Search in sources :

Example 1 with ServiceFunctionChain

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain in project netvirt by opendaylight.

the class PortChainTranslator method buildServiceFunctionPath.

public static ServiceFunctionPath buildServiceFunctionPath(ServiceFunctionChain sfc) {
    Preconditions.checkNotNull(sfc, "Service Function Chain must not be null");
    ServiceFunctionPathBuilder sfpBuilder = new ServiceFunctionPathBuilder();
    // Set the name
    sfpBuilder.setName(new SfpName(SFP_NAME_PREFIX + sfc.getName().getValue()));
    sfpBuilder.setSymmetric(sfc.isSymmetric());
    // Set related SFC name
    sfpBuilder.setServiceChainName(sfc.getName());
    return sfpBuilder.build();
}
Also used : ServiceFunctionPathBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder) SfpName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName)

Example 2 with ServiceFunctionChain

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain 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 3 with ServiceFunctionChain

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain in project netvirt by opendaylight.

the class PortChainTranslator method buildServiceFunctionChain.

public static ServiceFunctionChain buildServiceFunctionChain(PortChain portChain, List<ServiceFunction> sfList) {
    ServiceFunctionChainBuilder sfcBuilder = new ServiceFunctionChainBuilder();
    sfcBuilder.setName(new SfcName(portChain.getName()));
    sfcBuilder.setKey(new ServiceFunctionChainKey(sfcBuilder.getName()));
    // By default set it to false. If user specify it in chain parameters, it
    // will be overridden.
    sfcBuilder.setSymmetric(false);
    // Set service functions
    List<SfcServiceFunction> sfcSfList = new ArrayList<>();
    for (ServiceFunction sf : sfList) {
        SfcServiceFunctionBuilder sfcSfBuilder = new SfcServiceFunctionBuilder();
        sfcSfBuilder.setName(sf.getName().getValue());
        sfcSfBuilder.setType(sf.getType());
        sfcSfBuilder.setKey(new SfcServiceFunctionKey(sfcSfBuilder.getName()));
        // NOTE: no explicit order is set.
        sfcSfList.add(sfcSfBuilder.build());
    }
    List<ChainParameters> cpList = portChain.getChainParameters();
    if (cpList != null && !cpList.isEmpty()) {
        for (ChainParameters cp : cpList) {
            if (cp.getChainParameter().equals(SYMMETRIC_PARAM)) {
                // Override the symmetric default value.
                sfcBuilder.setSymmetric(Boolean.valueOf(cp.getChainParameterValue()));
                break;
            }
        }
    }
    sfcBuilder.setSfcServiceFunction(sfcSfList);
    return sfcBuilder.build();
}
Also used : SfcName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName) SfcServiceFunctionBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder) SfcServiceFunction(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction) ServiceFunction(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction) ServiceFunctionChainBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder) ArrayList(java.util.ArrayList) ChainParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParameters) SfcServiceFunction(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction) ServiceFunctionChainKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainKey) SfcServiceFunctionKey(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionKey)

Aggregations

ArrayList (java.util.ArrayList)2 ServiceFunction (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction)2 HashMap (java.util.HashMap)1 List (java.util.List)1 SfcName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName)1 SfpName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName)1 ServiceFunctionChain (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain)1 ServiceFunctionChainBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder)1 ServiceFunctionChainKey (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainKey)1 SfcServiceFunction (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction)1 SfcServiceFunctionBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder)1 SfcServiceFunctionKey (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionKey)1 ServiceFunctionForwarder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder)1 ServiceFunctionPath (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath)1 ServiceFunctionPathBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 ChainParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParameters)1 PortPairGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup)1 PortPair (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair)1