Update PortMapping for XPDR netconf devices 16/64616/1
authorGilles Thouenon <gilles.thouenon@orange.com>
Thu, 12 Oct 2017 08:25:36 +0000 (10:25 +0200)
committerGilles <gilles.thouenon@orange.com>
Mon, 23 Oct 2017 16:11:37 +0000 (18:11 +0200)
Add some logs in the PortMapping treatment and deal with the case
where a XPDR includes at least one circuit-pack that does not support
even one port.

Change-Id: Icdceee60cd7cd22be4a25b116c357207bac4e251
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
renderer/src/main/java/org/opendaylight/transportpce/renderer/mapping/PortMapping.java

index b0e975cacb6c68900b379157fcc4064c64cce901..93a75e29352465f86dc7b7aae107fc5f408e3d1e 100644 (file)
@@ -344,26 +344,41 @@ public class PortMapping {
             if (deviceObject.isPresent()) {
                 for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
                     String circuitPackName = cp.getCircuitPackName();
-                    for (Ports port : cp.getPorts()) {
-                        if (port.getPortQual().getIntValue() == 3) {
-                            // Port is xpdr-network
-                            portMapList.add(createMappingObject(port, circuitPackName, "LINE" + line, deviceDb));
-                            line++;
-                        }
-                        if (port.getPortQual().getIntValue() == 4) {
-                            // port is xpdr-client
-                            portMapList.add(createMappingObject(port, circuitPackName, "CLNT" + client, deviceDb));
-                            client++;
+                    if (cp.getPorts() == null) {
+                        LOG.warn("No port found for {}, circuit pack {}", deviceInfo.getNodeId(), circuitPackName);
+                    } else {
+                        for (Ports port : cp.getPorts()) {
+                            if (port.getPortQual() != null) {
+                                if (port.getPortQual().getIntValue() == 3) {
+                                    // Port is xpdr-network
+                                    portMapList.add(createMappingObject(port, circuitPackName, "XPDR-LINE"
+                                        + line, deviceDb));
+                                    LOG.info("Logical Connection Point for {} {} is XPDR-LINE{}", circuitPackName, port
+                                        .getPortName(), line);
+                                    line++;
+                                }
+                                if (port.getPortQual().getIntValue() == 4) {
+                                    // port is xpdr-client
+                                    portMapList.add(createMappingObject(port, circuitPackName, "XPDR-CLNT"
+                                        + client, deviceDb));
+                                    LOG.info("Logical Connection Point for {} {} is XPDR-CLNT{}", circuitPackName, port
+                                        .getPortName(), client);
+                                    client++;
+                                }
+                            } else {
+                                LOG.info("no PortQual for port {} of circuit pack {}", port.getPortName(), cp
+                                    .getCircuitPackName());
+                            }
                         }
                     }
                 }
             } else {
-                LOG.info("Circuit Packs are not present for " + nodeId);
+                LOG.info("No deviceObject present for {}", nodeId);
                 return false;
             }
 
         } catch (InterruptedException | ExecutionException ex) {
-            LOG.warn("Read failed for CircuitPacks of " + nodeId, ex);
+            LOG.warn("Read failed for CircuitPacks of {}", nodeId, ex);
             return false;
         }
         return true;