import java.util.ArrayList;
import java.util.List;
+import java.util.stream.IntStream;
+
import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev171215.AdminStates;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.EthAttributes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.Interface1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.Interface1Builder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.ethernet.container.EthernetBuilder;
import org.slf4j.LoggerFactory;
-public class OpenRoadmOTNInterface {
+public class OpenRoadmOtnInterface221 {
private final PortMapping portMapping;
private final OpenRoadmInterfaces openRoadmInterfaces;
- private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmOtnInterface221.class);
- public OpenRoadmOTNInterface(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
+ public OpenRoadmOtnInterface221(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
this.portMapping = portMapping;
this.openRoadmInterfaces = openRoadmInterfaces;
}
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(String.format("Unable to get mapping from PortMapping for node % and"
- + " logical connection port %s", nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(
+ "Unable to get mapping from PortMapping for node % and logical connection port %s",
+ nodeId, logicalConnPoint));
}
// Ethernet interface specific data
- EthernetBuilder ethIfBuilder = new EthernetBuilder()
- .setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
- .setSpeed(1000L)
- .setMtu(9000L);
- //.setCurrSpeed("1000L")
- //.setCurrDuplex("FULL");
+ EthernetBuilder ethIfBuilder = new EthernetBuilder();
+ //ethIfBuilder.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled);
+ ethIfBuilder.setSpeed(1000L);
InterfaceBuilder ethInterfaceBldr =
createGenericInterfaceBuilder(portMap, EthernetCsmacd.class, logicalConnPoint + "-ETHERNET1G");
// Create Interface1 type object required for adding as augmentation
}
private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap,
- Class<? extends InterfaceType> type, String key) {
+ Class<? extends InterfaceType> type, String key) {
InterfaceBuilder interfaceBuilder = new InterfaceBuilder()
//.setDescription(" TBD ")
//.setCircuitId(" TBD ")
// Ethernet interface specific data
EthernetBuilder ethIfBuilder = new EthernetBuilder()
- .setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
- .setSpeed(10000L)
- .setMtu(9000L);
- //.setCurrSpeed("1000L")
- //.setCurrDuplex("FULL");
+ //.setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
+ .setSpeed(10000L);
// Create Interface1 type object required for adding as augmentation
Interface1Builder ethIf1Builder = new Interface1Builder();
InterfaceBuilder ethInterfaceBldr =
}
- public String createOpenRoadmOdu2eInterface(String nodeId, String logicalConnPoint, String serviceName,
- String payLoad, boolean isNetworkPort)
+ public String createOpenRoadmOdu2eInterface(
+ String nodeId, String logicalConnPoint, String serviceName,
+ String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
if (portMap == null) {
- throw new OpenRoadmInterfaceException(
- String.format("Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(
+ "Unable to get mapping from PortMapping for node % and logical connection port %s",
+ nodeId, logicalConnPoint));
}
String supportingInterface = null;
if (isNetworkPort) {
supportingInterface = portMap.getSupportingOdu4();
-
} else {
- // supportingInterface = portMap.getSupportingEthernet();
supportingInterface = logicalConnPoint + "-ETHERNET10G";
}
+
+ if (supportingInterface == null) {
+ throw new OpenRoadmInterfaceException(
+ "Interface Creation failed because of missing supported ODU4 on network end or Eth iface on client");
+ }
+
InterfaceBuilder oduInterfaceBldr =
createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2e-" + serviceName)
.setSupportingInterface(supportingInterface);
.setRate(ODU2e.class)
.setOduFunction(ODUTTPCTP.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
+ LOG.debug("Inside the ODU2e creation {} {} {}",isNetworkPort,tribPortNumber,tribSlotIndex);
if (isNetworkPort) {
List<Integer> tribSlots = new ArrayList<>();
- //add trib slots
- tribSlots.add(45);
+ int newIdx = tribSlotIndex;
+ tribSlots.add(newIdx);
+ IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach(
+ nbr -> tribSlots.add(nbr)
+ );
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
- //set trib port numbers
- .setTribPortNumber(24)
+ .setTribPortNumber(tribPortNumber)
.setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.NotTerminated)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
}
else {
// Set Opu attributes
OpuBuilder opuBldr = new OpuBuilder()
- .setPayloadType(new PayloadTypeDef(payLoad))
- .setExpPayloadType(new PayloadTypeDef(payLoad));
- //.setRxPayloadType("07")
- //.setPayloadInterface(payLoad);
+ .setPayloadType(new PayloadTypeDef(payLoad))
+ .setExpPayloadType(new PayloadTypeDef(payLoad));
oduIfBuilder.setOpu(opuBldr.build());
}
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
oduIf1Builder.setOdu(oduIfBuilder.build()).build());
return oduInterfaceBldr.getName();
}
- public String createOpenRoadmOdu0Interface(String nodeId, String logicalConnPoint, String serviceName,
- String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlot)
+ public String createOpenRoadmOdu0Interface(String nodeId, String logicalConnPoint,
+ String serviceName, String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlot)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
String supportingInterface = null;
if (isNetworkPort) {
supportingInterface = portMap.getSupportingOdu4();
} else {
- // supportingInterface = portMap.getSupportingEthernet();
supportingInterface = logicalConnPoint + "-ETHERNET1G";
}
if (portMap == null) {
- throw new OpenRoadmInterfaceException(
- String.format("Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
+ throw new OpenRoadmInterfaceException(String.format(
+ "Unable to get mapping from PortMapping for node % and logical connection port %s",
+ nodeId, logicalConnPoint));
}
- InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint
- + "-ODU0-" + serviceName);
+ InterfaceBuilder oduInterfaceBldr =
+ createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU0-" + serviceName);
oduInterfaceBldr.setSupportingInterface(supportingInterface);
// ODU interface specific data
.setOduFunction(ODUTTPCTP.class)
.setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
if (isNetworkPort) {
+ LOG.debug("Network port is true");
List<Integer> tribSlots = new ArrayList<>();
tribSlots.add(tribSlot); //add trib slots
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
.setTribPortNumber(tribPortNumber)
.setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.NotTerminated)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
+ LOG.debug("Network port is true {} {} {}",
+ oduIfBuilder.getParentOduAllocation().getTribSlots(),
+ oduIfBuilder.getRate(),
+ oduIfBuilder.getParentOduAllocation().getTribPortNumber());
}
else {
- // Set Opu attributes
+ LOG.debug("Current port is a client port");
OpuBuilder opuBldr = new OpuBuilder()
- .setPayloadType(new PayloadTypeDef(payLoad))
- .setExpPayloadType(new PayloadTypeDef(payLoad));
- //.setRxPayloadType("07")
- //.setPayloadInterface(payLoad);
+ .setPayloadType(new PayloadTypeDef(payLoad))
+ .setExpPayloadType(new PayloadTypeDef(payLoad));
oduIfBuilder.setOpu(opuBldr.build());
}
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
- oduIf1Builder.setOdu(oduIfBuilder.build()).build());
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
+ oduIf1Builder.setOdu(oduIfBuilder.build()).build());
// Post interface on the device
this.openRoadmInterfaces.postOTNInterface(nodeId, oduInterfaceBldr);
return oduInterfaceBldr.getName();
}
- public String createOpenRoadmOdu2Interface(String nodeId, String logicalConnPoint, String serviceName,
- String payLoad, boolean isNetworkPort)
+
+ public String createOpenRoadmOdu2Interface(
+ String nodeId, String logicalConnPoint, String serviceName,
+ String payLoad, boolean isNetworkPort, int tribPortNumber, int tribSlotIndex)
throws OpenRoadmInterfaceException {
Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
String supportingInterface = null;
- if (portMap == null) {
- throw new OpenRoadmInterfaceException(
- String.format("Unable to get mapping from PortMapping for node % and logical connection port %s",
- nodeId, logicalConnPoint));
- }
+
if (isNetworkPort) {
supportingInterface = portMap.getSupportingOdu4();
} else {
supportingInterface = portMap.getSupportingEthernet();
}
+ if (portMap == null) {
+ throw new OpenRoadmInterfaceException(
+ String.format("Unable to get mapping from PortMapping for node % and logical connection port %s",
+ nodeId, logicalConnPoint));
+ }
InterfaceBuilder oduInterfaceBldr =
createGenericInterfaceBuilder(portMap, OtnOdu.class, logicalConnPoint + "-ODU2-" + serviceName)
.setSupportingInterface(supportingInterface);
.setMonitoringMode(OduAttributes.MonitoringMode.Terminated);
if (isNetworkPort) {
List<Integer> tribSlots = new ArrayList<>();
- tribSlots.add(45); //add trib slots
+ IntStream.range(tribSlotIndex, tribSlotIndex + 8).forEach(
+ nbr -> tribSlots.add(nbr)
+ );
ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
//set trib port numbers
- .setTribPortNumber(24)
+ .setTribPortNumber(tribPortNumber)
.setTribSlots(tribSlots);
oduIfBuilder.setOduFunction(ODUCTP.class)
- .setMonitoringMode(OduAttributes.MonitoringMode.NotTerminated)
+ .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
.setParentOduAllocation(parentOduAllocationBuilder.build());
}
else {
// Set Opu attributes
OpuBuilder opuBldr = new OpuBuilder()
- .setPayloadType(new PayloadTypeDef(payLoad))
- .setExpPayloadType(new PayloadTypeDef(payLoad));
- //.setRxPayloadType("07")
- //.setPayloadInterface(payLoad);
+ .setPayloadType(new PayloadTypeDef(payLoad))
+ .setExpPayloadType(new PayloadTypeDef(payLoad));
oduIfBuilder.setOpu(opuBldr.build());
}
// Create Interface1 type object required for adding as augmentation
// TODO look at imports of different versions of class
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder oduIf1Builder =
- new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
+ new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
oduInterfaceBldr.addAugmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
- oduIf1Builder.setOdu(oduIfBuilder.build()).build());
+ org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
+ oduIf1Builder.setOdu(oduIfBuilder.build()).build());
// Post interface on the device
this.openRoadmInterfaces.postOTNInterface(nodeId, oduInterfaceBldr);