Search in sources :

Example 1 with ServiceFunctionForwarderBase

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarderBase 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;
}
Also used : RenderedServicePaths(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths) LogicalInterfaceLocator(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.LogicalInterfaceLocator) SffSfDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator) LoggerFactory(org.slf4j.LoggerFactory) SfpName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) RspName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName) ServiceFunctionDictionary(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary) SffDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator) ServiceFunctionForwarderBase(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarderBase) RenderedServicePathHop(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop) RenderedServicePathKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) ServiceFunctionForwarder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) Logger(org.slf4j.Logger) RenderedServicePath(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath) ServiceFunctionForwarders(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders) ServiceFunctionPathStateKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.ServiceFunctionPathStateKey) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ServiceFunctionPathState(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.ServiceFunctionPathState) List(java.util.List) ServiceFunctionForwarderKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName) Optional(java.util.Optional) Collections(java.util.Collections) LogicalInterface(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.LogicalInterface) ServiceFunctionPathsState(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsState) LogicalInterfaceLocator(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.LogicalInterfaceLocator) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) SffSfDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator) ServiceFunctionForwarder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder) LogicalInterface(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.LogicalInterface) ServiceFunctionForwarderBase(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarderBase) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)1 RspName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName)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 SfpName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName)1 RenderedServicePaths (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths)1 RenderedServicePath (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath)1 RenderedServicePathKey (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey)1 RenderedServicePathHop (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop)1 ServiceFunctionForwarderBase (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarderBase)1 ServiceFunctionForwarders (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders)1