import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.Timeouts;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.tapi.utils.TapiLink;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.cp.to.degree.CpToDegree;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.cp.to.degree.CpToDegree;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesKey;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Protocols;
private final TapiLink tapiLink;
public R2RTapiLinkDiscovery(NetworkTransactionService networkTransactionService,
- DeviceTransactionManager deviceTransactionManager, TapiLink tapiLink) {
+ DeviceTransactionManager deviceTransactionManager, TapiLink tapiLink) {
this.networkTransactionService = networkTransactionService;
this.deviceTransactionManager = deviceTransactionManager;
this.tapiLink = tapiLink;
Optional<Protocols> protocol121Object = this.deviceTransactionManager.getDataFromDevice(
nodeId.getValue(), LogicalDatastoreType.OPERATIONAL, protocols121IID, Timeouts.DEVICE_READ_TIMEOUT,
Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocol121Object.isPresent()
- || (protocol121Object.get().augmentation(Protocols1.class) == null)) {
- LOG.warn("LLDP subtree is missing : isolated openroadm device");
+ if (hasNoNeighbor121(protocol121Object)) {
+ LOG.warn("LLDP subtree is missing or incomplete: isolated openroadm device");
return new HashMap<>();
}
// get neighbor list
.child(org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device
.container.org.openroadm.device.Protocols.class)
.build();
- Optional<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device
- .container.org.openroadm.device.Protocols> protocol221Object = this.deviceTransactionManager
+ var protocol221Object = this.deviceTransactionManager
.getDataFromDevice(nodeId.getValue(), LogicalDatastoreType.OPERATIONAL, protocols221IID,
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
- if (!protocol221Object.isPresent() || (protocol221Object.get().augmentation(
- org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class) == null)) {
- LOG.warn("LLDP subtree is missing : isolated openroadm device");
+ if (hasNoNeighbor221(protocol221Object)) {
+ LOG.warn("LLDP subtree is missing or incomplete: isolated openroadm device");
return new HashMap<>();
}
- org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.lldp.container.lldp.@Nullable NbrList
- nbr221List = protocol221Object.get().augmentation(org.opendaylight.yang.gen.v1.http
- .org.openroadm.lldp.rev181019.Protocols1.class).getLldp().getNbrList();
+ var nbr221List = protocol221Object.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", nbr221List.getIfName().size());
return rdm2rdmLinkCreatev221(nodeId, tapiTopoUuid, nbr221List);
case 3:
}
}
+ private boolean hasNoNeighbor121(Optional<Protocols> protocol121Object) {
+ return protocol121Object.isEmpty()
+ || protocol121Object.get().augmentation(Protocols1.class) == null
+ || protocol121Object.get().augmentation(Protocols1.class).getLldp() == null
+ || protocol121Object.get().augmentation(Protocols1.class).getLldp().getNbrList() == null;
+ }
+
+ private boolean hasNoNeighbor221(Optional<
+ org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org
+ .openroadm.device.Protocols> protocol221Object) {
+ return protocol221Object.isEmpty()
+ || protocol221Object.get().augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class) == null
+ || protocol221Object.get().augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
+ .getLldp() == null
+ || protocol221Object.get().augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.Protocols1.class)
+ .getLldp().getNbrList() == null;
+ }
+
private Map<LinkKey, Link> rdm2rdmLinkCreatev221(NodeId nodeId, Uuid tapiTopoUuid,
org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.lldp.container.lldp.NbrList nbrList) {
Map<LinkKey, Link> linkMap = new HashMap<>();