Refactor Renderer OpenRoadmInterfaces step 2 16/102616/5
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 12 Oct 2022 12:02:03 +0000 (14:02 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Thu, 17 Nov 2022 19:32:40 +0000 (20:32 +0100)
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I32a7f978d9ca37e65c44fda24cd89d497047e3a0

common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfaceException.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface121.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface221.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/openroadminterface/OpenRoadmInterface710.java

index 13dd4d4e08c047841fa7c73b32dc19eb42e5a480..8de67147712041fe92bd0762e7e20964028cae58 100644 (file)
@@ -21,4 +21,9 @@ public class OpenRoadmInterfaceException extends Exception {
     public OpenRoadmInterfaceException(String message, Throwable cause) {
         super(message, cause);
     }
+
+    public static final String mapping_msg_err(String node, String port) {
+        return String.format(
+            "Unable to get mapping from PortMapping for node % and logical connection port %s", node, port);
+    }
 }
index 906bd2398c9f2e08148b7ee609a5015465303dab..f50697665d606606c05d4c1703a46cab3f48e1af 100644 (file)
@@ -60,8 +60,6 @@ import org.slf4j.LoggerFactory;
 
 
 public class OpenRoadmInterface121 {
-    private static final String MAPPING_MSG_ERROR =
-            "Unable to get mapping from PortMapping for node % and logical connection port %s";
     private final PortMapping portMapping;
     private final OpenRoadmInterfaces openRoadmInterfaces;
     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface121.class);
@@ -75,7 +73,8 @@ public class OpenRoadmInterface121 {
             throws OpenRoadmInterfaceException {
         Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
-            throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
+            throw new OpenRoadmInterfaceException(
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder ethInterfaceBldr =
             createGenericInterfaceBuilder(portMap, EthernetCsmacd.VALUE, logicalConnPoint + "-ETHERNET")
@@ -126,14 +125,14 @@ public class OpenRoadmInterface121 {
             throws OpenRoadmInterfaceException {
         Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
-            throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
+            throw new OpenRoadmInterfaceException(
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create generic interface
         InterfaceBuilder otuInterfaceBldr =
             createGenericInterfaceBuilder(portMap, OtnOtu.VALUE, logicalConnPoint + "-OTU")
                 .setSupportingInterface(supportOchInterface)
                 .addAugmentation(
-                // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1Builder()
                         .setOtu(
                             // OTU interface specific data
@@ -162,7 +161,8 @@ public class OpenRoadmInterface121 {
             throws OpenRoadmInterfaceException {
         Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
-            throw new OpenRoadmInterfaceException(String.format(MAPPING_MSG_ERROR, nodeId, logicalConnPoint));
+            throw new OpenRoadmInterfaceException(
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + "-ODU");
@@ -171,7 +171,6 @@ public class OpenRoadmInterface121 {
         }
         oduInterfaceBldr.addAugmentation(
             // Create Interface1 type object required for adding as augmentation
-            // TODO look at imports of different versions of class
             new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev161014.Interface1Builder()
                 .setOdu(
                     // ODU interface specific data
@@ -207,9 +206,8 @@ public class OpenRoadmInterface121 {
             throws OpenRoadmInterfaceException {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
-            throw new OpenRoadmInterfaceException(String.format(
-                "Unable to get mapping from PortMapping for node %s and logical connection port %s",
-                    nodeId, logicalConnPoint));
+            throw new OpenRoadmInterfaceException(
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create generic interface
         InterfaceBuilder ochInterfaceBldr =
@@ -222,7 +220,6 @@ public class OpenRoadmInterface121 {
         }
         ochInterfaceBldr.addAugmentation(
             // Create Interface1 type object required for adding as augmentation
-            // TODO look at imports of different versions of class
             new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.Interface1Builder()
                 .setOch(
                     // OCH interface specific data
@@ -237,9 +234,8 @@ public class OpenRoadmInterface121 {
             SpectrumInformation spectrumInformation) throws OpenRoadmInterfaceException {
         Mapping portMap = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
-            throw new OpenRoadmInterfaceException(String.format(
-                "Unable to get mapping from PortMapping for node %s and logical connection port %s",
-                    nodeId, logicalConnPoint));
+            throw new OpenRoadmInterfaceException(
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         ModulationFormat modulationFormat =
             OchAttributes.ModulationFormat.forName(spectrumInformation.getModulationFormat());
@@ -253,7 +249,6 @@ public class OpenRoadmInterface121 {
                     spectrumInformation.getIdentifierFromParams(logicalConnPoint))
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014
                             .Interface1Builder()
                         .setOch(
index 5d25362ae2abbc6b721e070cc7806a037d8f6b5a..5554bcaccea7163e9253829b0eb547c4ae0068b1 100644 (file)
@@ -62,6 +62,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev17121
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev171215.OTU4;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev171215.OduFunctionIdentity;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev171215.PayloadTypeDef;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.OduAttributes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.OduAttributes.MonitoringMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.odu.container.OduBuilder;
@@ -77,8 +78,6 @@ import org.slf4j.LoggerFactory;
 
 
 public class OpenRoadmInterface221 {
-    private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
-            "Unable to get mapping from PortMapping for node % and logical connection port %s";
     private final PortMapping portMapping;
     private final OpenRoadmInterfaces openRoadmInterfaces;
     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface221.class);
@@ -94,7 +93,7 @@ public class OpenRoadmInterface221 {
         Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Post interface on the device
         InterfaceBuilder ethInterfaceBldr =
@@ -121,7 +120,7 @@ public class OpenRoadmInterface221 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         List<String> interfacesCreated = new ArrayList<>();
         String mcInterfaceCreated = "";
@@ -139,9 +138,8 @@ public class OpenRoadmInterface221 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
-        // TODO : Check this method
         LOG.info("MC interface Freq Start {} and Freq End {} and center-Freq {}",
                 spectrumInformation.getMinFrequency(), spectrumInformation.getMaxFrequency(),
                 spectrumInformation.getCenterFrequency());
@@ -169,16 +167,13 @@ public class OpenRoadmInterface221 {
     public String createNMCInterface(String nodeId, String logicalConnPoint,
             SpectrumInformation spectrumInformation, String mcName)
             throws OpenRoadmInterfaceException {
-        //TODO improve logs messages
-        LOG.info("This is the central frequency {}", spectrumInformation.getCenterFrequency());
-        LOG.info("This is the nmc width {}", spectrumInformation.getWidth());
-        // TODO : Check this method
+        LOG.info("The central frequency is {} and the nmc width is {}",
+            spectrumInformation.getCenterFrequency(), spectrumInformation.getWidth());
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
-        //TODO : Check this method
         InterfaceBuilder nmcInterfaceBldr =
             createGenericInterfaceBuilder(
                 portMap, NetworkMediaChannelConnectionTerminationPoint.VALUE,
@@ -204,7 +199,6 @@ public class OpenRoadmInterface221 {
     public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint,
             SpectrumInformation spectrumInformation)
             throws OpenRoadmInterfaceException {
-        // TODO : Check this method
         ModulationFormat modulationFormat = ModulationFormat.forName(spectrumInformation.getModulationFormat());
         if (modulationFormat == null) {
             modulationFormat = ModulationFormat.DpQpsk;
@@ -212,8 +206,7 @@ public class OpenRoadmInterface221 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format("Unable to get mapping from PortMapping for node %s and logical connection port %s",
-                    nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create generic interface
         InterfaceBuilder ochInterfaceBldr =
@@ -223,7 +216,6 @@ public class OpenRoadmInterface221 {
                     spectrumInformation.getIdentifierFromParams(logicalConnPoint))
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev181019
                             .Interface1Builder()
                         .setOch(
@@ -250,7 +242,7 @@ public class OpenRoadmInterface221 {
         Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(mapping, OtnOdu.VALUE, logicalConnPoint + "-ODU4");
@@ -260,26 +252,35 @@ public class OpenRoadmInterface221 {
         if (mapping.getSupportingEthernet() != null) {
             oduInterfaceBldr.setSupportingInterface(mapping.getSupportingEthernet());
         }
-        // ODU interface specific data
-        OduFunctionIdentity oduFunction;
-        MonitoringMode monitoringMode;
-        Opu opu = null;
         if (isCTP) {
-            oduFunction = ODUCTP.VALUE;
-            monitoringMode = MonitoringMode.Monitored;
-        } else {
-            oduFunction =
-                // For TPDR it can be both CTP and TTP
-                // For switch-ponder we still use TTP
-                mapping.getXponderType() == XpdrNodeTypes.Tpdr
-                    ? ODUTTPCTP.VALUE
-                    : ODUTTP.VALUE;
-            monitoringMode = MonitoringMode.Terminated;
-            opu = new OpuBuilder()
-                .setPayloadType(PayloadTypeDef.getDefaultInstance(payloadType))
-                .setExpPayloadType(PayloadTypeDef.getDefaultInstance(payloadType))
-                .build();
+            // Create Interface1 type object required for adding as augmentation
+            oduInterfaceBldr.addAugmentation(
+                createOdu4HOInterface1(ODUCTP.VALUE, MonitoringMode.Monitored, null, apiInfoA, apiInfoZ));
+            // Post interface on the device
+            openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
+            return oduInterfaceBldr.getName();
         }
+        // Create Interface1 type object required for adding as augmentation
+        oduInterfaceBldr.addAugmentation(
+            createOdu4HOInterface1(
+                // For TPDR it can be both CTP and TTP - For switch-ponder we still use TTP
+                mapping.getXponderType() == XpdrNodeTypes.Tpdr ? ODUTTPCTP.VALUE : ODUTTP.VALUE,
+                MonitoringMode.Terminated,
+                new OpuBuilder()
+                    .setPayloadType(PayloadTypeDef.getDefaultInstance(payloadType))
+                    .setExpPayloadType(PayloadTypeDef.getDefaultInstance(payloadType))
+                    .build(),
+                apiInfoA, apiInfoZ));
+        // Post interface on the device
+        openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
+        LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
+        this.portMapping.updateMapping(nodeId, mapping);
+        return oduInterfaceBldr.getName();
+    }
+
+    private Interface1 createOdu4HOInterface1(
+            OduFunctionIdentity oduFunction, MonitoringMode monitoringMode, Opu opu,
+            AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) {
         OduBuilder oduIfBuilder = new OduBuilder()
                 .setRate(ODU4.VALUE)
                 .setOduFunction(oduFunction)
@@ -297,36 +298,25 @@ public class OpenRoadmInterface221 {
                 .setExpectedSapi(apiInfoZ.getExpectedSapi())
                 .setExpectedDapi(apiInfoZ.getExpectedDapi());
         }
-        // Create Interface1 type object required for adding as augmentation
-        // TODO look at imports of different versions of class
-        oduInterfaceBldr.addAugmentation(
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder()
-                .setOdu(oduIfBuilder.build())
-                .build());
-        // Post interface on the device
-        openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
-        //TODO isCTP is checked twice. There is room for refactoring here
-        // and also likely for an intermediate fonction to create oduIfBuilder
-        if (!isCTP) {
-            LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
-            this.portMapping.updateMapping(nodeId, mapping);
-        }
-        return oduInterfaceBldr.getName();
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder()
+                    .setOdu(oduIfBuilder.build())
+                    .build();
     }
 
+
+
     public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
             throws OpenRoadmInterfaceException {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + "-ODU")
                 .setSupportingInterface(supportingOtuInterface)
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder()
                         .setOdu(
                             // ODU interface specific data
@@ -352,18 +342,17 @@ public class OpenRoadmInterface221 {
         Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
         if (portMapA == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, anodeId, alogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint));
         }
         if (portMapZ == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, znodeId, zlogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint + "-ODU")
                 .setSupportingInterface(supportingOtuInterface)
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder()
                         .setOdu(
                             new OduBuilder()
@@ -393,7 +382,7 @@ public class OpenRoadmInterface221 {
         Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // OTU interface specific data
         OtuBuilder otuIfBuilder = new OtuBuilder()
@@ -416,7 +405,6 @@ public class OpenRoadmInterface221 {
                 .setSupportingInterface(supportOchInterface)
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev181019.Interface1Builder()
                         .setOtu(otuIfBuilder.build())
                         .build());
@@ -534,14 +522,13 @@ public class OpenRoadmInterface221 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                    String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + "-ODU4")
                 .setSupportingInterface(supportingOtuInterface)
                 .addAugmentation(
                 // Create Interface1 type object required for adding as augmentation
-                // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder()
                         .setOdu(
                         // ODU interface specific data
@@ -570,19 +557,18 @@ public class OpenRoadmInterface221 {
         Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
         if (portMapA == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, anodeId, alogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint));
         }
         Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
         if (portMapZ == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, znodeId, zlogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint + "-ODU4")
                 .setSupportingInterface(asupportingOtuInterface)
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019
                             .Interface1Builder()
                         .setOdu(
index c57b39166bf4fc4e0f0da9270135a81a8a8a4f5b..48794144570db7d85eaa33f69be0ad573d75f513 100644 (file)
@@ -86,8 +86,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OpenRoadmInterface710 {
-    private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
-        "Unable to get mapping from PortMapping for node % and logical connection port %s";
     private static final String MODULATION_FMT_EXCEPTION_MESSAGE =
         "Unable to get the modulation format";
     private static final String RATE_EXCEPTION_MESSAGE =
@@ -108,7 +106,7 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder ethInterfaceBldr =
             createGenericInterfaceBuilder(portMap, EthernetCsmacd.VALUE, logicalConnPoint + "-ETHERNET")
@@ -142,8 +140,7 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format("Unable to get mapping from PortMapping for node %s and logical connection port %s",
-                    nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create generic interface
         InterfaceBuilder ochInterfaceBldr =
@@ -152,7 +149,6 @@ public class OpenRoadmInterface710 {
                     spectrumInformation.getIdentifierFromParams(logicalConnPoint))
                 .addAugmentation(
                 // Create Interface1 type object required for adding as augmentation
-                // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529
                             .Interface1Builder()
                         .setOch(
@@ -179,7 +175,7 @@ public class OpenRoadmInterface710 {
             throws OpenRoadmInterfaceException {
         ModulationFormat modulationFormat = ModulationFormat.forName(spectrumInformation.getModulationFormat());
         if (modulationFormat == null) {
-            throw new OpenRoadmInterfaceException(String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(MODULATION_FMT_EXCEPTION_MESSAGE);
         }
         // OTSI interface specific data
         OtsiBuilder otsiBuilder = new OtsiBuilder()
@@ -241,12 +237,12 @@ public class OpenRoadmInterface710 {
                 break;
             default:
                 LOG.error("Rate {} is unsupported", serviceRate);
-                throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+                throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create generic interface
         InterfaceBuilder otsiInterfaceBldr =
@@ -276,12 +272,12 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Check the modulation format
         ModulationFormat modulationFormat = ModulationFormat.forName(spectrumInformation.getModulationFormat());
         if (modulationFormat == null) {
-            throw new OpenRoadmInterfaceException(String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(MODULATION_FMT_EXCEPTION_MESSAGE);
         }
         int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
         // Create an OTSI group object
@@ -301,7 +297,7 @@ public class OpenRoadmInterface710 {
                 break;
             default:
                 LOG.error("Rate {} is not supported", serviceRate);
-                throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+                throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         // Create generic interface
         InterfaceBuilder otsiGroupInterfaceBldr =
@@ -329,12 +325,13 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.VALUE)) {
             // create OCH interface
             return createOpenRoadmOchInterface(nodeId, logicalConnPoint, spectrumInformation);
-        } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
+        }
+        if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
             // Create OTSi and OTSi-group and concat the names of the interface
             String interfaceOtsiName = createOpenRoadmOtsiInterface(nodeId, logicalConnPoint, spectrumInformation);
             // And Concat the two names for this interface
@@ -349,7 +346,7 @@ public class OpenRoadmInterface710 {
         Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // OTU interface specific data
         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder
@@ -374,7 +371,6 @@ public class OpenRoadmInterface710 {
                 .setSupportingInterfaceList(new HashSet<>(Set.of(supportOchInterface)))
                 .addAugmentation(
                     // Create Interface1 type object required for adding as augmentation
-                    // TODO look at imports of different versions of class
                     new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder()
                         .setOtu(otuIfBuilder.build())
                         .build());
@@ -391,8 +387,7 @@ public class OpenRoadmInterface710 {
         Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
-                    nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Create an OTUCn object
         OtuBuilder otuBuilder = new OtuBuilder()
@@ -435,7 +430,7 @@ public class OpenRoadmInterface710 {
                 break;
             default:
                 LOG.error("Rate {} is not supported", rate);
-                throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+                throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         InterfaceBuilder otuInterfaceBuilder =
             createGenericInterfaceBuilder(mapping, OtnOtu.VALUE, logicalConnPoint + "-OTUC" + otucnrate)
@@ -460,14 +455,15 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Depending on OCH-OTU4-ODU4 interface or OTSi-OTSi-group, supporting interface should
         // reflect that
         if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.VALUE)) {
             // create OTU4 interface
             return createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportingInterface, apiInfoA, apiInfoZ);
-        } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
+        }
+        if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
             // Create OTUCn
             return createOpenRoadmOtucnInterface(nodeId, logicalConnPoint, supportingInterface, apiInfoA, apiInfoZ);
         }
@@ -479,7 +475,7 @@ public class OpenRoadmInterface710 {
         Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBldr =
             createGenericInterfaceBuilder(mapping, OtnOdu.VALUE, logicalConnPoint + "-ODU4");
@@ -528,18 +524,17 @@ public class OpenRoadmInterface710 {
         Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
         if (mapping == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         if (mapping.getSupportingOtucn() == null) {
-            throw new OpenRoadmInterfaceException(
-                String.format("Missing supporting OTUCn interface on port-mapping"));
+            throw new OpenRoadmInterfaceException("Missing supporting OTUCn interface on port-mapping");
         }
         String supportingOtucn = mapping.getSupportingOtucn();
         // Set the ODUCn rate from OTUCn interface naming convention
         String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
         // check if the oducnrate is a valid value and if it is invalid, then throw error
         if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
-            throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         InterfaceBuilder oduInterfaceBuilder =
             createGenericInterfaceBuilder(mapping, OtnOdu.VALUE, logicalConnPoint + "-ODUC" + oducnrate)
@@ -583,18 +578,18 @@ public class OpenRoadmInterface710 {
         String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
         // check if the oducnrate is a valid value and if it is invalid, then throw error
         if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
-            throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
         if (portMapA == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, anodeId, alogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint));
         }
         // On the Zside
         Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
         if (portMapZ == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, znodeId, zlogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint));
         }
         InterfaceBuilder oduInterfaceBuilder =
             createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint + ODUC + oducnrate)
@@ -640,7 +635,7 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Parent Odu-allocation
         // Set the trib-slot array
@@ -665,27 +660,31 @@ public class OpenRoadmInterface710 {
                     .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build())
                     .build());
         // Build the OPU container to the ODU builder
-        if (rate.equals("1")) {
-            oduBuilder
-                .setRate(ODU4.VALUE)
-                .setOpu(
-                    new OpuBuilder()
-                        .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
-                        .setPayloadType(PayloadTypeDef.getDefaultInstance("07"))
-                        .build());
-            logicalConnPoint += "-ODU4";
-        } else if (rate.equals("4")) {
-            oduBuilder
-                .setRate(ODUflexCbr.VALUE)
-                .setOduflexCbrService(ODUflexCbr400G.VALUE)
-                .setOpu(
-                    new OpuBuilder()
-                        .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
-                        .setPayloadType(PayloadTypeDef.getDefaultInstance("32"))
-                        .build());
-            logicalConnPoint += "-ODUFLEX";
-        } else {
-            oduBuilder.setOpu(new OpuBuilder().build());
+        switch (rate) {
+            case "1":
+                oduBuilder
+                    .setRate(ODU4.VALUE)
+                    .setOpu(
+                        new OpuBuilder()
+                            .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
+                            .setPayloadType(PayloadTypeDef.getDefaultInstance("07"))
+                            .build());
+                logicalConnPoint += "-ODU4";
+                break;
+            case "4":
+                oduBuilder
+                    .setRate(ODUflexCbr.VALUE)
+                    .setOduflexCbrService(ODUflexCbr400G.VALUE)
+                    .setOpu(
+                        new OpuBuilder()
+                            .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
+                            .setPayloadType(PayloadTypeDef.getDefaultInstance("32"))
+                            .build());
+                logicalConnPoint += "-ODUFLEX";
+                break;
+            default:
+                oduBuilder.setOpu(new OpuBuilder().build());
+                break;
         }
         InterfaceBuilder oduflexInterfaceBuilder =
             createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint)
@@ -711,13 +710,13 @@ public class OpenRoadmInterface710 {
         Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
         if (portMapA == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, anodeId, alogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint));
         }
         // On the Zside
         Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
         if (portMapZ == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, znodeId, zlogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint));
         }
         // Parent Odu-allocation
         // Set the trib-slot array
@@ -744,27 +743,31 @@ public class OpenRoadmInterface710 {
                     .setTribPortNumber(Uint16.valueOf(1))
                     .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build())
                     .build());
-        if (rate.equals("1")) {
-            oduBuilder
-                .setRate(ODU4.VALUE)
-                .setOpu(
-                    new OpuBuilder()
-                        .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
-                        .setPayloadType(PayloadTypeDef.getDefaultInstance("07"))
-                        .build());
-            alogicalConnPoint += "-ODU4";
-        } else if (rate.equals("4")) {
-            oduBuilder
-                .setRate(ODUflexCbr.VALUE)
-                .setOduflexCbrService(ODUflexCbr400G.VALUE)
-                .setOpu(
-                    new OpuBuilder()
-                        .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
-                        .setPayloadType(PayloadTypeDef.getDefaultInstance("32"))
-                        .build());
-            alogicalConnPoint += "-ODUFLEX";
-        } else {
-            oduBuilder.setOpu(new OpuBuilder().build());
+        switch (rate) {
+            case "1":
+                oduBuilder
+                    .setRate(ODU4.VALUE)
+                    .setOpu(
+                        new OpuBuilder()
+                            .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
+                            .setPayloadType(PayloadTypeDef.getDefaultInstance("07"))
+                            .build());
+                alogicalConnPoint += "-ODU4";
+                break;
+            case "4":
+                oduBuilder
+                    .setRate(ODUflexCbr.VALUE)
+                    .setOduflexCbrService(ODUflexCbr400G.VALUE)
+                    .setOpu(
+                        new OpuBuilder()
+                            .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
+                            .setPayloadType(PayloadTypeDef.getDefaultInstance("32"))
+                            .build());
+                alogicalConnPoint += "-ODUFLEX";
+                break;
+            default:
+                oduBuilder.setOpu(new OpuBuilder().build());
+                break;
         }
         InterfaceBuilder oduflexInterfaceBuilder =
             createGenericInterfaceBuilder(portMapA, OtnOdu.VALUE, alogicalConnPoint)
@@ -785,7 +788,7 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Depending on OTU4 or OTUCn, supporting interface should
         // reflect that
@@ -794,7 +797,8 @@ public class OpenRoadmInterface710 {
         if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.VALUE)) {
             // create OTU4 interface
             return createOpenRoadmOdu4Interface(nodeId, logicalConnPoint, apiInfoA, apiInfoZ);
-        } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
+        }
+        if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.VALUE)) {
             // Create ODUCn and ODUFlex interface.
             String interfaceOducn = createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
             return interfaceOducn + "#"
@@ -809,13 +813,13 @@ public class OpenRoadmInterface710 {
         Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
         if (portMap == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(nodeId, logicalConnPoint));
         }
         // Set the ODUCn rate from OTUCn interface naming convention
         String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
         // check if the oducnrate is a valid value and if it is invalid, then throw error
         if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
-            throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
         InterfaceBuilder oduInterfaceBuilder =
             createGenericInterfaceBuilder(portMap, OtnOdu.VALUE, logicalConnPoint + ODUC + oducnrate)
@@ -860,19 +864,19 @@ public class OpenRoadmInterface710 {
         Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
         if (portMapA == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, anodeId, alogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(anodeId, alogicalConnPoint));
         }
         // On the Zside
         Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
         if (portMapZ == null) {
             throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, znodeId, zlogicalConnPoint));
+                OpenRoadmInterfaceException.mapping_msg_err(znodeId, zlogicalConnPoint));
         }
         // Set the ODUCn rate from OTUCn interface naming convention
         String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
         // check if the oducnrate is a valid value and if it is invalid, then throw error
         if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
-            throw new OpenRoadmInterfaceException(String.format(RATE_EXCEPTION_MESSAGE));
+            throw new OpenRoadmInterfaceException(RATE_EXCEPTION_MESSAGE);
         }
 
         InterfaceBuilder oduInterfaceBuilder =
@@ -940,21 +944,19 @@ public class OpenRoadmInterface710 {
                 double spectralWidth = (spectrumInformation.getHigherSpectralSlotNumber()
                     - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY;
                 LOG.info("The width with guard band {}", spectralWidth);
-                Map<ModulationFormat, Integer> rateMap;
                 if (spectralWidth == 50.0) {
-                    rateMap = Map.of(
+                    LOG.info("The baud-rate is 31.6 GBaud");
+                    return Map.of(
                             ModulationFormat.DpQpsk , 100,
-                            ModulationFormat.DpQam16 , 200);
+                            ModulationFormat.DpQam16 , 200)
+                        .get(modulationFormat);
                     // Based on roll-of-factor of 0.2, 50 - 12.5 = 37.5GHz translates to 31.6 GBaud
-                    LOG.info("The baud-rate is 31.6 GBaud");
-                    return rateMap.get(modulationFormat);
-                } else {
-                    rateMap = Map.of(
-                            ModulationFormat.DpQpsk , 200,
-                            ModulationFormat.DpQam16 , 400);
-                    // Based on roll-of-factor of 0.2, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
-                    LOG.info("The baud-rate is 63.1 GBaud");
                 }
+                LOG.info("The baud-rate is 63.1 GBaud");
+                Map<ModulationFormat, Integer> rateMap = Map.of(
+                        ModulationFormat.DpQpsk , 200,
+                        ModulationFormat.DpQam16 , 400);
+                // Based on roll-of-factor of 0.2, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
                 int rate = rateMap.get(modulationFormat);
                 LOG.info("Given modulation format {} rate is {}", modulationFormat, rate);
                 return rate;