use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder 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.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder in project netvirt by opendaylight.
the class SfcProviderTest method createRsp.
private RenderedServicePathBuilder createRsp(RspName rspName, boolean hasHops, boolean hasSfName, boolean hasSffName, boolean hasDict, boolean hasSfDict, boolean createSff, boolean createSffDpl, boolean createLogicalSfDpl) {
RenderedServicePathBuilder rspBuilder = createRsp(rspName);
SffName sffName = new SffName(SFF_NAME);
SfName sfName = new SfName(SF_NAME);
RenderedServicePathHopBuilder rspHopBuilder = new RenderedServicePathHopBuilder();
if (hasSfName) {
rspHopBuilder.setServiceFunctionName(sfName);
}
if (hasSffName) {
rspHopBuilder.setServiceFunctionForwarder(sffName);
}
if (hasHops) {
List<RenderedServicePathHop> hops = new ArrayList<>();
hops.add(rspHopBuilder.build());
rspBuilder.setRenderedServicePathHop(hops);
}
ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder = new ServiceFunctionDictionaryBuilder();
serviceFunctionDictionaryBuilder.setName(sfName);
if (hasSfDict) {
SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
sffSfDataPlaneLocatorBuilder.setSffDplName(new SffDataPlaneLocatorName(SFF_DPL_NAME));
serviceFunctionDictionaryBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
}
if (hasDict) {
sffBuilder.setServiceFunctionDictionary(Collections.singletonList(serviceFunctionDictionaryBuilder.build()));
}
SffDataPlaneLocatorBuilder sffDplBuilder = new SffDataPlaneLocatorBuilder();
DataPlaneLocatorBuilder dataPlaneLocatorBuilder = new DataPlaneLocatorBuilder();
if (createLogicalSfDpl) {
LogicalInterfaceBuilder liBuilder = new LogicalInterfaceBuilder();
liBuilder.setInterfaceName(LOGICAL_IF_NAME);
dataPlaneLocatorBuilder.setLocatorType(liBuilder.build());
sffDplBuilder.setDataPlaneLocator(dataPlaneLocatorBuilder.build());
}
if (createSffDpl) {
List<SffDataPlaneLocator> sffDpls = new ArrayList<>();
sffDplBuilder.setKey(new SffDataPlaneLocatorKey(new SffDataPlaneLocatorName(SFF_DPL_NAME)));
sffDplBuilder.setName(new SffDataPlaneLocatorName(SFF_DPL_NAME));
sffDpls.add(sffDplBuilder.build());
sffBuilder.setSffDataPlaneLocator(sffDpls);
}
if (createSff) {
sffBuilder.setName(sffName);
storeSff(sffName, sffBuilder.build());
}
return rspBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder in project netvirt by opendaylight.
the class SfcProviderTest method getRenderedServicePath.
@Test
public void getRenderedServicePath() {
RspName rspName = new RspName(RSP_NAME);
RenderedServicePathBuilder rspBuilder = createRsp(rspName);
storeRsp(rspName, rspBuilder.build());
Optional<RenderedServicePath> rspOptional = this.sfcProvider.getRenderedServicePath(RSP_NAME);
assertTrue(rspOptional.isPresent());
}
Aggregations