Search in sources :

Example 6 with ServiceFunctionForwarder

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 NeutronPortChainListener method processPortChain.

private void processPortChain(PortChain newPortChain) {
    // List of Port Pair Group attached to the Port Chain
    List<PortPairGroup> portPairGroupList = new ArrayList<>();
    // Port Pair Group and associated Port Pair
    Map<Uuid, List<PortPair>> groupPortPairsList = new HashMap<>();
    List<ServiceFunction> portChainServiceFunctionList = new ArrayList<>();
    // Read chain related port pair group from neutron data store
    for (Uuid ppgUuid : newPortChain.getPortPairGroups()) {
        PortPairGroup ppg = neutronMdsalHelper.getNeutronPortPairGroup(ppgUuid);
        if (ppg != null) {
            List<PortPair> portPairList = new ArrayList<>();
            portPairGroupList.add(ppg);
            for (Uuid ppUuid : ppg.getPortPairs()) {
                PortPair pp = neutronMdsalHelper.getNeutronPortPair(ppUuid);
                if (pp == null) {
                    LOG.error("Port pair {} does not exist in the neutron data store", ppUuid);
                    return;
                }
                portPairList.add(pp);
            }
            groupPortPairsList.put(ppgUuid, portPairList);
        }
    }
    // For each port pair group
    for (PortPairGroup ppg : portPairGroupList) {
        List<PortPair> portPairList = groupPortPairsList.get(ppg.getUuid());
        // Generate all the SF and write it to SFC data store
        for (PortPair portPair : portPairList) {
            // Build the service function for the given port pair.
            ServiceFunction serviceFunction = PortPairTranslator.buildServiceFunction(portPair, ppg);
            portChainServiceFunctionList.add(serviceFunction);
            // Write the Service Function to SFC data store.
            LOG.info("Add Service Function {} for Port Pair {}", serviceFunction, portPair);
            sfcMdsalHelper.addServiceFunction(serviceFunction);
        }
        // Build the SFF Builder from port pair group
        ServiceFunctionForwarder serviceFunctionForwarder;
        serviceFunctionForwarder = PortPairGroupTranslator.buildServiceFunctionForwarder(ppg, portPairList);
        // Send SFF create request
        LOG.info("Update Service Function Forwarder with {} for Port Pair Group {}", serviceFunctionForwarder, ppg);
        sfcMdsalHelper.updateServiceFunctionForwarder(serviceFunctionForwarder);
    }
    // Build Service Function Chain Builder
    ServiceFunctionChain sfc = PortChainTranslator.buildServiceFunctionChain(newPortChain, portChainServiceFunctionList);
    // Write SFC to data store
    if (sfc == null) {
        LOG.warn("Service Function Chain building failed for Port Chain {}", newPortChain);
        return;
    }
    LOG.info("Add service function chain {}", sfc);
    sfcMdsalHelper.addServiceFunctionChain(sfc);
    // Build Service Function Path Builder
    ServiceFunctionPath sfp = PortChainTranslator.buildServiceFunctionPath(sfc);
    // Write SFP to data store
    LOG.info("Add service function path {}", sfp);
    sfcMdsalHelper.addServiceFunctionPath(sfp);
    // The RSP will automatically be created from the SFP added above.
    // Add ACLs from flow classifiers
    processFlowClassifiers(newPortChain, newPortChain.getFlowClassifiers(), sfp.getName().getValue());
}
Also used : PortPairGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup) HashMap(java.util.HashMap) ServiceFunctionPath(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath) ArrayList(java.util.ArrayList) ServiceFunctionForwarder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder) ServiceFunctionChain(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain) ServiceFunction(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortPair(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with ServiceFunctionForwarder

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 removePortPairFromServiceFunctionForwarder.

public static ServiceFunctionForwarder removePortPairFromServiceFunctionForwarder(ServiceFunctionForwarder serviceFunctionForwarder, PortPair deletedPortPair) {
    Preconditions.checkNotNull(deletedPortPair, "Port pair must not be null");
    String portPairName = deletedPortPair.getName();
    ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder(serviceFunctionForwarder);
    List<ServiceFunctionDictionary> serviceFunctionDictionaryList = sffBuilder.getServiceFunctionDictionary();
    if (serviceFunctionDictionaryList == null) {
        LOG.debug("SF dictionary is empty");
        return serviceFunctionForwarder;
    }
    ServiceFunctionDictionary serviceFunctionDictionary = serviceFunctionDictionaryList.stream().filter(sfDictionary -> sfDictionary.getName().getValue().equals(portPairName)).findFirst().orElse(null);
    if (serviceFunctionDictionary == null) {
        LOG.debug("SFF dictionary entry for port pair {} not found", portPairName);
        return serviceFunctionForwarder;
    }
    SffSfDataPlaneLocator sffSfDataPlaneLocator = serviceFunctionDictionary.getSffSfDataPlaneLocator();
    if (sffSfDataPlaneLocator != null) {
        List<SffDataPlaneLocatorName> locators = Arrays.asList(sffSfDataPlaneLocator.getSffDplName(), sffSfDataPlaneLocator.getSffForwardDplName(), sffSfDataPlaneLocator.getSffReverseDplName());
        List<SffDataPlaneLocator> sffDplList = sffBuilder.getSffDataPlaneLocator();
        if (sffDplList != null) {
            sffDplList.stream().filter(sffDataPlaneLocator -> locators.contains(sffDataPlaneLocator.getName())).map(sffDplList::remove);
        }
    }
    serviceFunctionDictionaryList.remove(serviceFunctionDictionary);
    return sffBuilder.build();
}
Also used : SfDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName) PortPair(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair) Arrays(java.util.Arrays) 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) ServiceFunctionForwarderBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder) 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) SfcMdsalHelper(org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper) 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) ArrayList(java.util.ArrayList) 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) ServiceFunctionForwarder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder) Mac(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) Logger(org.slf4j.Logger) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) DataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder) List(java.util.List) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName) Preconditions(com.google.common.base.Preconditions) PortPairGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup) 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) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) ServiceFunctionDictionaryBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) ServiceFunctionForwarderBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder) 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) 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)

Aggregations

ServiceFunctionForwarder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder)6 SffName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName)4 ServiceFunctionForwarderKey (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SfName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName)3 SffDataPlaneLocatorName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName)3 ServiceFunctionForwarders (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders)3 SffDataPlaneLocator (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator)3 ServiceFunctionDictionary (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary)3 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)3 PortPair (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair)3 SfDataPlaneLocatorName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName)2 SffDataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder)2 DataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder)2 ServiceFunctionForwarderBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder)2 ServiceFunctionDictionaryBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder)2 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)2 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)2 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)2