Search in sources :

Example 1 with SfcServiceFunctionKey

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionKey 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)1 SfcName (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName)1 ServiceFunction (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction)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 ChainParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParameters)1