Upgrade portmapping YANG to enable flex-grid
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
index 4f43adc3941e547237d422942cbb813cb018d3bb..85ee24a820d592f7298b03538066906ecb07d5d1 100644 (file)
@@ -9,12 +9,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.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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -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;
     }
@@ -271,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;
+        }
+    }
 }