Read all LLDP neighbours even if one fails 96/89596/3
authorJonas Mårtensson <jonas.martensson@ri.se>
Tue, 5 May 2020 06:48:06 +0000 (08:48 +0200)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Tue, 12 May 2020 12:53:12 +0000 (12:53 +0000)
Currently in the readLLDP function, when looping over all neighbours in
nbrList, if createR2RLink for one neighbour fails, the whole function
returns which means that the rest of the neighbors in nbrList are never
processed. I think it makes more sense to continue the loop and create
R2R links for other neighbors. This patch proposes to do that while
still returning false if one createR2RLink fails.

Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
Change-Id: I73d587cc52c1b11e449baf3c69c9179a7dc2483d

networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/R2RLinkDiscovery.java

index fc4d287e155d9a5b41cf0912a7d0a1b7560466ba..a8c34043dacbec127979690e99bf06ff201c4144 100644 (file)
@@ -71,6 +71,7 @@ public class R2RLinkDiscovery {
             }
             NbrList nbrList = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList();
             LOG.info("LLDP subtree is present. Device has {} neighbours", nbrList.getIfName().size());
+            boolean success = true;
             for (IfName ifName : nbrList.getIfName()) {
                 if (ifName.getRemoteSysName() == null) {
                     LOG.warn("LLDP subtree neighbour is empty for nodeId: {}, ifName: {}",
@@ -88,12 +89,12 @@ public class R2RLinkDiscovery {
                             ifName.getRemotePortId())) {
                             LOG.error("Link Creation failed between {} and {} nodes.", nodeId.getValue(),
                                 ifName.getRemoteSysName());
-                            return false;
+                            success = false;
                         }
                     }
                 }
             }
-            return true;
+            return success;
         }
         else if (nodeVersion.equals(OPENROADM_DEVICE_VERSION_2_2_1)) {
             InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device
@@ -114,6 +115,7 @@ public class R2RLinkDiscovery {
                 = protocolObject.get().augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019
                 .Protocols1.class).getLldp().getNbrList();
             LOG.info("LLDP subtree is present. Device has {} neighbours", nbrList.getIfName().size());
+            boolean success = true;
             for (org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.lldp.container.lldp.nbr.list.IfName
                 ifName : nbrList.getIfName()) {
                 if (ifName.getRemoteSysName() == null) {
@@ -132,12 +134,12 @@ public class R2RLinkDiscovery {
                             ifName.getRemotePortId())) {
                             LOG.error("Link Creation failed between {} and {} nodes.", nodeId, ifName
                                 .getRemoteSysName());
-                            return false;
+                            success = false;
                         }
                     }
                 }
             }
-            return true;
+            return success;
         }
         else {
             LOG.error("Unable to read LLDP data for unmanaged openroadm device version");