use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName 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();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName 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();
}
Aggregations