Update portmapping YANG model
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
index 6a69d90eab3c701d7913e5f7eb51e5d61e4f0aef..c21ee1fa1548c8b732530b8d0d164c7252f61f97 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.transportpce.renderer.openroadminterface;
 
-import java.math.BigDecimal;
 import java.util.List;
 import org.opendaylight.transportpce.common.StringConstants;
 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.openroadminterfaces.OpenRoadmInterfaceException;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.Mapping;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,13 +27,16 @@ public class OpenRoadmInterfaceFactory {
     private final MappingUtils mappingUtils;
     private final OpenRoadmInterface121 openRoadmInterface121;
     private final OpenRoadmInterface221 openRoadmInterface221;
+    private final OpenRoadmInterface710 openRoadmInterface710;
     private final OpenRoadmOtnInterface221 openRoadmOtnInterface;
 
     public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, OpenRoadmInterface121 openRoadmInterface121,
-            OpenRoadmInterface221 openRoadmInterface221, OpenRoadmOtnInterface221 openRoadmOTNInterface) {
+            OpenRoadmInterface221 openRoadmInterface221, OpenRoadmInterface710 openRoadmInterface710,
+            OpenRoadmOtnInterface221 openRoadmOTNInterface) {
         this.mappingUtils = mappingUtils;
         this.openRoadmInterface121 = openRoadmInterface121;
         this.openRoadmInterface221 = openRoadmInterface221;
+        this.openRoadmInterface710 = openRoadmInterface710;
         this.openRoadmOtnInterface = openRoadmOTNInterface;
     }
 
@@ -45,69 +48,53 @@ public class OpenRoadmInterfaceFactory {
                 return openRoadmInterface121.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                return openRoadmInterface710.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
             default:
                 return null;
         }
     }
 
-    public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
-            BigDecimal centerFreq, BigDecimal width)
+    public List<String> createOpenRoadmOchInterfaces(String nodeId, String logicalConnPoint,
+            SpectrumInformation spectrumInformation)
             throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber);
+                return openRoadmInterface121.createOpenRoadmOchInterfaces(nodeId, logicalConnPoint,
+                        spectrumInformation);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber,
-                    centerFreq, width);
+                return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint, spectrumInformation);
             default:
                 return null;
         }
     }
 
+
     /**
-     * This methods creates an OCH interface on the given termination point on
-     * Roadm.
+     * This methods creates an OCH interface on the given termination point on Roadm.
      *
      * @param nodeId           node ID
      * @param logicalConnPoint logical connection point
-     * @param waveNumber       wavelength number of the OCH interface.
+     * @param spectrumInformation spectrum information.
      * @return Name of the interface if successful, otherwise return null.
      * @throws OpenRoadmInterfaceException OpenRoadm interface exception
      */
-    public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
-            throws OpenRoadmInterfaceException {
-        switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
-            case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber);
-            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber);
-            default:
-                return null;
-        }
-    }
-
-    public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
-            OchAttributes.ModulationFormat format, BigDecimal centerFreq, BigDecimal width)
-            throws OpenRoadmInterfaceException {
-        switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
-            case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber, format);
-            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return openRoadmInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
-                   centerFreq, width);
-            default:
-                return null;
-        }
-    }
-
-    public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
-            OchAttributes.ModulationFormat format)
-            throws OpenRoadmInterfaceException {
+    public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint,
+            SpectrumInformation spectrumInformation) throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber, format);
+                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,
+                        spectrumInformation);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
-                return openRoadmInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber);
+                return openRoadmInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint,
+                        spectrumInformation);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                // In the case of 710 device, we logically combine the OTSi and OTSiGroup interface and represent
+                // as OCh
+                String interfaceOtsiName = openRoadmInterface710.createOpenRoadmOtsiInterface(nodeId, logicalConnPoint,
+                    spectrumInformation);
+                return openRoadmInterface710.createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint,
+                    interfaceOtsiName);
             default:
                 return null;
         }
@@ -132,6 +119,12 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
                         supportingOtuInterface);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                // Here ODUCn and ODUflex are combined
+                String interfaceNameOduc4 = openRoadmInterface710.createOpenRoadmOducnInterface(nodeId,
+                    logicalConnPoint, supportingOtuInterface);
+                return openRoadmInterface710.createOpenRoadmOduflexInterface(nodeId, logicalConnPoint,
+                    interfaceNameOduc4);
             default:
                 return null;
         }
@@ -159,6 +152,12 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmOdu4Interface(anodeId, alogicalConnPoint,
                     asupportingOtuInterface, znodeId, zlogicalConnPoint);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                // Here ODUCn and ODUflex are combined
+                String interfaceNameOduc4 = openRoadmInterface710.createOpenRoadmOducnInterface(anodeId,
+                    alogicalConnPoint, asupportingOtuInterface, znodeId, zlogicalConnPoint);
+                return openRoadmInterface710.createOpenRoadmOduflexInterface(anodeId, alogicalConnPoint,
+                    interfaceNameOduc4, znodeId, zlogicalConnPoint);
             default:
                 return null;
         }
@@ -183,6 +182,9 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221
                         .createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportOchInterface);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                return openRoadmInterface710.createOpenRoadmOtucnInterface(nodeId, logicalConnPoint,
+                    supportOchInterface);
             default:
                 return null;
         }
@@ -211,13 +213,16 @@ public class OpenRoadmInterfaceFactory {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmOtu4Interface(anodeId, alogicalConnPoint,
                         asupportOchInterface, znodeId, zlogicalConnPoint);
+            case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+                return openRoadmInterface710.createOpenRoadmOtucnInterface(anodeId, alogicalConnPoint,
+                    asupportOchInterface, znodeId, zlogicalConnPoint);
             default:
                 return null;
         }
     }
 
-    public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
-        return logicalConnectionPoint + "-" + waveNumber;
+    public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, String spectralSlotNumber) {
+        return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR,logicalConnectionPoint, spectralSlotNumber);
     }
 
     public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {