Upgrade portmapping YANG to enable flex-grid
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
index 8412b5c32372f7ef2ce9cd220d05e969c3853279..85ee24a820d592f7298b03538066906ecb07d5d1 100644 (file)
@@ -9,19 +9,19 @@
 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.mapping.MappingUtils;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.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.openroadm.optical.channel.interfaces.rev161014.RateIdentity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OpenRoadmInterfaceFactory {
 
+    private static final String OTN_FUNTIONS_ARE_NOT_SUPPORTED_BY_OPENROADM_MODELS_1_2_1_MSG =
+            "OTN funtions are not supported by Openroadm models 1.2.1";
     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfaceFactory.class);
     private final MappingUtils mappingUtils;
     private final OpenRoadmInterface121 openRoadmInterface121;
@@ -76,12 +76,11 @@ public class OpenRoadmInterfaceFactory {
 
 
     public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
-            Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format)
+        OchAttributes.ModulationFormat format)
             throws OpenRoadmInterfaceException {
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
-                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
-                        rate, format);
+                return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber, format);
             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
                 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber);
             default:
@@ -113,6 +112,33 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
+    /**
+     * This methods creates an ODU interface on the given termination point.
+     *
+     * @param anodeId                 node ID for A side
+     * @param alogicalConnPoint       logical connection point for A side
+     * @param asupportingOtuInterface supporting OTU interface
+     * @param znodeId                 node ID for Z side
+     * @param zlogicalConnPoint       logical connection point for Z side
+     * @return Name of the interface if successful, otherwise return null.
+     * @throws OpenRoadmInterfaceException OpenRoadm interface exception
+     */
+
+    public String createOpenRoadmOdu4Interface(String anodeId, String alogicalConnPoint, String asupportingOtuInterface,
+        String znodeId, String zlogicalConnPoint)
+        throws OpenRoadmInterfaceException {
+        switch (mappingUtils.getOpenRoadmVersion(anodeId)) {
+            case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
+                return openRoadmInterface121.createOpenRoadmOdu4Interface(anodeId, alogicalConnPoint,
+                    asupportingOtuInterface);
+            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+                return openRoadmInterface221.createOpenRoadmOdu4Interface(anodeId, alogicalConnPoint,
+                    asupportingOtuInterface, znodeId, zlogicalConnPoint);
+            default:
+                return null;
+        }
+    }
+
     /**
      * This methods creates an OTU interface on the given termination point.
      *
@@ -137,6 +163,34 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
+    /**
+     * This methods creates an OTU interface on the given termination point.
+     *
+     * @param anodeId node ID for A side
+     * @param alogicalConnPoint logical connection point for A side
+     * @param asupportOchInterface supporting OCH interface
+     * @param znodeId node ID for the Z side
+     * @param zlogicalConnPoint logical connection point for Z side
+     * @return Name of the interface if successful, otherwise return null.
+     *
+     * @throws OpenRoadmInterfaceException OpenRoadm interface exception
+     */
+
+    public String createOpenRoadmOtu4Interface(String anodeId, String alogicalConnPoint, String asupportOchInterface,
+            String znodeId, String zlogicalConnPoint)
+            throws OpenRoadmInterfaceException {
+        switch (mappingUtils.getOpenRoadmVersion(anodeId)) {
+            case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
+                return openRoadmInterface121.createOpenRoadmOtu4Interface(anodeId,
+                        alogicalConnPoint, asupportOchInterface);
+            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+                return openRoadmInterface221.createOpenRoadmOtu4Interface(anodeId, alogicalConnPoint,
+                        asupportOchInterface, znodeId, zlogicalConnPoint);
+            default:
+                return null;
+        }
+    }
+
     public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
         return logicalConnectionPoint + "-" + waveNumber;
     }
@@ -163,7 +217,7 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
-    public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
+    public boolean isUsedByXc(String nodeId, String interfaceName, String xc,
                               DeviceTransactionManager deviceTransactionManager) {
         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
@@ -175,11 +229,24 @@ public class OpenRoadmInterfaceFactory {
         }
     }
 
+    public boolean isUsedByOtnXc(String nodeId, String interfaceName, String xc,
+        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);
+                return false;
+            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+                return openRoadmInterface221.isUsedByOtnXc(nodeId, interfaceName, xc, deviceTransactionManager);
+            default:
+                return false;
+        }
+    }
+
     public String createOpenRoadmEth1GInterface(String nodeId,
                                                 String logicalConnPoint) throws OpenRoadmInterfaceException {
         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");
+                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 openRoadmOtnInterface.createOpenRoadmEth1GInterface(nodeId, logicalConnPoint);
@@ -192,7 +259,7 @@ public class OpenRoadmInterfaceFactory {
                                                  String logicalConnPoint) throws OpenRoadmInterfaceException {
         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");
+                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 openRoadmOtnInterface.createOpenRoadmEth10GInterface(nodeId, logicalConnPoint);
@@ -207,7 +274,7 @@ public class OpenRoadmInterfaceFactory {
             throws OpenRoadmInterfaceException {
         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");
+                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 openRoadmOtnInterface.createOpenRoadmOdu0Interface(
@@ -222,7 +289,7 @@ public class OpenRoadmInterfaceFactory {
             throws OpenRoadmInterfaceException {
         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");
+                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 openRoadmOtnInterface.createOpenRoadmOdu2Interface(
@@ -237,7 +304,7 @@ public class OpenRoadmInterfaceFactory {
             throws OpenRoadmInterfaceException {
         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");
+                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 openRoadmOtnInterface.createOpenRoadmOdu2eInterface(
@@ -258,4 +325,17 @@ public class OpenRoadmInterfaceFactory {
                 return null;
         }
     }
+
+    public String createOpenRoadmOtnOdu4Interface(String anodeId, String alogicalConnPoint,
+        String asupportingOtuInterface, String znodeId, String zlogicalConnPoint)
+        throws OpenRoadmInterfaceException {
+        switch (mappingUtils.getOpenRoadmVersion(anodeId)) {
+            case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+                return openRoadmInterface221
+                    .createOpenRoadmOtnOdu4Interface(anodeId, alogicalConnPoint, asupportingOtuInterface,
+                        znodeId, zlogicalConnPoint);
+            default:
+                return null;
+        }
+    }
 }