+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void updateOpenRoadmTopologies(String nodeId, Mapping mapping) {
+ LOG.info("update OpenRoadm topologies after change update from: {} ", nodeId);
+ this.topologyChanges.clear();
+ Network openroadmTopology = null;
+ Network otnTopology = null;
+ Map<LinkKey, Link> openroadmTopologyLinks = null;
+ Map<LinkKey, Link> otnTopologyLinks = null;
+ try {
+ openroadmTopology = this.networkTransactionService
+ .read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifiers.OVERLAY_NETWORK_II)
+ .get().orElseThrow();
+ if (openroadmTopology.augmentation(Network1.class) != null) {
+ openroadmTopologyLinks = openroadmTopology.augmentation(Network1.class).getLink();
+ }
+ otnTopology = this.networkTransactionService
+ .read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifiers.OTN_NETWORK_II)
+ .get().orElseThrow();
+ if (otnTopology.augmentation(Network1.class) != null) {
+ otnTopologyLinks = otnTopology.augmentation(Network1.class).getLink();
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Error when trying to update node : {}", nodeId, e);
+ }
+ if (openroadmTopology == null || otnTopology == null) {
+ LOG.warn("Error getting topologies from datastore");
+ return;
+ }
+ String abstractNodeid = String.join("-", nodeId, mapping.getLogicalConnectionPoint().split("-")[0]);
+ // nodes/links update in openroadm-topology
+ if (openroadmTopology.getNode() != null) {
+ TopologyShard topologyShard = TopologyUtils.updateTopologyShard(abstractNodeid, mapping,
+ openroadmTopology.getNode(), openroadmTopologyLinks);
+ if (topologyShard.getLinks() != null) {
+ for (Link link : topologyShard.getLinks()) {
+ LOG.info("updating links {} in {}", link.getLinkId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ InstanceIdentifier<Link> iiTopologyLink = InstanceIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, link.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiTopologyLink, link);
+ }
+ }
+ if (topologyShard.getTps() != null) {
+ for (TerminationPoint tp : topologyShard.getTps()) {
+ LOG.info("updating TP {} in openroadm-topology", tp.getTpId().getValue());
+ InstanceIdentifier<TerminationPoint> iiTopologyTp = InstanceIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
+ .child(Node.class, new NodeKey(new NodeId(abstractNodeid)))
+ .augmentation(Node1.class)
+ .child(TerminationPoint.class, new TerminationPointKey(tp.getTpId()))
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiTopologyTp, tp);
+ TopologyChanges tc = new TopologyChangesBuilder()
+ .withKey(new TopologyChangesKey(abstractNodeid, tp.getTpId().getValue()))
+ .setNodeId(abstractNodeid)
+ .setTpId(tp.getTpId().getValue())
+ .setState(tp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1
+ .class).getOperationalState())
+ .build();
+ if (!this.topologyChanges.containsKey(tc.key())) {
+ this.topologyChanges.put(tc.key(), tc);
+ }
+ }
+ }
+ }
+ // nodes/links update in otn-topology
+ if (otnTopology.getNode() != null
+ && otnTopology.getNode().containsKey(new NodeKey(new NodeId(abstractNodeid)))) {
+ TopologyShard otnShard = TopologyUtils.updateTopologyShard(abstractNodeid, mapping,
+ otnTopology.getNode(), otnTopologyLinks);
+ if (otnShard.getLinks() != null) {
+ for (Link link : otnShard.getLinks()) {
+ LOG.info("updating links {} in {}", link.getLinkId().getValue(),
+ NetworkUtils.OVERLAY_NETWORK_ID);
+ InstanceIdentifier<Link> iiTopologyLink = InstanceIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .augmentation(Network1.class)
+ .child(Link.class, link.key())
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiTopologyLink, link);
+ }
+ }
+ if (otnShard.getTps() != null) {
+ for (TerminationPoint tp : otnShard.getTps()) {
+ LOG.info("updating TP {} in otn-topology", tp.getTpId().getValue());
+ InstanceIdentifier<TerminationPoint> iiTopologyTp = InstanceIdentifier.builder(Networks.class)
+ .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+ .child(Node.class, new NodeKey(new NodeId(abstractNodeid)))
+ .augmentation(Node1.class)
+ .child(TerminationPoint.class, new TerminationPointKey(tp.getTpId()))
+ .build();
+ networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiTopologyTp, tp);
+ TopologyChanges tc = new TopologyChangesBuilder()
+ .withKey(new TopologyChangesKey(abstractNodeid, tp.getTpId().getValue()))
+ .setNodeId(abstractNodeid)
+ .setTpId(tp.getTpId().getValue())
+ .setState(tp.augmentation(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1
+ .class).getOperationalState())
+ .build();
+ if (!this.topologyChanges.containsKey(tc.key())) {
+ this.topologyChanges.put(tc.key(), tc);
+ }
+ }
+ }
+ }
+ // commit datastore updates
+ try {
+ networkTransactionService.commit().get();
+ sendNotification();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Error updating openroadm-topology", e);