Update portmapping YANG model
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
index 50319bbad50a2de7882fdc68317234d0ddc13243..c21ee1fa1548c8b732530b8d0d164c7252f61f97 100644 (file)
@@ -11,10 +11,11 @@ package org.opendaylight.transportpce.renderer.openroadminterface;
 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.rev200429.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;
 
@@ -26,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;
     }
 
@@ -44,45 +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;
         }
     }
 
-
-    /**
-     * 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.
-     * @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)
+    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);
+                return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint, spectrumInformation);
             default:
                 return null;
         }
     }
 
 
-    public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
-        OchAttributes.ModulationFormat format)
-            throws OpenRoadmInterfaceException {
+    /**
+     * This methods creates an OCH interface on the given termination point on Roadm.
+     *
+     * @param nodeId           node ID
+     * @param logicalConnPoint logical connection point
+     * @param spectrumInformation spectrum information.
+     * @return Name of the interface if successful, otherwise return null.
+     * @throws OpenRoadmInterfaceException OpenRoadm interface exception
+     */
+    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;
         }
@@ -107,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;
         }
@@ -125,8 +143,8 @@ public class OpenRoadmInterfaceFactory {
      */
 
     public String createOpenRoadmOdu4Interface(String anodeId, String alogicalConnPoint, String asupportingOtuInterface,
-        String znodeId, String zlogicalConnPoint)
-        throws OpenRoadmInterfaceException {
+            String znodeId, String zlogicalConnPoint)
+            throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(anodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
                 return openRoadmInterface121.createOpenRoadmOdu4Interface(anodeId, alogicalConnPoint,
@@ -134,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;
         }
@@ -158,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;
         }
@@ -186,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 {
@@ -230,7 +260,7 @@ public class OpenRoadmInterfaceFactory {
     }
 
     public boolean isUsedByOtnXc(String nodeId, String interfaceName, String xc,
-        DeviceTransactionManager deviceTransactionManager) {
+            DeviceTransactionManager deviceTransactionManager) {
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
                 LOG.error(OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG);
@@ -327,8 +357,8 @@ public class OpenRoadmInterfaceFactory {
     }
 
     public String createOpenRoadmOtnOdu4Interface(String anodeId, String alogicalConnPoint,
-        String asupportingOtuInterface, String znodeId, String zlogicalConnPoint)
-        throws OpenRoadmInterfaceException {
+            String asupportingOtuInterface, String znodeId, String zlogicalConnPoint)
+            throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(anodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221