- public boolean readLLDP(NodeId nodeId) {
- InstanceIdentifier<Protocols> protocolsIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
- .child(Protocols.class);
- Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId.getValue(),
- LogicalDatastoreType.OPERATIONAL, protocolsIID, Timeouts.DEVICE_READ_TIMEOUT,
- Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocolObject.isPresent() || (protocolObject.get().augmentation(Protocols1.class) == null)) {
- LOG.warn("LLDP subtree is missing : isolated openroadm device");
- return false;
+ public boolean readLLDP(NodeId nodeId, String nodeVersion) {
+
+ if (nodeVersion.equals(OPENROADM_DEVICE_VERSION_1_2_1)) {
+ InstanceIdentifier<Protocols> protocolsIID = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+ .child(Protocols.class);
+ Optional<Protocols> protocolObject = this.deviceTransactionManager.getDataFromDevice(nodeId.getValue(),
+ LogicalDatastoreType.OPERATIONAL, protocolsIID, Timeouts.DEVICE_READ_TIMEOUT,
+ Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+ if (!protocolObject.isPresent() || (protocolObject.get().augmentation(Protocols1.class) == null)) {
+ LOG.warn("LLDP subtree is missing : isolated openroadm device");
+ return false;
+ }
+ NbrList nbrList = protocolObject.get().augmentation(Protocols1.class).getLldp().getNbrList();
+ LOG.info("LLDP subtree is present. Device has {} neighbours", nbrList.getIfName().size());
+ for (IfName ifName : nbrList.getIfName()) {
+ if (ifName.getRemoteSysName() == null) {
+ LOG.warn("LLDP subtree neighbour is empty for nodeId: {}, ifName: {}",
+ nodeId.getValue(),ifName.getIfName());
+ } else {
+ Optional<MountPoint> mps = this.deviceTransactionManager.getDeviceMountPoint(ifName
+ .getRemoteSysName());
+ if (!mps.isPresent()) {
+ LOG.warn("Neighbouring nodeId: {} is not mounted yet", ifName.getRemoteSysName());
+ // The controller raises a warning rather than an error because the first node to
+ // mount cannot see its neighbors yet. The link will be detected when processing
+ // the neighbor node.
+ } else {
+ if (!createR2RLink(nodeId, ifName.getIfName(), ifName.getRemoteSysName(),
+ ifName.getRemotePortId())) {
+ LOG.error("Link Creation failed between {} and {} nodes.", nodeId.getValue(),
+ ifName.getRemoteSysName());
+ return false;
+ }
+ }
+ }
+ }
+ return true;