Search in sources :

Example 1 with RenderedServicePathBuilder

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);
}
Also used : RspName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName) RenderedServicePathBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder) ConstantSchemaAbstractDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest) Test(org.junit.Test)

Example 2 with RenderedServicePathBuilder

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;
}
Also used : SffSfDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder) DataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) ServiceFunctionForwarderBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder) ArrayList(java.util.ArrayList) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName) RenderedServicePathHopBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHopBuilder) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) RenderedServicePathHop(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) RenderedServicePathBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder) LogicalInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterfaceBuilder) SffSfDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) SffDataPlaneLocatorKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorKey) ServiceFunctionDictionaryBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder) SffDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator)

Example 3 with RenderedServicePathBuilder

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());
}
Also used : RspName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName) RenderedServicePathBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder) RenderedServicePath(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath) ConstantSchemaAbstractDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest) Test(org.junit.Test)

Aggregations

RenderedServicePathBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder)3 Test (org.junit.Test)2 ConstantSchemaAbstractDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest)2 RspName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName)2 ArrayList (java.util.ArrayList)1 SfName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName)1 SffDataPlaneLocatorName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName)1 SffName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName)1 RenderedServicePath (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath)1 RenderedServicePathHop (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop)1 RenderedServicePathHopBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHopBuilder)1 SffDataPlaneLocator (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator)1 SffDataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder)1 SffDataPlaneLocatorKey (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorKey)1 DataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder)1 ServiceFunctionForwarderBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder)1 ServiceFunctionDictionaryBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder)1 SffSfDataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder)1 LogicalInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterfaceBuilder)1