use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.
the class SfcProvider method getHopSfInterface.
private Optional<String> getHopSfInterface(RenderedServicePathHop hop, boolean useForwardDpl) {
LOG.trace("getHopSfInterface of hop {}", hop);
SfName sfName = hop.getServiceFunctionName();
if (sfName == null) {
LOG.warn("getHopSfInterface hop has no SF");
return Optional.empty();
}
SffName sffName = hop.getServiceFunctionForwarder();
if (sffName == null) {
LOG.warn("getHopSfInterface hop has no SFF");
return Optional.empty();
}
Optional<ServiceFunctionForwarder> sff = getServiceFunctionForwarder(sffName);
if (!sff.isPresent()) {
LOG.warn("getHopSfInterface SFF [{}] does not exist", sffName.getValue());
return Optional.empty();
}
// Find the SFF-SF data plane locator for the SF pair
SffSfDataPlaneLocator sffSfDataPlaneLocator = sff.map(ServiceFunctionForwarder::getServiceFunctionDictionary).orElse(Collections.emptyList()).stream().filter(serviceFunctionDictionary -> serviceFunctionDictionary.getName().equals(sfName)).findAny().map(ServiceFunctionDictionary::getSffSfDataPlaneLocator).orElse(null);
if (sffSfDataPlaneLocator == null) {
LOG.warn("getHopSfInterface SFF [{}] has not dictionary for SF [{}]", sffName.getValue(), sffName.getValue());
return Optional.empty();
}
// Get the forward or reverse locator name as appropriate if any,
// otherwise default to non directional locator
SffDataPlaneLocatorName sffDataPlaneLocatorName = null;
if (useForwardDpl) {
sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffForwardDplName();
} else {
sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffReverseDplName();
}
if (sffDataPlaneLocatorName == null) {
sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffDplName();
}
// Get the interface name value of the locator with such name
SffDataPlaneLocatorName locatorName = sffDataPlaneLocatorName;
Optional<String> interfaceName = sff.map(ServiceFunctionForwarderBase::getSffDataPlaneLocator).orElse(Collections.emptyList()).stream().filter(sffDataPlaneLocator -> sffDataPlaneLocator.getName().equals(locatorName)).findAny().map(SffDataPlaneLocator::getDataPlaneLocator).filter(dataPlaneLocator -> dataPlaneLocator.getLocatorType() instanceof LogicalInterface).map(dataPlaneLocator -> (LogicalInterfaceLocator) dataPlaneLocator.getLocatorType()).map(LogicalInterfaceLocator::getInterfaceName);
return interfaceName;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.
the class OpenflowRenderer method renderPath.
@Override
// FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
@SuppressFBWarnings("UC_USELESS_OBJECT")
public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
List<Flow> flows = new ArrayList<>();
if (firstHopIp != null) {
Long port = geniusProvider.getEgressVxlanPortForNode(OpenFlow13Provider.getDpnIdFromNodeId(nodeId)).orElse(null);
if (port == null) {
LOG.error("OpenflowRenderer: cant get egressPort for nodeId [{}]", nodeId.getValue());
return;
}
Flow flow;
flow = openFlow13Provider.createEgressClassifierTransportEgressRemoteFlow(nodeId, nsp, port, firstHopIp);
flows.add(flow);
} else {
Flow flow;
flow = openFlow13Provider.createEgressClassifierTransportEgressLocalFlow(nodeId, nsp);
flows.add(flow);
}
short egressNsi = (short) (nsi - nsl);
flows.add(openFlow13Provider.createIngressClassifierFilterChainEgressFlow(nodeId, nsp, egressNsi));
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx))), LOG, "Error rendering a path");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.
the class L2GatewayListener method remove.
@Override
protected void remove(final InstanceIdentifier<L2gateway> identifier, final L2gateway input) {
LOG.info("Removing L2gateway with ID: {}", input.getUuid());
List<L2gatewayConnection> connections = l2gwService.getL2GwConnectionsByL2GatewayId(input.getUuid());
try {
ReadWriteTransaction tx = this.dataBroker.newReadWriteTransaction();
for (L2gatewayConnection connection : connections) {
InstanceIdentifier<L2gatewayConnection> iid = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class).child(L2gatewayConnection.class, connection.getKey());
tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
}
tx.submit().checkedGet();
} catch (TransactionCommitFailedException e) {
LOG.error("Failed to delete associated l2gwconnection while deleting l2gw {} with id beacause of {}", input.getUuid(), e.getLocalizedMessage());
// TODO :retry
}
List<Devices> l2Devices = input.getDevices();
for (Devices l2Device : l2Devices) {
LOG.trace("Removing L2gateway device: {}", l2Device);
removeL2Device(l2Device, input);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.
the class L2GatewayListener method update.
@Override
protected void update(InstanceIdentifier<L2gateway> identifier, L2gateway original, L2gateway update) {
LOG.trace("Updating L2gateway : key: {}, original value={}, update value={}", identifier, original, update);
List<L2gatewayConnection> connections = l2gwService.getAssociatedL2GwConnections(Sets.newHashSet(update.getUuid()));
if (connections == null) {
LOG.warn("There are no connections associated with l2 gateway uuid {} name {}", update.getUuid(), update.getName());
return;
}
if (original.getDevices() == null) {
connections.forEach((connection) -> l2gwService.addL2GatewayConnection(connection));
return;
}
jobCoordinator.enqueueJob("l2gw.update", () -> {
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
List<ListenableFuture<Void>> fts = new ArrayList<>();
original.getDevices().stream().filter((originalDevice) -> originalDevice.getInterfaces() != null).forEach((originalDevice) -> {
String deviceName = originalDevice.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(new NodeId(l2GwDevice.getHwvtepNodeId()), deviceName);
originalDevice.getInterfaces().stream().filter((intf) -> !updatedDeviceInterfaces.containsInterface(deviceName, intf.getInterfaceName())).forEach((intf) -> {
connections.forEach((connection) -> {
Integer vlanId = connection.getSegmentId();
if (intf.getSegmentationIds() != null && !intf.getSegmentationIds().isEmpty()) {
for (Integer vlan : intf.getSegmentationIds()) {
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlan);
}
} else {
LOG.debug("Deleting vlan binding {} {} {}", physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
}
});
});
});
fts.add(transaction.submit());
Futures.addCallback(fts.get(0), new FutureCallback<Void>() {
@Override
public void onSuccess(Void success) {
LOG.debug("Successfully deleted vlan bindings for l2gw update {}", update);
connections.forEach((l2GwConnection) -> l2gwService.addL2GatewayConnection(l2GwConnection, null, update));
}
@Override
public void onFailure(Throwable throwable) {
LOG.error("Failed to delete vlan bindings as part of l2gw udpate {}", update);
}
}, MoreExecutors.directExecutor());
return fts;
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project openflowplugin by opendaylight.
the class AbstractNotificationSupplierBase method getNodeII.
/**
* Method returns a keyed {@link InstanceIdentifier} for {@link Node} from inventory
* because this path is a base for every OF paths.
*
* @param ii - key for keyed {@link Node} {@link InstanceIdentifier}
* @return Keyed InstanceIdentifier for Node
*/
protected static KeyedInstanceIdentifier<Node, NodeKey> getNodeII(final InstanceIdentifier<?> ii) {
final NodeKey key = ii.firstKeyOf(Node.class, NodeKey.class);
Preconditions.checkArgument(key != null);
return InstanceIdentifier.create(Nodes.class).child(Node.class, key);
}
Aggregations