Bump upstream dependencies to K-SR1
[transportpce.git] / networkmodel / src / main / java / org / opendaylight / transportpce / networkmodel / service / NetworkModelServiceImpl.java
index 42665ef5fbea328ba316d89db38c6cb5ee21a2ee..214aae49ce83da25f844146b79665b1bf62c6403 100644 (file)
@@ -8,19 +8,23 @@
 package org.opendaylight.transportpce.networkmodel.service;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.InstanceIdentifiers;
 import org.opendaylight.transportpce.common.NetworkUtils;
+import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.networkmodel.R2RLinkDiscovery;
@@ -30,44 +34,47 @@ import org.opendaylight.transportpce.networkmodel.util.LinkIdUtil;
 import org.opendaylight.transportpce.networkmodel.util.OpenRoadmNetwork;
 import org.opendaylight.transportpce.networkmodel.util.OpenRoadmOtnTopology;
 import org.opendaylight.transportpce.networkmodel.util.OpenRoadmTopology;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.NodeInfo.OpenroadmVersion;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1Builder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1Builder;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
+import org.opendaylight.transportpce.networkmodel.util.TopologyUtils;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TopologyUpdateResult;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TopologyUpdateResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.TopologyChanges;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.TopologyChangesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.topology.update.result.TopologyChangesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.OpenroadmNodeVersion;
+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.NodeInfo;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1;
-import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev201019.OtnLinkType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Link1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.link.tp.LinkTp;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.link.tp.LinkTpBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.termination.point.SupportingTerminationPoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev231024.ConnectionOper.ConnectionStatus;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint32;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Component(immediate = true)
 public class NetworkModelServiceImpl implements NetworkModelService {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetworkModelServiceImpl.class);
@@ -77,27 +84,26 @@ public class NetworkModelServiceImpl implements NetworkModelService {
     private final PortMapping portMapping;
     private Map<String, TopologyShard> topologyShardMountedDevice;
     private Map<String, TopologyShard> otnTopologyShardMountedDevice;
-    // Maps that include topology component changed with its new operational state <id, state>
-    private Map<String, State> linksChanged;
-    private Map<String, State> terminationPointsChanged;
-
-    public NetworkModelServiceImpl(final NetworkTransactionService networkTransactionService,
-            final R2RLinkDiscovery linkDiscovery, PortMapping portMapping) {
+    // Variables for creating and sending topology update notification
+    private final NotificationPublishService notificationPublishService;
+    private Map<TopologyChangesKey, TopologyChanges> topologyChanges;
+    private TopologyUpdateResult notification = null;
+
+    @Activate
+    public NetworkModelServiceImpl(@Reference DataBroker dataBroker,
+            @Reference DeviceTransactionManager deviceTransactionManager,
+            @Reference final NetworkTransactionService networkTransactionService,
+            @Reference PortMapping portMapping,
+            @Reference final NotificationPublishService notificationPublishService) {
 
         this.networkTransactionService = networkTransactionService;
-        this.linkDiscovery = linkDiscovery;
+        this.linkDiscovery = new R2RLinkDiscovery(dataBroker, deviceTransactionManager, networkTransactionService);
         this.portMapping = portMapping;
         this.topologyShardMountedDevice = new HashMap<String, TopologyShard>();
         this.otnTopologyShardMountedDevice = new HashMap<String, TopologyShard>();
-        this.linksChanged = new HashMap<String, State>();
-        this.terminationPointsChanged = new HashMap<String, State>();
-    }
-
-    public void init() {
-        LOG.info("init ...");
-    }
-
-    public void close() {
+        this.notificationPublishService = notificationPublishService;
+        this.topologyChanges = new HashMap<TopologyChangesKey, TopologyChanges>();
+        LOG.debug("NetworkModelServiceImpl instantiated");
     }
 
     @Override
@@ -105,6 +111,14 @@ public class NetworkModelServiceImpl implements NetworkModelService {
         try {
             LOG.info("createOpenROADMNode: {} ", nodeId);
 
+            boolean firstMount;
+            if (portMapping.getNode(nodeId) == null) {
+                firstMount = true;
+            } else {
+                LOG.info("{} already exists in portmapping but was reconnected", nodeId);
+                firstMount = false;
+            }
+
             if (!portMapping.createMappingData(nodeId, openRoadmVersion)) {
                 LOG.warn("Could not generate port mapping for {} skipping network model creation", nodeId);
                 return;
@@ -130,7 +144,8 @@ public class NetworkModelServiceImpl implements NetworkModelService {
                 openroadmNetworkNode);
 
             // nodes/links creation in openroadm-topology
-            TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(portMapping.getNode(nodeId));
+            TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(portMapping.getNode(nodeId),
+                                                                                firstMount);
             if (topologyShard != null) {
                 this.topologyShardMountedDevice.put(nodeId, topologyShard);
                 for (Node openRoadmTopologyNode : topologyShard.getNodes()) {
@@ -173,7 +188,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
     }
 
     @Override
-    public void setOpenRoadmNodeStatus(String nodeId, NetconfNodeConnectionStatus.ConnectionStatus connectionStatus) {
+    public void setOpenRoadmNodeStatus(String nodeId, ConnectionStatus connectionStatus) {
         LOG.info("setOpenROADMNodeStatus: {} {}", nodeId, connectionStatus.name());
         /*
           TODO: set connection status of the device in model,
@@ -188,8 +203,11 @@ public class NetworkModelServiceImpl implements NetworkModelService {
      */
 
     @Override
-    public void deleteOpenRoadmnode(String nodeId) {
+    public boolean deleteOpenRoadmnode(String nodeId) {
         try {
+            if (!this.portMapping.isNodeExist(nodeId)) {
+                return false;
+            }
             NodeKey nodeIdKey = new NodeKey(new NodeId(nodeId));
 
             LOG.info("deleting node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
@@ -224,7 +242,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
                 LOG.warn("TopologyShard for node '{}' is not present", nodeId);
             }
             @Nullable
-            OpenroadmVersion deviceVersion = this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
+            OpenroadmNodeVersion deviceVersion = this.portMapping.getNode(nodeId).getNodeInfo().getOpenroadmVersion();
             @Nullable
             NodeTypes nodeType = this.portMapping.getNode(nodeId).getNodeInfo().getNodeType();
             if (nodeType.getIntValue() == 2 && deviceVersion.getIntValue() != 1) {
@@ -254,96 +272,165 @@ public class NetworkModelServiceImpl implements NetworkModelService {
             }
 
             LOG.info("deleteOpenROADMnode: {} version {}", nodeId, deviceVersion.getName());
-            this.portMapping.deleteMappingData(nodeId);
+            this.portMapping.deletePortMappingNode(nodeId);
 
             this.networkTransactionService.commit().get(1, TimeUnit.SECONDS);
             LOG.info("all nodes and links deleted ! ");
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.error("Error when trying to delete node : {}", nodeId, e);
+            return false;
         }
+        return true;
     }
 
     @Override
-    public void updateOpenRoadmNetworkTopology(String nodeId, CircuitPacks changedCpack) {
-        // Clear maps for each NETCONF notification received
-        this.linksChanged.clear();
-        this.terminationPointsChanged.clear();
-        // 1. Get the list links and nodes of the current openroadm network topology
-        List<Link> linkList = null;
-        List<Node> nodesList = null;
+    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 {
-            InstanceIdentifier.InstanceIdentifierBuilder<Network1> network1IID =
-                InstanceIdentifier.builder(Networks.class)
-                    .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
-                    .augmentation(Network1.class);
-            InstanceIdentifier.InstanceIdentifierBuilder<Network> networkIID =
-                InstanceIdentifier.builder(Networks.class)
-                    .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)));
-            Optional<Network> networkOptional = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION,
-                networkIID.build()).get();
-            Optional<Network1> network1Optional =
-                this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, network1IID.build()).get();
-            if (network1Optional.isPresent()) {
-                // Links list
-                linkList = new ArrayList<>(Objects.requireNonNull(network1Optional.get().getLink()).values());
-            }
-            if (networkOptional.isPresent()) {
-                // Nodes list
-                nodesList = new ArrayList<>(Objects.requireNonNull(networkOptional.get().getNode()).values());
+            openroadmTopology = this.networkTransactionService
+                .read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifiers.OVERLAY_NETWORK_II)
+                .get().orElseThrow();
+            if (openroadmTopology.augmentation(Network1.class) != null) {
+                openroadmTopologyLinks = openroadmTopology.augmentation(Network1.class).getLink();
             }
-        } catch (InterruptedException e) {
-            LOG.error("Couldn't get list of links in the network. Error={}", e.getMessage());
-            Thread.currentThread().interrupt();
-        } catch (ExecutionException e) {
-            LOG.error("Couldn't get list of links in the network. Error={}", e.getMessage());
-        }
-        /* 2. For simplicity the update is only considered in the case of a WSSDEG circuit pack change where client and
-        line ports (external ports) of a node are included and there is a 1-to-1 port mapping to the nodes TPs. The
-        mapping between ports and TPs internal of a node is a bit different as the is a 1-to-many port mapping */
-        String cpackType = changedCpack.getCircuitPackType();
-        switch (cpackType) {
-            case "ADDROP":
-                LOG.info("ADDROP circuit pack modified");
-                setTerminationPointsChangedMap(changedCpack);
-                // setTpStateHashmap(changedCpack);
-                break;
-            case "WSSDEG":
-                LOG.info("WSSDEG circuit pack modified");
-                setTerminationPointsChangedMap(changedCpack);
-                // 3. Update the termination points of the node that sent a NETCONF notification
-                updateOpenRoadmNetworkTopologyTPs(nodesList, nodeId);
-                // 4. Update the links of the topology affected by the changes on TPs (if any)
-                updateOpenRoadmNetworkTopologyLinks(linkList, nodesList);
-                // TODO: send notification to service handler
-                break;
-            case "port":
-                LOG.info("port circuit pack modified");
-                break;
-            case "pluggable":
-                LOG.info("pluggable circuit pack modified");
-                break;
-            default:
-                LOG.warn("Circuitp pack of type {} not recognized", cpackType);
+            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);
         }
     }
 
     @Override
-    public void createOtnLinks(String nodeA, String tpA, String nodeZ, String tpZ, OtnLinkType linkType) {
+    public void createOtnLinks(
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link
+        notifLink, List<String> suppLinks, OtnLinkType linkType) {
+
         TopologyShard otnTopologyShard;
         switch (linkType) {
             case OTU4:
-                otnTopologyShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, linkType);
+            case OTUC2:
+            case OTUC3:
+            case OTUC4:
+                otnTopologyShard = OpenRoadmOtnTopology.createOtnLinks(notifLink, null, null, linkType);
                 break;
             case ODTU4:
-                String nodeTopoA = new StringBuilder(nodeA).append("-").append(tpA.split("-")[0]).toString();
-                String nodeTopoZ = new StringBuilder(nodeZ).append("-").append(tpZ.split("-")[0]).toString();
+            case ODUC2:
+            case ODUC3:
+            case ODUC4:
                 List<LinkId> linkIdList = new ArrayList<>();
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, "OTU4"));
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, "OTU4"));
+                if (suppLinks != null) {
+                    suppLinks.forEach(lk -> linkIdList.add(new LinkId(lk)));
+                }
                 List<Link> supportedOtu4links = getOtnLinks(linkIdList);
-                List<TerminationPoint> tps = getOtnNodeTps(nodeTopoA, tpA, nodeTopoZ, tpZ);
-
-                otnTopologyShard = OpenRoadmOtnTopology.createOtnLinks(supportedOtu4links, tps);
+                String nodeTopoA = convertNetconfNodeIdToTopoNodeId(notifLink.getATermination().getNodeId(),
+                    notifLink.getATermination().getTpId());
+                String nodeTopoZ = convertNetconfNodeIdToTopoNodeId(notifLink.getZTermination().getNodeId(),
+                    notifLink.getZTermination().getTpId());
+                List<TerminationPoint> tps = getOtnNodeTps(nodeTopoA, notifLink.getATermination().getTpId(), nodeTopoZ,
+                    notifLink.getZTermination().getTpId());
+                otnTopologyShard = OpenRoadmOtnTopology.createOtnLinks(notifLink, supportedOtu4links, tps, linkType);
                 break;
             default:
                 LOG.error("unknown otn link type {}", linkType);
@@ -384,36 +471,51 @@ public class NetworkModelServiceImpl implements NetworkModelService {
     }
 
     @Override
-    public void deleteOtnLinks(String nodeA, String tpA, String nodeZ, String tpZ, OtnLinkType linkType) {
+    public void deleteOtnLinks(
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link
+        notifLink, List<String> suppLinks, OtnLinkType linkType) {
+
         TopologyShard otnTopologyShard;
-        String nodeTopoA = new StringBuilder(nodeA).append("-").append(tpA.split("-")[0]).toString();
-        String nodeTopoZ = new StringBuilder(nodeZ).append("-").append(tpZ.split("-")[0]).toString();
-        List<Link> otu4Links;
+        String nodeTopoA = convertNetconfNodeIdToTopoNodeId(notifLink.getATermination().getNodeId(),
+            notifLink.getATermination().getTpId());
+        String nodeTopoZ = convertNetconfNodeIdToTopoNodeId(notifLink.getZTermination().getNodeId(),
+            notifLink.getZTermination().getTpId());
+        String tpA = notifLink.getATermination().getTpId();
+        String tpZ = notifLink.getZTermination().getTpId();
+        List<Link> otuLinks;
         List<LinkId> linkIdList = new ArrayList<>();
         switch (linkType) {
             case OTU4:
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, "OTU4"));
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, "OTU4"));
-                otu4Links = getOtnLinks(linkIdList);
-                if (checkLinks(otu4Links)) {
-                    deleteLinks(otu4Links);
+            case OTUC2:
+            case OTUC3:
+            case OTUC4:
+                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, linkType.getName()));
+                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, linkType.getName()));
+                otuLinks = getOtnLinks(linkIdList);
+                if (checkLinks(otuLinks)) {
+                    deleteLinks(otuLinks);
                 } else {
                     LOG.error("Error deleting OTU4 links");
                 }
                 otnTopologyShard = new TopologyShard(null, null);
                 break;
             case ODTU4:
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, "ODU4"));
-                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, "ODU4"));
-                List<Link> odu4Links = getOtnLinks(linkIdList);
+            case ODUC2:
+            case ODUC3:
+            case ODUC4:
+                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, linkType.getName()));
+                linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, linkType.getName()));
+                List<Link> oduLinks = getOtnLinks(linkIdList);
                 List<TerminationPoint> tps = getOtnNodeTps(nodeTopoA, tpA, nodeTopoZ, tpZ);
-                if (checkLinks(odu4Links) && checkTerminationPoints(tps)) {
-                    deleteLinks(odu4Links);
+                if (checkLinks(oduLinks) && checkTerminationPoints(tps)) {
+                    deleteLinks(oduLinks);
                     linkIdList.clear();
-                    linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoA, tpA, nodeTopoZ, tpZ, "OTU4"));
-                    linkIdList.add(LinkIdUtil.buildOtnLinkId(nodeTopoZ, tpZ, nodeTopoA, tpA, "OTU4"));
-                    otu4Links = getOtnLinks(linkIdList);
-                    otnTopologyShard = OpenRoadmOtnTopology.deleteOtnLinks(otu4Links, tps);
+                    if (suppLinks != null) {
+                        suppLinks.forEach(lk -> linkIdList.add(new LinkId(lk)));
+                    }
+                    otuLinks = getOtnLinks(linkIdList);
+
+                    otnTopologyShard = OpenRoadmOtnTopology.deleteOtnLinks(otuLinks, tps, linkType);
                 } else {
                     LOG.error("Error deleting ODU4 links");
                     otnTopologyShard = new TopologyShard(null, null);
@@ -423,6 +525,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
                 LOG.error("unknown otn link type {}", linkType);
                 otnTopologyShard = new TopologyShard(null, null);
         }
+
         if (otnTopologyShard.getLinks() != null) {
             for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
                 LOG.info("deleting and updating otn links {} in {}", otnTopologyLink.getLinkId().getValue(),
@@ -458,13 +561,48 @@ public class NetworkModelServiceImpl implements NetworkModelService {
     }
 
     @Override
-    public void updateOtnLinks(List<String> nodeTps, String serviceRate, Short tribPortNb, Short tribSoltNb,
-            boolean isDeletion) {
-        List<Link> supportedOdu4Links = getSupportingOdu4Links(nodeTps);
-        List<TerminationPoint> tps = getOtnNodeTps(nodeTps);
+    public void updateOtnLinks(
+        org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link
+            notifLink, List<String> suppLinks, Uint32 serviceRate, Short tribPortNb, Short minTribSoltNb,
+            Short maxTribSlotNb, boolean isDeletion) {
+
+        List<LinkTp> linkTerminations = new ArrayList<>();
+        List<Link> supportedOdu4Links = null;
+        if (notifLink != null) {
+            // retreive termination-points to be updated
+            linkTerminations.add(new LinkTpBuilder()
+                    .setNodeId(notifLink.getATermination().getNodeId())
+                    .setTpId(notifLink.getATermination().getTpId())
+                    .build());
+            linkTerminations.add(new LinkTpBuilder()
+                    .setNodeId(notifLink.getZTermination().getNodeId())
+                    .setTpId(notifLink.getZTermination().getTpId())
+                    .build());
+            // retreive supported links
+            supportedOdu4Links = getSupportingOdu4Links(linkTerminations, serviceRate);
+        } else if (suppLinks != null) {
+             // retreive supported links
+            List<LinkId> linkIdList = new ArrayList<>();
+            if (suppLinks != null) {
+                suppLinks.forEach(lk -> linkIdList.add(new LinkId(lk)));
+            }
+            supportedOdu4Links = getOtnLinks(linkIdList);
+            // retreive termination-points to be updated
+            for (Link link : supportedOdu4Links) {
+                LinkTp atermination = new LinkTpBuilder()
+                    .setNodeId(link.getSource().getSourceNode().getValue())
+                    .setTpId(link.getSource().getSourceTp().getValue())
+                    .build();
+                linkTerminations.add(atermination);
+            }
+        } else {
+            LOG.error("Impossible to update OTN links and their associated termination points in otn-topology");
+            return;
+        }
+        List<TerminationPoint> tps = getOtnNodeTps(linkTerminations);
         TopologyShard otnTopologyShard;
         otnTopologyShard = OpenRoadmOtnTopology.updateOtnLinks(supportedOdu4Links, tps, serviceRate, tribPortNb,
-            tribSoltNb, isDeletion);
+            minTribSoltNb, maxTribSlotNb, isDeletion);
         if (otnTopologyShard.getLinks() != null) {
             for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
                 LOG.info("creating and updating otn links {} in {}", otnTopologyLink.getLinkId().getValue(),
@@ -503,6 +641,35 @@ public class NetworkModelServiceImpl implements NetworkModelService {
         }
     }
 
+    @Override
+    public void updateOtnLinks(List<String> suppLinks, boolean isDeletion) {
+        List<LinkId> linkIdList = new ArrayList<>();
+        if (suppLinks != null) {
+            suppLinks.forEach(lk -> linkIdList.add(new LinkId(lk)));
+        }
+        List<Link> supportedOtu4links = getOtnLinks(linkIdList);
+
+        TopologyShard otnTopologyShard = OpenRoadmOtnTopology.updateOtnLinks(supportedOtu4links, isDeletion);
+        if (otnTopologyShard.getLinks() != null) {
+            for (Link otnTopologyLink : otnTopologyShard.getLinks()) {
+                LOG.info("creating and updating otn links {} in {}", otnTopologyLink.getLinkId().getValue(),
+                    NetworkUtils.OVERLAY_NETWORK_ID);
+                InstanceIdentifier<Link> iiOtnTopologyLink = InstanceIdentifier.builder(Networks.class)
+                    .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
+                    .augmentation(Network1.class)
+                    .child(Link.class, otnTopologyLink.key())
+                    .build();
+                networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOtnTopologyLink, otnTopologyLink);
+            }
+        }
+        try {
+            networkTransactionService.commit().get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Error adding OTN links in otn-topology", e);
+        }
+        LOG.info("OTN links updated");
+    }
+
     private List<Link> getOtnLinks(List<LinkId> linkIds) {
         List<Link> links = new ArrayList<>();
         for (LinkId linkId : linkIds) {
@@ -516,7 +683,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
             if (linkOptLf.isDone()) {
                 try {
                     if (linkOptLf.get().isPresent()) {
-                        links.add(linkOptLf.get().get());
+                        links.add(linkOptLf.get().orElseThrow());
                     }
                 } catch (InterruptedException | ExecutionException e) {
                     LOG.error("Error retreiving OTN links from otn-topology", e);
@@ -586,17 +753,17 @@ public class NetworkModelServiceImpl implements NetworkModelService {
         }
 
         if (tpAOpt.isPresent() && tpZOpt.isPresent()) {
-            tps.add(tpAOpt.get());
-            tps.add(tpZOpt.get());
+            tps.add(tpAOpt.orElseThrow());
+            tps.add(tpZOpt.orElseThrow());
         }
         return tps;
     }
 
-    private List<TerminationPoint> getOtnNodeTps(List<String> nodeTopoTps) {
+    private List<TerminationPoint> getOtnNodeTps(List<LinkTp> linkTerminations) {
         List<TerminationPoint> tps = new ArrayList<>();
-        for (String str : nodeTopoTps) {
-            String nodeId = str.split("--")[0];
-            String tp = str.split("--")[1];
+        for (LinkTp linkTp : linkTerminations) {
+            String tp = linkTp.getTpId();
+            String nodeId = formatNodeName(linkTp.getNodeId(), tp);
             InstanceIdentifier<TerminationPoint> iiTp = InstanceIdentifier.builder(Networks.class)
                 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
                 .child(Node.class, new NodeKey(new NodeId(nodeId)))
@@ -608,7 +775,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
                 try {
                     tpOpt = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, iiTp).get();
                     if (tpOpt.isPresent()) {
-                        tps.add(tpOpt.get());
+                        tps.add(tpOpt.orElseThrow());
                     }
                 } catch (InterruptedException | ExecutionException e) {
                     LOG.error("Error retreiving tp {} of node {} from otn-topology", tp, nodeId, e);
@@ -617,19 +784,13 @@ public class NetworkModelServiceImpl implements NetworkModelService {
                 LOG.error("error getting node termination points from the datastore");
             }
         }
-        if (tps.isEmpty()) {
-            LOG.warn("returning null");
-            return null;
-        } else {
-            LOG.info("returning tps = {}", tps.toString());
-            return tps;
-        }
+        return tps;
     }
 
     private void deleteLinks(List<Link> links) {
         for (Link otnTopologyLink : links) {
             LOG.info("deleting link {} from {}", otnTopologyLink.getLinkId().getValue(),
-                NetworkUtils.OVERLAY_NETWORK_ID);
+                NetworkUtils.OTN_NETWORK_ID);
             InstanceIdentifier<Link> iiOtnTopologyLink = InstanceIdentifier.builder(Networks.class)
                 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
                 .augmentation(Network1.class)
@@ -644,7 +805,7 @@ public class NetworkModelServiceImpl implements NetworkModelService {
         }
     }
 
-    private List<Link> getSupportingOdu4Links(List<String> nodesTopoTps) {
+    private List<Link> getSupportingOdu4Links(List<LinkTp> nodesTopoTps, Uint32 serviceRate) {
         InstanceIdentifier<Network1> iiOtnTopologyLinks = InstanceIdentifier.builder(Networks.class)
             .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID)))
             .augmentation(Network1.class)
@@ -660,37 +821,35 @@ public class NetworkModelServiceImpl implements NetworkModelService {
             }
         }
         List<Link> odu4links = null;
-        if (netw1Opt.isPresent() && netw1Opt.get().getLink() != null) {
+        if (netw1Opt.isPresent() && netw1Opt.orElseThrow().getLink() != null) {
             odu4links = netw1Opt
-                .get()
+                .orElseThrow()
                 .nonnullLink().values()
-                .stream().filter(lk -> lk.getLinkId().getValue().startsWith("ODU4"))
+                .stream().filter(lk -> lk.getLinkId().getValue()
+                    .startsWith(Uint32.valueOf(100).equals(serviceRate) ? "ODUC4" : "ODTU4"))
                 .collect(Collectors.toList());
         }
+        if (odu4links == null) {
+            return null;
+        }
         List<Link> links = new ArrayList<>();
-        if (odu4links != null) {
-            for (String str : nodesTopoTps) {
-                String[] nodeAndTp = str.split("--");
-                if (nodeAndTp.length >= 2) {
-                    String nodeId = nodeAndTp[0];
-                    String tp = nodeAndTp[1];
-                    Link slink = odu4links.stream().filter(lk -> lk.getSource().getSourceNode().getValue()
-                        .equals(nodeId) && lk.getSource().getSourceTp().toString().equals(tp)).findFirst().get();
-                    if (!links.contains(slink)) {
-                        links.add(slink);
-                    }
-                    Link dlink = odu4links.stream().filter(lk -> lk.getDestination().getDestNode().getValue()
-                        .equals(nodeId) && lk.getDestination().getDestTp().toString().equals(tp)).findFirst().get();
-                    if (!links.contains(dlink)) {
-                        links.add(dlink);
-                    }
-                }
+        for (LinkTp linkTp : nodesTopoTps) {
+            String tp = linkTp.getTpId();
+            String nodeId = new StringBuilder(linkTp.getNodeId()).append("-")
+                .append(tp.split("-")[0]).toString();
+            Link slink = odu4links.stream().filter(lk -> lk.getSource().getSourceNode().getValue()
+                .equals(nodeId) && lk.getSource().getSourceTp().getValue().equals(tp)).findFirst().orElseThrow();
+            if (!links.contains(slink)) {
+                links.add(slink);
+            }
+            Link dlink = odu4links.stream().filter(lk -> lk.getDestination().getDestNode().getValue()
+                .equals(nodeId) && lk.getDestination().getDestTp().getValue().equals(tp)).findFirst().orElseThrow();
+            if (!links.contains(dlink)) {
+                links.add(dlink);
             }
-            LOG.debug("odu4links = {}", links.toString());
-            return links;
-        } else {
-            return null;
         }
+        LOG.debug("odu4oduC4links = {}", links);
+        return links;
     }
 
     private void createOpenRoadmOtnNode(String nodeId) {
@@ -719,206 +878,33 @@ public class NetworkModelServiceImpl implements NetworkModelService {
         } else {
             LOG.error("Unable to create OTN topology shard for node {}!", nodeId);
         }
-
     }
 
-    private void setTerminationPointsChangedMap(CircuitPacks changedCpack) {
-        List<Ports> portsList = new ArrayList<>(Objects.requireNonNull(changedCpack.getPorts()).values());
-        for (Ports port : portsList) {
-            String lcp = port.getLogicalConnectionPoint();
-            if (lcp != null && !this.terminationPointsChanged.containsKey(lcp)) {
-                this.terminationPointsChanged.put(lcp, State.forValue(port.getOperationalState().getIntValue()));
-            }
-        }
-    }
-
-    private void updateOpenRoadmNetworkTopologyTPs(List<Node> nodesList, String nodeId) {
-        /* 1. The nodes in nodesList are abstract nodes (i.e. ROADMA01-DEG1) and we have the id of the node that has
-        a change (i.e. ROADMA01). So we only need to look for the abstract nodes that belong to the physical node. */
-        String abstractNodeId;
-        for (Node node : nodesList) {
-            abstractNodeId = Objects.requireNonNull(node.getNodeId()).getValue();
-            // Checking if the node is operationally inService
-            if (abstractNodeId.contains(nodeId) && node.augmentation(org.opendaylight.yang.gen.v1.http
-                    .org.openroadm.common.network.rev200529.Node1.class)
-                    .getOperationalState().equals(State.InService)) {
-                /* 2. Check if the state of the termination points from the topology shard are equal to the state of
-                the termination points in the previously created map. */
-                List<TerminationPoint> tpList = new ArrayList<>(Objects.requireNonNull(node.augmentation(Node1.class))
-                    .getTerminationPoint().values());
-                Map<TerminationPointKey, TerminationPoint> updatedTpMap = new HashMap<>();
-                for (TerminationPoint tp : tpList) {
-                    String tpId = Objects.requireNonNull(tp.getTpId()).getValue();
-                    State tpState = Objects.requireNonNull(tp.augmentation(org.opendaylight.yang.gen.v1.http
-                        .org.openroadm.common.network.rev200529.TerminationPoint1.class)).getOperationalState();
-                    if (this.terminationPointsChanged.containsKey(tpId) && !this.terminationPointsChanged.get(tpId)
-                            .equals(tpState)) {
-                        // The state of a termination point has changed... updating
-                        State newTpOperationalState = null;
-                        AdminStates newTpAdminState = null;
-                        /* 3. If the TP has changed its state, it has to be added to the links Map, as a Link state
-                        is defined by the state of the TPs that model the link. */
-                        switch (this.terminationPointsChanged.get(tpId)) {
-                            case InService:
-                                newTpAdminState = AdminStates.InService;
-                                newTpOperationalState = State.InService;
-                                // Add TP and state inService to the links Map
-                                this.linksChanged.put(tpId, State.InService);
-                                // TODO: update change list for service handler notification
-                                break;
-                            case OutOfService:
-                                newTpAdminState = AdminStates.OutOfService;
-                                newTpOperationalState = State.OutOfService;
-                                // Add TP and state outOfService to the links Map
-                                this.linksChanged.put(tpId, State.OutOfService);
-                                // TODO: update change list for service handler notification
-                                break;
-                            case Degraded:
-                                LOG.warn("Operational state Degraded not handled");
-                                break;
-                            default:
-                                LOG.warn("Unrecognized state!");
-                        }
-                        // 4. Add modified TP to the updated List.
-                        TerminationPoint updTp = new TerminationPointBuilder().withKey(tp.key())
-                            .setTpId(tp.getTpId())
-                            .addAugmentation(new TerminationPoint1Builder()
-                                .setAdministrativeState(newTpAdminState)
-                                .setOperationalState(newTpOperationalState)
-                                .build())
-                            .build();
-                        updatedTpMap.put(tp.key(), updTp);
-                    }
-                    // 5. Update the list of termination points of the corresponding node and merge to the datastore.
-                    if (!updatedTpMap.isEmpty()) {
-                        Node updNode = new NodeBuilder().setNodeId(node.getNodeId()).addAugmentation(new Node1Builder()
-                            .setTerminationPoint(updatedTpMap).build()).build();
-                        InstanceIdentifier<Node> iiOpenRoadmTopologyNode = InstanceIdentifier.builder(
-                            Networks.class).child(Network.class, new NetworkKey(
-                                    new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).child(Node.class, node.key())
-                            .build();
-                        networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, iiOpenRoadmTopologyNode,
-                            updNode);
-                        try {
-                            networkTransactionService.commit().get();
-                        } catch (InterruptedException e) {
-                            LOG.error("Couldnt commit change to openroadm topology.", e);
-                            Thread.currentThread().interrupt();
-                        } catch (ExecutionException e) {
-                            LOG.error("Couldnt commit change to openroadm topology.", e);
-                        }
-                    }
-                }
-            }
-        }
+    private String convertNetconfNodeIdToTopoNodeId(String nodeId, String tpId) {
+        return new StringBuilder(nodeId).append("-").append(tpId.split("-")[0]).toString();
     }
 
-    private void updateOpenRoadmNetworkTopologyLinks(List<Link> linkList, List<Node> nodesList) {
-        for (Link link : linkList) {
-            String srcTp = link.getSource().getSourceTp().toString();
-            String dstTp = link.getDestination().getDestTp().toString();
-            String srcNode = link.getSource().getSourceNode().getValue();
-            String dstNode = link.getDestination().getDestNode().getValue();
-            State linkState = link.augmentation(org.opendaylight.yang.gen.v1.http
-                .org.openroadm.common.network.rev200529.Link1.class).getOperationalState();
-            /* 1. Check the current state of the source and dest tps of the link. If these tps exist on the links Map
-            and the states are different, then we need to update the link state accordingly.
-            There are several cases depending on the current link state:
-                - TPs were both inService and one of them (or both) is (are) now outOfService --> link to outOfService
-                - TPs were both outOfService and both of them are now inService --> link to inService
-            However, if only one TP exists on the Link map, we will need to check the state of the other end in order to
-            make a decision: i.e. we cannot assume that if a TP has changed from outOfService to inService the link will
-            become inService, as this can only happen if both TPs are inService, therefore we need to check the other
-            end. */
-            switch (linkState) {
-                case InService:
-                    if (this.linksChanged.containsKey(srcTp) && this.linksChanged.containsKey(dstTp)) {
-                        // Both TPs of the link have been updated. If one of them is outOfService --> link outOfService
-                        if (State.OutOfService.equals(this.linksChanged.get(srcTp)) || State.OutOfService.equals(this
-                                .linksChanged.get(dstTp))) {
-                            updateLinkStates(link, State.OutOfService, AdminStates.OutOfService);
-                        }
-                    } else if (this.linksChanged.containsKey(srcTp) && State.OutOfService.equals(this.linksChanged
-                            .get(srcTp))) {
-                        // Source TP has been changed to outOfService --> link outOfService
-                        updateLinkStates(link, State.OutOfService, AdminStates.OutOfService);
-                    } else if (this.linksChanged.containsKey(dstTp) && State.OutOfService.equals(this.linksChanged
-                            .get(dstTp))) {
-                        // Destination TP has been changed to outOfService --> link outOfService
-                        updateLinkStates(link, State.OutOfService, AdminStates.OutOfService);
-                    }
-                    break;
-                case OutOfService:
-                    if (this.linksChanged.containsKey(srcTp) && this.linksChanged.containsKey(dstTp)) {
-                        // Both TPs of the link have been updated. If both of them are inService --> link inService
-                        if (State.InService.equals(this.linksChanged.get(srcTp)) || State.InService.equals(this
-                                .linksChanged.get(dstTp))) {
-                            updateLinkStates(link, State.InService, AdminStates.InService);
-                        }
-                    } else if (this.linksChanged.containsKey(srcTp) && State.InService.equals(this.linksChanged
-                            .get(srcTp))) {
-                        // Source TP has been changed to inService --> check the second TP and update link to inService
-                        // only if both TPs are inService
-                        if (tpInService(dstNode, dstTp, nodesList)) {
-                            updateLinkStates(link, State.InService, AdminStates.InService);
-                        }
-                    } else if (this.linksChanged.containsKey(dstTp) && State.InService.equals(this.linksChanged
-                            .get(dstTp))) {
-                        // Destination TP has been changed to to inService --> check the second TP and update link to
-                        // inService only if both TPs are inService
-                        if (tpInService(srcNode, srcTp, nodesList)) {
-                            updateLinkStates(link, State.InService, AdminStates.InService);
-                        }
-                    }
-                    break;
-                case Degraded:
-                    LOG.warn("Link state degraded not handled");
-                    break;
-                default:
-                    LOG.warn("Unrecognized state!");
-            }
-        }
+    private static String formatNodeName(String nodeName, String tpName) {
+        return nodeName.contains("-XPDR")
+            ? nodeName
+            : new StringBuilder(nodeName).append("-").append(tpName.split("-")[0]).toString();
     }
 
-    private boolean tpInService(String nodeId, String tpId, List<Node> nodesList) {
-        // Check the node with dstNode id and check the state of the TP with id dstTP id
-        for (Node node : nodesList) {
-            if (Objects.requireNonNull(node.getNodeId()).getValue().equals(nodeId)) {
-                List<TerminationPoint> tpList = new ArrayList<>(Objects.requireNonNull(Objects.requireNonNull(node
-                    .augmentation(Node1.class)).getTerminationPoint()).values());
-                for (TerminationPoint tp : tpList) {
-                    if (Objects.requireNonNull(tp.getTpId()).getValue().equals(tpId)) {
-                        if (State.InService.equals(tp.augmentation(org.opendaylight.yang.gen.v1.http
-                                .org.openroadm.common.network.rev200529.TerminationPoint1.class)
-                                .getOperationalState())) {
-                            // The second TP is also inService
-                            return true;
-                        }
-                        break;
-                    }
-                }
-                break;
-            }
+    @SuppressFBWarnings(
+            value = "UPM_UNCALLED_PRIVATE_METHOD",
+            justification = "false positive, this method is used by public updateOpenRoadmNetworkTopology")
+    private void sendNotification() {
+        if (topologyChanges.isEmpty()) {
+            LOG.warn("Empty Topology Change List. No updates in topology");
+            return;
         }
-        return false;
-    }
-
-    private void updateLinkStates(Link link, State state, AdminStates adminStates) {
-        // TODO: add change to list of changes
-        org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1 link1 = new Link1Builder()
-            .setOperationalState(state).setAdministrativeState(adminStates).build();
-        Link updLink = new LinkBuilder().withKey(link.key()).addAugmentation(link1).build();
-        InstanceIdentifier.InstanceIdentifierBuilder<Link> linkIID = InstanceIdentifier.builder(Networks.class)
-            .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)))
-            .augmentation(Network1.class).child(Link.class, link.key());
-        networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, linkIID.build(), updLink);
+        this.notification = new TopologyUpdateResultBuilder()
+            .setTopologyChanges(topologyChanges)
+            .build();
         try {
-            networkTransactionService.commit().get();
+            notificationPublishService.putNotification(this.notification);
         } catch (InterruptedException e) {
-            LOG.error("Couldnt commit changed to openroadm topology. Error={}", e.getMessage());
-            Thread.currentThread().interrupt();
-        } catch (ExecutionException e) {
-            LOG.error("Couldnt commit changed to openroadm topology. Error={}", e.getMessage());
+            LOG.error("Notification offer rejected. Error={}", e.getMessage());
         }
     }
 }