Search in sources :

Example 1 with PortPairGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup in project netvirt by opendaylight.

the class PortPairGroupTranslator method buildServiceFunctionForwarder.

public static ServiceFunctionForwarder buildServiceFunctionForwarder(PortPairGroup portPairGroup, List<PortPair> portPairs) {
    Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
    Preconditions.checkNotNull(portPairs, "Port pairs must not be null");
    Preconditions.checkElementIndex(0, portPairs.size(), "There must be at least one port pair");
    // Currently we only support one SF per type. Mean, one port-pair per port-pair-group.
    final PortPair portPair = portPairs.get(0);
    ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
    sffBuilder.setName(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
    DataPlaneLocatorBuilder forwardDplBuilder = new DataPlaneLocatorBuilder();
    forwardDplBuilder.setTransport(Mac.class);
    String forwardPort = portPair.getIngress().getValue();
    LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
    forwardDplBuilder.setLocatorType(forwardInterface);
    SffDataPlaneLocatorBuilder sffForwardDplBuilder = new SffDataPlaneLocatorBuilder();
    sffForwardDplBuilder.setDataPlaneLocator(forwardDplBuilder.build());
    String forwardDplName = portPair.getName() + DPL_INGRESS_SUFFIX;
    sffForwardDplBuilder.setName(new SffDataPlaneLocatorName(forwardDplName));
    DataPlaneLocatorBuilder reverseDplBuilder = new DataPlaneLocatorBuilder();
    reverseDplBuilder.setTransport(Mac.class);
    String reversePort = portPair.getEgress().getValue();
    LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
    reverseDplBuilder.setLocatorType(reverseInterface);
    SffDataPlaneLocatorBuilder sffReverseDplBuilder = new SffDataPlaneLocatorBuilder();
    sffReverseDplBuilder.setDataPlaneLocator(reverseDplBuilder.build());
    String reverseDplName = portPair.getName() + DPL_EGRESS_SUFFIX;
    sffReverseDplBuilder.setName(new SffDataPlaneLocatorName(reverseDplName));
    List<SffDataPlaneLocator> sffDataPlaneLocator = new ArrayList<>();
    sffDataPlaneLocator.add(sffForwardDplBuilder.build());
    sffDataPlaneLocator.add(sffReverseDplBuilder.build());
    sffBuilder.setSffDataPlaneLocator(sffDataPlaneLocator);
    SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
    sffSfDataPlaneLocatorBuilder.setSffForwardDplName(new SffDataPlaneLocatorName(forwardDplName));
    sffSfDataPlaneLocatorBuilder.setSfForwardDplName(new SfDataPlaneLocatorName(forwardDplName));
    sffSfDataPlaneLocatorBuilder.setSffReverseDplName(new SffDataPlaneLocatorName(reverseDplName));
    sffSfDataPlaneLocatorBuilder.setSfReverseDplName(new SfDataPlaneLocatorName(reverseDplName));
    ServiceFunctionDictionaryBuilder sfdBuilder = new ServiceFunctionDictionaryBuilder();
    sfdBuilder.setName(new SfName(portPair.getName()));
    sfdBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
    List<ServiceFunctionDictionary> sfdList = new ArrayList<>();
    sfdList.add(sfdBuilder.build());
    sffBuilder.setServiceFunctionDictionary(sfdList);
    return sffBuilder.build();
}
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) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) SfDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName) 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) 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) PortPair(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair) 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) 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) ServiceFunctionDictionaryBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder)

Example 2 with PortPairGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup 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 PortPairGroup

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup in project netvirt by opendaylight.

the class PortPairTranslator method buildServiceFunction.

@Nonnull
public static ServiceFunction buildServiceFunction(PortPair portPair, PortPairGroup portPairGroup) {
    Preconditions.checkNotNull(portPair, "Port pair must not be null");
    Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
    ServiceFunctionBuilder serviceFunctionBuilder = new ServiceFunctionBuilder();
    // Set SF name and tenant-id
    serviceFunctionBuilder.setName(new SfName(portPair.getName()));
    serviceFunctionBuilder.setTenantId(new TenantId(portPair.getTenantId().getValue()));
    // Set SF Type. Setting it to PortPairGroup Type, this will be overridden if user pass
    // it through service_function_params
    serviceFunctionBuilder.setType(SftTypeName.getDefaultInstance(portPairGroup.getName()));
    // If user pass specific param using service_function_parameters, set/override it accordingly
    Class transportTypeClass = null;
    List<ServiceFunctionParameters> sfParams = portPair.getServiceFunctionParameters();
    if (sfParams != null) {
        for (ServiceFunctionParameters sfParam : sfParams) {
            // There is by default type set to port pair group name, override it if user pass it specific type
            if (sfParam.getServiceFunctionParameter().equals(SF_TYPE_PARAM)) {
                serviceFunctionBuilder.setType(new SftTypeName(sfParam.getServiceFunctionParameterValue()));
            }
            if (sfParam.getServiceFunctionParameter().equals(DPL_TRANSPORT_PARAM)) {
                transportTypeClass = DPL_TRANSPORT_TYPE.get(sfParam.getServiceFunctionParameterValue());
            }
        }
    }
    // Build forward DPL
    SfDataPlaneLocatorBuilder sfForwardDplBuilder = new SfDataPlaneLocatorBuilder();
    sfForwardDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_INGRESS_SUFFIX));
    sfForwardDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
    sfForwardDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
    String forwardPort = portPair.getIngress().getValue();
    LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
    sfForwardDplBuilder.setLocatorType(forwardInterface);
    // Build reverse DPL
    SfDataPlaneLocatorBuilder sfReverseDplBuilder = new SfDataPlaneLocatorBuilder();
    sfReverseDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_EGRESS_SUFFIX));
    sfReverseDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
    sfReverseDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
    String reversePort = portPair.getEgress().getValue();
    LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
    sfReverseDplBuilder.setLocatorType(reverseInterface);
    // Set all data plane locator
    List<SfDataPlaneLocator> sfDataPlaneLocatorList = new ArrayList<>();
    sfDataPlaneLocatorList.add(sfForwardDplBuilder.build());
    sfDataPlaneLocatorList.add(sfReverseDplBuilder.build());
    serviceFunctionBuilder.setSfDataPlaneLocator(sfDataPlaneLocatorList);
    return serviceFunctionBuilder.build();
}
Also used : SfDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocator) ServiceFunctionBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder) ArrayList(java.util.ArrayList) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName) Mac(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac) TenantId(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId) SfDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName) SftTypeName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SftTypeName) LogicalInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.functions.service.function.sf.data.plane.locator.locator.type.LogicalInterfaceBuilder) LogicalInterface(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.functions.service.function.sf.data.plane.locator.locator.type.LogicalInterface) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) SfDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocatorBuilder) ServiceFunctionParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.pair.attributes.ServiceFunctionParameters) Nonnull(javax.annotation.Nonnull)

Aggregations

ArrayList (java.util.ArrayList)3 SfDataPlaneLocatorName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName)2 SfName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName)2 SffName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName)2 PortPair (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 SffDataPlaneLocatorName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName)1 SftTypeName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SftTypeName)1 TenantId (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId)1 SfDataPlaneLocator (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocator)1 SfDataPlaneLocatorBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocatorBuilder)1 ServiceFunction (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction)1 ServiceFunctionBuilder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder)1 ServiceFunctionChain (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain)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 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 ServiceFunctionForwarder (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder)1