use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.LogicalInterfaceLocator in project netvirt by opendaylight.
the class SfcProviderTest method getFirstHopSfInterfaceFromRsp.
@Test
public void getFirstHopSfInterfaceFromRsp() {
RspName rspName = new RspName(RSP_NAME);
// Check RSP with no hops
RenderedServicePathBuilder rspBuilder = createRsp(rspName);
Optional<String> ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with no SF name
rspBuilder = createRsp(rspName, true, false, false, false, false, false, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with SF name, but no SFF name
rspBuilder = createRsp(rspName, true, true, false, false, false, false, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with SF name, but SFF doesnt exist
rspBuilder = createRsp(rspName, true, true, true, false, false, false, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with SF and SFF, but SFF has no dictionary
rspBuilder = createRsp(rspName, true, true, true, false, false, true, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with SF and SFF, but SFF has no dictionary entry for SF
rspBuilder = createRsp(rspName, true, true, true, true, false, true, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with SF, SFF name, SFF exists, but has no DPL
rspBuilder = createRsp(rspName, true, true, true, true, true, true, false, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP with Sfm SFF name, SFF exists, has DPL, but not of type LogicalInterfaceLocator
rspBuilder = createRsp(rspName, true, true, true, true, true, true, true, false);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertFalse(ifName.isPresent());
// Check RSP when its all created correctly
rspBuilder = createRsp(rspName, true, true, true, true, true, true, true, true);
ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
assertTrue(ifName.isPresent());
assertEquals(ifName.get(), LOGICAL_IF_NAME);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.LogicalInterfaceLocator 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;
}
Aggregations