use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder 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();
}
Aggregations