Update 7.1 port-mapping data after inf delete 11/99611/1
authorBalagangadhar Bathula <bb4341@att.com>
Mon, 7 Feb 2022 16:26:07 +0000 (11:26 -0500)
committerGilles Thouenon <gilles.thouenon@orange.com>
Thu, 10 Feb 2022 14:24:21 +0000 (14:24 +0000)
- When the service/interface is deleted, the 7.1
  port-mapping data is not updated and still shows the
  supporting ODUCn/OTUCn interfaces.
- Add code to update data for the supporting
  interfaces, after deletion.

JIRA: TRNSPRTPCE-608
Change-Id: Ie0af185285f645c2d52d88699ba538bdf207a66b
Signed-off-by: Balagangadhar Bathula <bb4341@att.com>
(cherry picked from commit a2c0845af51f68102d9f32df83cdfa93fbf9bb35)

common/src/main/java/org/opendaylight/transportpce/common/openroadminterfaces/OpenRoadmInterfacesImpl710.java
common/src/main/resources/OSGI-INF/blueprint/common-blueprint.xml
lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java
olm/src/test/java/org/opendaylight/transportpce/olm/OlmPowerServiceRpcImplTest.java
olm/src/test/java/org/opendaylight/transportpce/olm/power/PowerMgmtPowerMockTest.java
olm/src/test/java/org/opendaylight/transportpce/olm/power/PowerMgmtTest.java
olm/src/test/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImplTest.java

index 35fd0963fc5177efb2607334ea205a3954d43a3e..4152b2e38d7549abbee43b7d8d958277e5444740 100644 (file)
@@ -19,6 +19,9 @@ import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransaction;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.common.mapping.PortMappingVersion710;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.Ports;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.PortsKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks;
@@ -41,9 +44,14 @@ public class OpenRoadmInterfacesImpl710 {
     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterfacesImpl710.class);
 
     private final DeviceTransactionManager deviceTransactionManager;
+    private final PortMapping portMapping;
+    private final PortMappingVersion710 portMapping710;
 
-    public OpenRoadmInterfacesImpl710(DeviceTransactionManager deviceTransactionManager) {
+    public OpenRoadmInterfacesImpl710(DeviceTransactionManager deviceTransactionManager,
+            PortMapping portMapping, PortMappingVersion710 portMapping710) {
         this.deviceTransactionManager = deviceTransactionManager;
+        this.portMapping = portMapping;
+        this.portMapping710 = portMapping710;
     }
 
     public void postInterface(String nodeId, InterfaceBuilder ifBuilder) throws OpenRoadmInterfaceException {
@@ -174,6 +182,11 @@ public class OpenRoadmInterfacesImpl710 {
             if (intf2Delete.getName().contains(StringConstants.CLIENT_TOKEN) || intf2Delete.getName().contains(
                 StringConstants.NETWORK_TOKEN)) {
                 postEquipmentState(nodeId, intf2Delete.getSupportingCircuitPackName(), false);
+                // Here we update the port-mapping data after the interface delete
+                Mapping oldMapping = this.portMapping.getMapping(
+                    nodeId, intf2Delete.getSupportingCircuitPackName(), intf2Delete.getSupportingPort());
+                this.portMapping.deleteMapping(nodeId, oldMapping.getLogicalConnectionPoint());
+                this.portMapping710.updateMapping(nodeId, oldMapping);
             }
 
         } else {
index ac7e7b76398d025ddc02527b06afc92e85f28033..8add362595501c9c5c71920e408182c8769fdcb5 100644 (file)
@@ -36,6 +36,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
     <bean id="openRoadmInterfaces710" class="org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl710" >
         <argument ref="deviceTransactionManager" />
+        <argument ref="portMapping" />
+        <argument ref="portMapping710" />
     </bean>
 
     <bean id="openRoadmInterfaces" class="org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl" >
index 7a8da833bf3117d0fc0355cd70958d30104c6f63..4bee0e15b17e11a7dcf2ad8544365e871871ef19 100644 (file)
@@ -342,7 +342,7 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
         OpenRoadmInterfacesImpl221 openRoadmInterfacesImpl221 = new OpenRoadmInterfacesImpl221(
                 deviceTransactionManager, portMapping, portMapping.getPortMappingVersion221());
         OpenRoadmInterfacesImpl710 openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(
-            deviceTransactionManager);
+                deviceTransactionManager, portMapping, portMapping.getPortMappingVersion710());
         return new OpenRoadmInterfacesImpl(deviceTransactionManager, mappingUtils, openRoadmInterfacesImpl121,
                 openRoadmInterfacesImpl221, openRoadmInterfacesImpl710);
     }
index 1f7bd98fb36f37553600bdfceecd1953dad31882..6fb3cb865abf68ba65b7dd270e807be39c9326ba 100644 (file)
@@ -123,7 +123,8 @@ public class OlmPowerServiceRpcImplTest extends AbstractTest {
         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping,
             this.portMappingVersion22);
-        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager);
+        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping,
+            this.portMappingVersion710);
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
             this.openRoadmInterfacesImpl710);
index 46997f4cfcede939be73ab6845cf882991268d0a..bbce9663bce7f8bbef43d00e3418b42f9c448012 100644 (file)
@@ -115,7 +115,8 @@ public class PowerMgmtPowerMockTest extends AbstractTest {
         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping,
             this.portMappingVersion22);
-        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager);
+        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping,
+            this.portMappingVersion710);
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
             this.openRoadmInterfacesImpl710);
index c020b545c0af96d07b4dd28f606d7e577e45f34c..67519f78c7f9ab2908f42247fa21bcb2aaf98f6f 100644 (file)
@@ -86,7 +86,8 @@ public class PowerMgmtTest extends AbstractTest {
         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping,
             this.portMappingVersion22);
-        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager);
+        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping,
+            this.portMappingVersion710);
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
             this.openRoadmInterfacesImpl710);
index fa739e040e1b892c0ac5be3a36e5d3e8b3b61fdc..0bca3731f31c6912adf1cc134ffc3a2260741bad 100644 (file)
@@ -123,7 +123,8 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
         this.openRoadmInterfacesImpl121 = new OpenRoadmInterfacesImpl121(deviceTransactionManager);
         this.openRoadmInterfacesImpl22 = new OpenRoadmInterfacesImpl221(deviceTransactionManager, this.portMapping,
             this.portMappingVersion22);
-        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager);
+        this.openRoadmInterfacesImpl710 = new OpenRoadmInterfacesImpl710(deviceTransactionManager, this.portMapping,
+            this.portMappingVersion710);
         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager),
                 this.mappingUtils,this.openRoadmInterfacesImpl121,this.openRoadmInterfacesImpl22,
             this.openRoadmInterfacesImpl710);