use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder in project netvirt by opendaylight.
the class PortPairGroupTranslator method buildServiceFunctionForwarder.
public static ServiceFunctionForwarder buildServiceFunctionForwarder(PortPairGroup portPairGroup, List<PortPair> portPairs) {
Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
Preconditions.checkNotNull(portPairs, "Port pairs must not be null");
Preconditions.checkElementIndex(0, portPairs.size(), "There must be at least one port pair");
// Currently we only support one SF per type. Mean, one port-pair per port-pair-group.
final PortPair portPair = portPairs.get(0);
ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
sffBuilder.setName(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
DataPlaneLocatorBuilder forwardDplBuilder = new DataPlaneLocatorBuilder();
forwardDplBuilder.setTransport(Mac.class);
String forwardPort = portPair.getIngress().getValue();
LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
forwardDplBuilder.setLocatorType(forwardInterface);
SffDataPlaneLocatorBuilder sffForwardDplBuilder = new SffDataPlaneLocatorBuilder();
sffForwardDplBuilder.setDataPlaneLocator(forwardDplBuilder.build());
String forwardDplName = portPair.getName() + DPL_INGRESS_SUFFIX;
sffForwardDplBuilder.setName(new SffDataPlaneLocatorName(forwardDplName));
DataPlaneLocatorBuilder reverseDplBuilder = new DataPlaneLocatorBuilder();
reverseDplBuilder.setTransport(Mac.class);
String reversePort = portPair.getEgress().getValue();
LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
reverseDplBuilder.setLocatorType(reverseInterface);
SffDataPlaneLocatorBuilder sffReverseDplBuilder = new SffDataPlaneLocatorBuilder();
sffReverseDplBuilder.setDataPlaneLocator(reverseDplBuilder.build());
String reverseDplName = portPair.getName() + DPL_EGRESS_SUFFIX;
sffReverseDplBuilder.setName(new SffDataPlaneLocatorName(reverseDplName));
List<SffDataPlaneLocator> sffDataPlaneLocator = new ArrayList<>();
sffDataPlaneLocator.add(sffForwardDplBuilder.build());
sffDataPlaneLocator.add(sffReverseDplBuilder.build());
sffBuilder.setSffDataPlaneLocator(sffDataPlaneLocator);
SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
sffSfDataPlaneLocatorBuilder.setSffForwardDplName(new SffDataPlaneLocatorName(forwardDplName));
sffSfDataPlaneLocatorBuilder.setSfForwardDplName(new SfDataPlaneLocatorName(forwardDplName));
sffSfDataPlaneLocatorBuilder.setSffReverseDplName(new SffDataPlaneLocatorName(reverseDplName));
sffSfDataPlaneLocatorBuilder.setSfReverseDplName(new SfDataPlaneLocatorName(reverseDplName));
ServiceFunctionDictionaryBuilder sfdBuilder = new ServiceFunctionDictionaryBuilder();
sfdBuilder.setName(new SfName(portPair.getName()));
sfdBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
List<ServiceFunctionDictionary> sfdList = new ArrayList<>();
sfdList.add(sfdBuilder.build());
sffBuilder.setServiceFunctionDictionary(sfdList);
return sffBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder in project netvirt by opendaylight.
the class NeutronPortPairListener method remove.
/**
* Method removes PortPair which is identified by InstanceIdentifier.
*
* @param deletedPortPair - PortPair for removing
*/
@Override
public void remove(PortPair deletedPortPair) {
LOG.info("Received remove port pair event {}", deletedPortPair);
ServiceFunctionKey sfKey = PortPairTranslator.getSFKey(deletedPortPair);
LOG.info("Removing service function {}", sfKey);
sfcMdsalHelper.removeServiceFunction(sfKey);
ServiceFunctionForwarder sff;
ServiceFunctionForwarder updatedSff;
SffName sffName = new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME);
sff = sfcMdsalHelper.readServiceFunctionForwarder(new ServiceFunctionForwarderKey(sffName));
updatedSff = PortPairGroupTranslator.removePortPairFromServiceFunctionForwarder(sff, deletedPortPair);
LOG.info("Updating service function forwarder as {}", updatedSff);
sfcMdsalHelper.addServiceFunctionForwarder(updatedSff);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder in project netvirt by opendaylight.
the class SfcProvider method getServiceFunctionForwarder.
private Optional<ServiceFunctionForwarder> getServiceFunctionForwarder(SffName name) {
ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(name);
InstanceIdentifier<ServiceFunctionForwarder> sffIid;
sffIid = InstanceIdentifier.builder(ServiceFunctionForwarders.class).child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey).build();
return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, sffIid).toJavaUtil();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder 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.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder in project netvirt by opendaylight.
the class SfcProviderTest method storeSff.
@SuppressWarnings("deprecation")
private void storeSff(SffName sffName, ServiceFunctionForwarder sff) {
InstanceIdentifier<ServiceFunctionForwarder> sffIid;
sffIid = InstanceIdentifier.builder(ServiceFunctionForwarders.class).child(ServiceFunctionForwarder.class, new ServiceFunctionForwarderKey(sffName)).build();
MDSALUtil.syncWrite(getDataBroker(), LogicalDatastoreType.CONFIGURATION, sffIid, sff);
}
Aggregations