Removing the maint-testsignal container
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterface710.java
index 3ce4156e5608c7abc105b757ebcb75858933a3b0..cc2860e8bd824026511145b4f001076c335ceff3 100644 (file)
@@ -20,6 +20,8 @@ import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.TrailTraceOther.TimDetectMode;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.parent.odu.allocation.ParentOduAllocationBuilder;
@@ -203,10 +205,10 @@ public class OpenRoadmInterface710 {
     }
 
     public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
-            String supportingOtsiGroupInterface)
+            String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
             throws OpenRoadmInterfaceException {
-        Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
-        if (portMap == null) {
+        Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
+        if (mapping == null) {
             throw new OpenRoadmInterfaceException(
                 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
                     nodeId, logicalConnPoint));
@@ -222,69 +224,21 @@ public class OpenRoadmInterface710 {
             .setDegmIntervals(Uint8.valueOf(2))
             .setDegthrPercentage(Uint16.valueOf(100))
             .setMaintLoopback(maintLoopbackBuilder.build());
-
-        InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOtu.class,
-            logicalConnPoint + "-OTUC4");
-
-        // Create a list
-        List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
-        listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
-
-        otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
-        org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
-            new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
-
-        otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
-
-        // Post interface on the device
-        openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
-
-        // Post the equipment-state change on the device circuit-pack if xpdr node
-        if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
-            this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
+        if (apiInfoA != null) {
+            otuBuilder.setTxSapi(apiInfoA.getSapi())
+                .setTxDapi(apiInfoA.getDapi())
+                .setExpectedSapi(apiInfoA.getExpectedSapi())
+                .setExpectedDapi(apiInfoA.getExpectedDapi());
         }
-
-        return otuInterfaceBuilder.getName();
-
-    }
-
-    // Adding method to have SAPI/DAPI information for the OTUCn
-    public String createOpenRoadmOtucnInterface(String anodeId, String alogicalConnPoint,
-            String supportingOtsiGroupInterface, String znodeId, String zlogicalConnPoint)
-            throws OpenRoadmInterfaceException {
-        Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
-        Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
-        if (portMapA == null) {
-            throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
-                    anodeId, alogicalConnPoint));
+        if (apiInfoZ != null) {
+            otuBuilder.setTxSapi(apiInfoZ.getSapi())
+                .setTxDapi(apiInfoZ.getDapi())
+                .setExpectedSapi(apiInfoZ.getExpectedSapi())
+                .setExpectedDapi(apiInfoZ.getExpectedDapi());
         }
-        // On the Zside
-        if (portMapZ == null) {
-            throw new OpenRoadmInterfaceException(
-                String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
-                    znodeId, zlogicalConnPoint));
 
-        }
-        // Create an OTUCn object
-        MaintLoopbackBuilder maintLoopbackBuilder = new MaintLoopbackBuilder();
-        maintLoopbackBuilder.setEnabled(false);
-        OtuBuilder otuBuilder = new OtuBuilder()
-            .setRate(OTUCn.class)
-            .setOtucnNRate(Uint16.valueOf(4))
-            .setTimActEnabled(false)
-            .setTimDetectMode(TimDetectMode.Disabled)
-            .setDegmIntervals(Uint8.valueOf(2))
-            .setDegthrPercentage(Uint16.valueOf(100))
-            .setMaintLoopback(maintLoopbackBuilder.build())
-            .setTxSapi(portMapA.getLcpHashVal())
-            .setTxDapi(portMapZ.getLcpHashVal())
-            // setting expected SAPI and DAPI values
-            .setExpectedDapi(portMapA.getLcpHashVal())
-            .setExpectedSapi(portMapZ.getLcpHashVal());
-
-        InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOtu.class,
-            alogicalConnPoint + "-OTUC4");
+        InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
+            logicalConnPoint + "-OTUC4");
 
         // Create a list
         List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
@@ -297,22 +251,19 @@ public class OpenRoadmInterface710 {
         otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
 
         // Post interface on the device
-        openRoadmInterfaces.postInterface(anodeId, otuInterfaceBuilder);
-
+        openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
         // Post the equipment-state change on the device circuit-pack if xpdr node
-        if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
-            this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
+        if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
+            this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
         }
-
+        this.portMapping.updateMapping(nodeId, mapping);
         return otuInterfaceBuilder.getName();
-
     }
 
-    public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint,
-            String supportingOtucn)
+    public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
             throws OpenRoadmInterfaceException {
-        Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
-        if (portMap == null) {
+        Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
+        if (mapping == null) {
             throw new OpenRoadmInterfaceException(
                 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
                     nodeId, logicalConnPoint));
@@ -323,11 +274,6 @@ public class OpenRoadmInterface710 {
         OpuBuilder opuBuilder = new OpuBuilder()
             .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
             .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
-        // Maint test signal
-        MaintTestsignalBuilder maintTestsignal = new MaintTestsignalBuilder()
-            // PRBS value should be PRBS31 if enabled is true
-            .setTestPattern(TestPattern.PRBS31)
-            .setEnabled(false);
 
         // Create an ODUC4 object
         OduBuilder oduBuilder = new OduBuilder()
@@ -339,15 +285,16 @@ public class OpenRoadmInterface710 {
             .setTimDetectMode(TimDetectMode.Disabled)
             .setDegmIntervals(Uint8.valueOf(2))
             .setDegthrPercentage(Uint16.valueOf(100))
-            .setOpu(opuBuilder.build())
-            .setMaintTestsignal(maintTestsignal.build());
+            .setOpu(opuBuilder.build());
 
-        InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
-            logicalConnPoint + ODUC4);
+        InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
+            logicalConnPoint + "-ODUC4");
 
         // Create a list
         List<String> listSupportingOtucnInterface = new ArrayList<>();
-        listSupportingOtucnInterface.add(supportingOtucn);
+        if (mapping.getSupportingOtuc4() != null) {
+            listSupportingOtucnInterface.add(mapping.getSupportingOtuc4());
+        }
 
         oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
@@ -359,8 +306,8 @@ public class OpenRoadmInterface710 {
         openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
 
         // Post the equipment-state change on the device circuit-pack if xpdr node
-        if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
-            this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
+        if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
+            this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
         }
 
         return oduInterfaceBuilder.getName();
@@ -390,11 +337,6 @@ public class OpenRoadmInterface710 {
         OpuBuilder opuBuilder = new OpuBuilder()
             .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
             .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
-        // Maint test signal
-        MaintTestsignalBuilder maintTestsignal = new MaintTestsignalBuilder()
-            // PRBS value should be PRBS31 if enabled is true
-            .setTestPattern(TestPattern.PRBS31)
-            .setEnabled(false);
 
         // Create an ODUC4 object
         OduBuilder oduBuilder = new OduBuilder()
@@ -410,8 +352,7 @@ public class OpenRoadmInterface710 {
             .setTxSapi(portMapA.getLcpHashVal())
             .setTxDapi(portMapZ.getLcpHashVal())
             .setExpectedSapi(portMapZ.getLcpHashVal())
-            .setExpectedDapi(portMapZ.getLcpHashVal())
-            .setMaintTestsignal(maintTestsignal.build());
+            .setExpectedDapi(portMapZ.getLcpHashVal());
 
         InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
             alogicalConnPoint + ODUC4);
@@ -452,11 +393,6 @@ public class OpenRoadmInterface710 {
         OpuBuilder opuBuilder = new OpuBuilder()
             .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
             .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
-        // Maint test signal
-        MaintTestsignalBuilder maintTestsignal = new MaintTestsignalBuilder()
-            // PRBS value should be PRBS31 if enabled is true
-            .setTestPattern(TestPattern.PRBS31)
-            .setEnabled(false);
 
         // Create an ODUC4 object
         OduBuilder oduBuilder = new OduBuilder()
@@ -468,8 +404,7 @@ public class OpenRoadmInterface710 {
             .setTimDetectMode(TimDetectMode.Disabled)
             .setDegmIntervals(Uint8.valueOf(2))
             .setDegthrPercentage(Uint16.valueOf(100))
-            .setOpu(opuBuilder.build())
-            .setMaintTestsignal(maintTestsignal.build());
+            .setOpu(opuBuilder.build());
 
         InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
             logicalConnPoint + ODUC4);
@@ -521,11 +456,6 @@ public class OpenRoadmInterface710 {
         OpuBuilder opuBuilder = new OpuBuilder()
             .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
             .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
-        // Maint test signal
-        MaintTestsignalBuilder maintTestsignal = new MaintTestsignalBuilder()
-            // PRBS value should be PRBS31 if enabled is true
-            .setTestPattern(TestPattern.PRBS31)
-            .setEnabled(false);
 
         // Create an ODUC4 object
         OduBuilder oduBuilder = new OduBuilder()
@@ -541,8 +471,7 @@ public class OpenRoadmInterface710 {
             .setTxSapi(portMapA.getLcpHashVal())
             .setTxDapi(portMapZ.getLcpHashVal())
             .setExpectedSapi(portMapZ.getLcpHashVal())
-            .setExpectedDapi(portMapZ.getLcpHashVal())
-            .setMaintTestsignal(maintTestsignal.build());
+            .setExpectedDapi(portMapZ.getLcpHashVal());
 
         InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
             alogicalConnPoint + ODUC4);
@@ -584,12 +513,6 @@ public class OpenRoadmInterface710 {
             .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
             .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
 
-        // Maint test signal
-        MaintTestsignalBuilder maintTestsignal = new MaintTestsignalBuilder()
-            // PRBS value should be PRBS31 if enabled is true
-            .setTestPattern(TestPattern.PRBS31)
-            .setEnabled(false);
-
         // Parent Odu-allocation
         // Set the trib-slot array
         List<OpucnTribSlotDef> tribslots = new ArrayList<>();
@@ -611,7 +534,6 @@ public class OpenRoadmInterface710 {
             .setDegmIntervals(Uint8.valueOf(2))
             .setDegthrPercentage(Uint16.valueOf(100))
             .setOpu(opuBuilder.build())
-            .setMaintTestsignal(maintTestsignal.build())
             .setParentOduAllocation(parentOduAllocationBuilder.build());
 
         InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,