Refactor renderer-blueprint
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
index 91e22ac37ff10f77eb247ec17cb995bad3aea3c0..cc99c4386b97dac192395befd11c4b3737327f1b 100644 (file)
@@ -14,11 +14,13 @@ import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.MappingUtils;
+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.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OpucnTribSlotDef;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,15 +38,14 @@ public class OpenRoadmInterfaceFactory {
     private final OpenRoadmOtnInterface221 openRoadmOtnInterface221;
     private final OpenRoadmOtnInterface710 openRoadmOtnInterface710;
 
-    public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, OpenRoadmInterface121 openRoadmInterface121,
-            OpenRoadmInterface221 openRoadmInterface221, OpenRoadmInterface710 openRoadmInterface710,
-            OpenRoadmOtnInterface221 openRoadmOTNInterface221, OpenRoadmOtnInterface710 openRoadmOtnInterface710) {
+    public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, PortMapping portMapping,
+            OpenRoadmInterfaces openRoadmInterfaces) {
         this.mappingUtils = mappingUtils;
-        this.openRoadmInterface121 = openRoadmInterface121;
-        this.openRoadmInterface221 = openRoadmInterface221;
-        this.openRoadmInterface710 = openRoadmInterface710;
-        this.openRoadmOtnInterface221 = openRoadmOTNInterface221;
-        this.openRoadmOtnInterface710 = openRoadmOtnInterface710;
+        this.openRoadmInterface121 = new OpenRoadmInterface121(portMapping, openRoadmInterfaces);
+        this.openRoadmInterface221 = new OpenRoadmInterface221(portMapping, openRoadmInterfaces);
+        this.openRoadmInterface710 = new OpenRoadmInterface710(portMapping, openRoadmInterfaces);
+        this.openRoadmOtnInterface221 = new OpenRoadmOtnInterface221(portMapping, openRoadmInterfaces);
+        this.openRoadmOtnInterface710 = new OpenRoadmOtnInterface710(portMapping, openRoadmInterfaces);
     }
 
     public String createOpenRoadmEthInterface(String nodeId, String logicalConnPoint)
@@ -56,6 +57,7 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
             case StringConstants.OPENROADM_DEVICE_VERSION_7_1:
+                // Below method differenciates 100G vs 400G based on supported-if-cap type
                 return openRoadmInterface710.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
             default:
                 return null;
@@ -96,12 +98,8 @@ public class OpenRoadmInterfaceFactory {
                 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint,
                         spectrumInformation);
             case StringConstants.OPENROADM_DEVICE_VERSION_7_1:
-                // In the case of 710 device, we logically combine the OTSi and OTSiGroup interface and represent
-                // as OCh
-                String interfaceOtsiName = openRoadmInterface710.createOpenRoadmOtsiInterface(nodeId, logicalConnPoint,
+                return openRoadmInterface710.createOpenRoadmOchOtsiOtsigroupInterface(nodeId, logicalConnPoint,
                     spectrumInformation);
-                return openRoadmInterface710.createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint,
-                    interfaceOtsiName);
             default:
                 return null;
         }
@@ -130,6 +128,18 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmOdu4HOInterface(nodeId, logicalConnPoint, isCTP,
                     apiInfoA, apiInfoZ, payloadType);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1:
+                return openRoadmInterface710.createOpenRoadmOdu4OducnOduflex(nodeId, logicalConnPoint,
+                    apiInfoA, apiInfoZ);
+            default:
+                return null;
+        }
+    }
+
+    public String createOpenRoadmOducn(String nodeId, String logicalConnPoint)
+            throws OpenRoadmInterfaceException {
+
+        switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_7_1:
                 return openRoadmInterface710.createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
             default:
@@ -161,7 +171,7 @@ public class OpenRoadmInterfaceFactory {
                 return openRoadmInterface221.createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportOchInterface,
                     apiInfoA, apiInfoZ);
             case StringConstants.OPENROADM_DEVICE_VERSION_7_1:
-                return openRoadmInterface710.createOpenRoadmOtucnInterface(nodeId, logicalConnPoint,
+                return openRoadmInterface710.createOpenRoadmOtu4OtucnInterface(nodeId, logicalConnPoint,
                     supportOchInterface, apiInfoA, apiInfoZ);
             default:
                 return null;
@@ -291,7 +301,7 @@ public class OpenRoadmInterfaceFactory {
                 LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
                 return null;
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return openRoadmOtnInterface221.createOpenRoadmOdu2Interface(nodeId, logicalConnPoint, servicename,
+                return openRoadmOtnInterface221.createOpenRoadmOdu2Interface(nodeId, logicalConnPoint,  servicename,
                     isCTP, tribPortNumber, tribSlotIndex, apiInfoA, apiInfoZ, payLoadType);
             default:
                 return null;
@@ -315,9 +325,9 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
-    public String createOpenRoadmOtnOdu4LoInterface(String nodeId, String logicalConnPoint,
-        String serviceName, String payLoad, boolean isNetworkPort,
-        OpucnTribSlotDef minTribSlotNumber, OpucnTribSlotDef maxTribSlotNumber)
+    public String createOpenRoadmOtnOdu4LoInterface(String nodeId, String logicalConnPoint, String serviceName,
+            String payLoad, boolean isNetworkPort, OpucnTribSlotDef minTribSlotNumber,
+            OpucnTribSlotDef maxTribSlotNumber)
         throws OpenRoadmInterfaceException {
 
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
@@ -361,7 +371,7 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
-    public String createOpenRoadmOtnOduc4Interface(String anodeId, String alogicalConnPoint,
+    public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
             String asupportingOtuInterface, String znodeId, String zlogicalConnPoint)
             throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(anodeId)) {