Bug in interface delete 400G-Ethernet
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / DeviceRendererServiceImpl.java
index 4bef899ecf3a3515ed341c7595bf7c2c16646b32..6a6480e79e8d28dfc3cb625060f93242c6b4f74f 100644 (file)
@@ -256,7 +256,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         forkJoinPool.shutdown();
 
         if (success.get()) {
-            results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
+            results.add("Interfaces created successfully for nodes: " + String.join(", ", nodesProvisioned));
         }
         // setting topology in the service list data store
         try {
@@ -290,7 +290,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     @Override
     public ServicePathOutput deleteServicePath(ServicePathInput input) {
         if (!alarmSuppressionNodeRegistration(input)) {
-            LOG.warn("Alarm suppresion node registraion failed!!!!");
+            LOG.warn("Alarm suppression node registration failed!!!!");
         }
         List<Nodes> nodes = input.getNodes();
         AtomicBoolean success = new AtomicBoolean(true);
@@ -388,13 +388,19 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
 
         OpenroadmNodeVersion nodeOpenRoadmVersion =
                 this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
+
         List<String> interfacesToDelete = new LinkedList<>();
         Map<String, List<String>> suffixListMap =
             nodeOpenRoadmVersion.equals(OpenroadmNodeVersion._71)
                 ? Map.of(
-                    "ODU",  List.of("ODUC4","ODUFLEX"),
-                    // -400G added due to the change in naming convention
-                    "other", List.of("OTUC4", "OTSIGROUP-400G", spectralSlotName))
+                    // We don't need ODUC2, ODUC3 here, since they are handled in OTN service-path
+                    // This has to be in an order of deletion
+                    "ODU",  List.of("ODU4", "ODUFLEX", "ODUC4"),
+                    // Add intermediate OTUCn rates (OTUC2, OTUC3)
+                    // OTU4 is used in 100G service on 7.1 model
+                    "other", List.of("OTU4", "OTUC2", "OTUC3", "OTUC4",
+                    "OTSIGROUP-400G", "OTSIGROUP-300G",  "OTSIGROUP-200G",
+                    spectralSlotName))
                 : Map.of(
                     "ODU", List.of("ODU", "ODU4"),
                     "other", List.of("OTU", spectralSlotName));
@@ -418,8 +424,22 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                         suffixListMap.get("ODU")),
                     e);
             }
-            for (String suffix : suffixListMap.get("other")) {
-                interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix));
+            try {
+                for (String suffix : suffixListMap.get("other")) {
+                    if (this.openRoadmInterfaces.getInterface(
+                        nodeId, String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix)).isPresent()) {
+                        LOG.info("Deleting the interface {}",
+                            String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix));
+                        interfacesToDelete.add(String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, suffix));
+                    }
+                }
+            }
+            catch (OpenRoadmInterfaceException e) {
+                LOG.error("impossible to get one of the interfaces {}",
+                    destTp + GridConstant.NAME_PARAMETERS_SEPARATOR + String.join(
+                        " or " + destTp + GridConstant.NAME_PARAMETERS_SEPARATOR,
+                        suffixListMap.get("ODU")),
+                    e);
             }
         }
         if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {