Refactor TAPI ConvertORTopoToTapiFullTopo 53/110153/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 5 Feb 2024 20:53:43 +0000 (21:53 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Tue, 6 Feb 2024 10:05:22 +0000 (11:05 +0100)
JIRA: TRNSPRTPCE-735
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I707ce33c5be5540a8fd7692c06d214fd4bb6d8ed

tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiFullTopo.java

index 9e83c91e6bac4b0c899f7d3e23241befe10d13e0..ca5d57cdd1325bc4531cd1311b91d9caa9b3b2b9 100644 (file)
@@ -44,9 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPac;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
@@ -84,51 +82,47 @@ public class ConvertORTopoToTapiFullTopo {
         this.tapiLink = tapiLink;
     }
 
-    public void convertRdmToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link> rdmTordmLinkList) {
+    public void convertRdmToRdmLinks(
+            List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> rdmTordmLinkList) {
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-            .Link link : rdmTordmLinkList) {
+        for (var link : rdmTordmLinkList) {
             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                        .ietf.network.topology.rev180226.networks.network.Link oppositeLink = rdmTordmLinkList.stream()
+                var oppositeLink = rdmTordmLinkList.stream()
                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink()))
                     .findAny().orElse(null);
-
                 AdminStates oppLnkAdmState = null;
                 State oppLnkOpState = null;
                 if (oppositeLink != null) {
                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
                 }
-                String adminState =
-                    link.augmentation(Link1.class).getAdministrativeState() == null
-                        || oppLnkAdmState == null
-                    ? null
-                    : this.tapiLink.setTapiAdminState(
-                        link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
-                String operState =
-                    link.augmentation(Link1.class).getOperationalState() == null
-                        || oppLnkOpState == null
-                    ? null
-                    : this.tapiLink.setTapiOperationalState(
-                        link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
 
-                Link tapLink = this.tapiLink.createTapiLink(String.join("-",
+                Link tapLink = this.tapiLink.createTapiLink(
+                    String.join("-",
                         link.getSource().getSourceNode().getValue().split("-")[0],
                         link.getSource().getSourceNode().getValue().split("-")[1]),
-                    link.getSource().getSourceTp().getValue(), String.join("-",
+                    link.getSource().getSourceTp().getValue(),
+                    String.join("-",
                         link.getDestination().getDestNode().getValue().split("-")[0],
                         link.getDestination().getDestNode().getValue().split("-")[1]),
                     link.getDestination().getDestTp().getValue(), TapiStringConstants.OMS_RDM_RDM_LINK,
                     TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA,
-                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState, operState,
+                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+                    //adminState,
+                    link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+                        ? null
+                        : this.tapiLink.setTapiAdminState(
+                            link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+                    //operState,
+                    link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+                        ? null
+                        : this.tapiLink.setTapiOperationalState(
+                            link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
                     Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
                     this.tapiTopoUuid);
-                linksToNotConvert.add(link
-                    .augmentation(Link1.class)
-                    .getOppositeLink().getValue());
+                linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
                 tapiLinks.put(tapLink.key(), tapLink);
             }
         }
@@ -137,7 +131,8 @@ public class ConvertORTopoToTapiFullTopo {
     public void convertRoadmNode(Node roadm, Network openroadmTopo) {
         this.ietfNodeId = roadm.getNodeId().getValue();
         this.ietfNodeType = roadm.augmentation(
-            org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class).getNodeType();
+                org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+            .getNodeType();
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
         // 1. Get degree and srg nodes to map TPs into NEPs
         if (openroadmTopo.getNode() == null) {
@@ -148,24 +143,24 @@ public class ConvertORTopoToTapiFullTopo {
         int numSips = 0;
         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
         for (Node node:nodeList) {
-            if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
-                .equals(this.ietfNodeId))) {
-                LOG.debug("Abstracted node {} is not part of {}",
-                    node.getNodeId().getValue(), this.ietfNodeId);
+            if (node.getSupportingNode().values().stream()
+                    .noneMatch(sp -> sp.getNodeRef().getValue().equals(this.ietfNodeId))) {
+                LOG.debug("Abstracted node {} is not part of {}", node.getNodeId().getValue(), this.ietfNodeId);
                 continue;
             }
             if (node.augmentation(Node1.class) == null
-                && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                .ietf.network.topology.rev180226.Node1.class) == null) {
+                    && node.augmentation(
+                            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                        .Node1.class) == null) {
                 LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
                     node.getNodeId().getValue());
                 continue;
             }
-            OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
-                .org.openroadm.common.network.rev230526.Node1.class).getNodeType();
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
-                node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.Node1.class);
+            OpenroadmNodeType nodeType = node.augmentation(
+                        org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class)
+                .getNodeType();
+            var node1 = node.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
             LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
             switch (nodeType.getIntValue()) {
                 case 11:
@@ -173,11 +168,11 @@ public class ConvertORTopoToTapiFullTopo {
                     // Get only external TPs of the degree
                     List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
+                                == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREERXTTP.getIntValue()
+                                == OpenroadmTpType.DEGREERXTTP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.DEGREETXTTP.getIntValue())
+                                == OpenroadmTpType.DEGREETXTTP.getIntValue())
                         .collect(Collectors.toList());
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Degree port List: {}", degPortList);
@@ -191,11 +186,11 @@ public class ConvertORTopoToTapiFullTopo {
                     // Get only external TPs of the srg
                     List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGTXRXPP.getIntValue()
+                                == OpenroadmTpType.SRGTXRXPP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGRXPP.getIntValue()
+                                == OpenroadmTpType.SRGRXPP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
-                            == OpenroadmTpType.SRGTXPP.getIntValue())
+                                == OpenroadmTpType.SRGTXPP.getIntValue())
                         .collect(Collectors.toList());
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Srg port List: {}", srgPortList);
@@ -209,33 +204,30 @@ public class ConvertORTopoToTapiFullTopo {
         }
         // create tapi Node
         // UUID
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
-            TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
-        LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid.toString());
+        String nodeIdPhMed = String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA);
+        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdPhMed.getBytes(Charset.forName("UTF-8"))).toString());
+        LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", roadm.getNodeId().getValue(), nodeUuid);
         // Names
-        Name nodeNames =  new NameBuilder().setValueName("roadm node name")
-            .setValue(String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA)).build();
-        Name nameNodeType = new NameBuilder().setValueName("Node Type")
-            .setValue(this.ietfNodeType.getName()).build();
+        Name nodeNames =  new NameBuilder().setValueName("roadm node name").setValue(nodeIdPhMed).build();
+        Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
         // Protocol Layer
         Set<LayerProtocolName> layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
         // Build tapi node
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
-            .Node roadmNode = createRoadmTapiNode(nodeUuid,
-            Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
+        var roadmNode = createRoadmTapiNode(
+            nodeUuid, Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
         // TODO add states corresponding to device config
         LOG.info("ROADM node {} should have {} NEPs and {} SIPs", roadm.getNodeId().getValue(), numNeps, numSips);
-        LOG.info("ROADM node {} has {} NEPs and {} SIPs", roadm.getNodeId().getValue(),
+        LOG.info("ROADM node {} has {} NEPs and {} SIPs",
+            roadm.getNodeId().getValue(),
             roadmNode.nonnullOwnedNodeEdgePoint().values().size(),
             roadmNode.nonnullOwnedNodeEdgePoint().values().stream()
                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
-
         tapiNodes.put(roadmNode.key(), roadmNode);
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node
-             createRoadmTapiNode(Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
-             Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createRoadmTapiNode(
+            Uuid nodeUuid, Map<NameKey, Name> nameMap, Set<LayerProtocolName> layerProtocols,
+            Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
         // Empty random creation of mandatory fields for avoiding errors....
         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
             .setCostAlgorithm("Restricted Shortest Path - RSP")
@@ -253,9 +245,6 @@ public class ConvertORTopoToTapiFullTopo {
             .setRiskCharacteristicName("risk characteristic")
             .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
             .build();
-        RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
-            .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
-            .build();
         return new NodeBuilder()
             .setUuid(nodeUuid)
             .setName(nameMap)
@@ -268,7 +257,10 @@ public class ConvertORTopoToTapiFullTopo {
                 .createNodeRuleGroupForRdmNode("Full",nodeUuid, this.ietfNodeId, oneplist.values()))
             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
-            .setRiskParameterPac(riskParamPac)
+            .setRiskParameterPac(
+                new RiskParameterPacBuilder()
+                    .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+                    .build())
             .setErrorCharacteristic("error")
             .setLossCharacteristic("loss")
             .setRepeatDeliveryCharacteristic("repeat delivery")
@@ -278,43 +270,39 @@ public class ConvertORTopoToTapiFullTopo {
             .build();
     }
 
-    private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(List<TerminationPoint> tpList,
-            boolean withSip, String nepPhotonicSublayer) {
+    private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(
+            List<TerminationPoint> tpList, boolean withSip, String nepPhotonicSublayer) {
         // create neps for MC and OTSiMC and Photonic Media
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
         for (TerminationPoint tp:tpList) {
-            // Admin and oper state common for all tps
-            AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
-            State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
             // PHOTONIC MEDIA nep
-            LOG.info("PHOTO NEP = {}", String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                tp.getTpId().getValue()));
+            String nodeIdNepTp = String.join("+", this.ietfNodeId, nepPhotonicSublayer, tp.getTpId().getValue());
+            LOG.info("PHOTO NEP = {}", nodeIdNepTp);
             Name nepName = new NameBuilder()
                 .setValueName(nepPhotonicSublayer + "NodeEdgePoint")
-                .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                    tp.getTpId().getValue()))
+                .setValue(nodeIdNepTp)
                 .build();
-
-            List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
-            sclpqiList.add(
-                new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                    .setLayerProtocolQualifier(
-                        TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
-                            ? PHOTONICLAYERQUALIFIEROMS.VALUE
-                            : PHOTONICLAYERQUALIFIEROTS.VALUE)
-                    .setNumberOfCepInstances(Uint64.valueOf(1))
-                    .build());
             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
-                .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
-                    nepPhotonicSublayer, tp.getTpId().getValue()))
-                    .getBytes(Charset.forName("UTF-8"))).toString()))
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes(nodeIdNepTp.getBytes(Charset.forName("UTF-8"))).toString()))
                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
                 .setName(Map.of(nepName.key(), nepName))
-                .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
+                .setSupportedCepLayerProtocolQualifierInstances(
+                    new ArrayList<>(List.of(
+                        new SupportedCepLayerProtocolQualifierInstancesBuilder()
+                            .setLayerProtocolQualifier(
+                                TapiStringConstants.PHTNC_MEDIA_OMS.equals(nepPhotonicSublayer)
+                                    ? PHOTONICLAYERQUALIFIEROMS.VALUE
+                                    : PHOTONICLAYERQUALIFIEROTS.VALUE)
+                            .setNumberOfCepInstances(Uint64.valueOf(1))
+                            .build())))
                 .setDirection(Direction.BIDIRECTIONAL)
                 .setLinkPortRole(PortRole.SYMMETRIC)
-                .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName()))
-                .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName()))
+                .setAdministrativeState(this.tapiLink.setTapiAdminState(
+                    // Admin state common for all tps
+                    tp.augmentation(TerminationPoint1.class).getAdministrativeState().getName()))
+                .setOperationalState(this.tapiLink.setTapiOperationalState(
+                    // Oper state common for all tps
+                    tp.augmentation(TerminationPoint1.class).getOperationalState().getName()))
                 .setLifecycleState(LifecycleState.INSTALLED)
                 .build();
             onepMap.put(onep.key(), onep);
@@ -322,55 +310,50 @@ public class ConvertORTopoToTapiFullTopo {
         return onepMap;
     }
 
-    public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
+    public void convertXpdrToRdmLinks(
+            List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> xpdrRdmLinkList) {
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
         // LOG.info("Link list = {}", xpdrRdmLinkList.toString());
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-            .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
+        for (var link:xpdrRdmLinkList) {
             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.networks.network.Link oppositeLink = xpdrRdmLinkList.stream()
+                var oppositeLink = xpdrRdmLinkList.stream()
                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink())).findAny()
                     .orElse(null);
-
                 AdminStates oppLnkAdmState = null;
                 State oppLnkOpState = null;
                 if (oppositeLink != null) {
                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
                 }
-                String adminState =
-                    link.augmentation(Link1.class).getAdministrativeState() == null
-                        || oppLnkAdmState == null
-                    ? null
-                    : this.tapiLink.setTapiAdminState(
-                        link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
-                String operState =
-                    link.augmentation(Link1.class).getOperationalState() == null
-                        || oppLnkOpState == null
-                    ? null
-                    : this.tapiLink.setTapiOperationalState(
-                        link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
-
-                String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
-                    ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
-                    : link.getSource().getSourceNode().getValue();
-                String sourceTp = link.getSource().getSourceTp().getValue();
-                String sourceNodeQual = sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
-                    : TapiStringConstants.XPDR;
-                String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
-                    ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
-                    : link.getDestination().getDestNode().getValue();
-                String destTp = link.getDestination().getDestTp().getValue();
-                String destNodeQual = destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
-                    : TapiStringConstants.XPDR;
-                Link tapLink = this.tapiLink.createTapiLink(sourceNode, sourceTp, destNode, destTp,
-                    TapiStringConstants.OMS_XPDR_RDM_LINK, sourceNodeQual, destNodeQual,
-                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS, adminState,
-                    operState, Set.of(LayerProtocolName.PHOTONICMEDIA),
-                    Set.of(LayerProtocolName.PHOTONICMEDIA.getName()), this.tapiTopoUuid);
+                String sourceNode =
+                    link.getSource().getSourceNode().getValue().contains("ROADM")
+                        ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
+                        : link.getSource().getSourceNode().getValue();
+                String destNode =
+                    link.getDestination().getDestNode().getValue().contains("ROADM")
+                        ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
+                        : link.getDestination().getDestNode().getValue();
+                Link tapLink = this.tapiLink.createTapiLink(
+                    sourceNode, link.getSource().getSourceTp().getValue(),
+                    destNode, link.getDestination().getDestTp().getValue(),
+                    TapiStringConstants.OMS_XPDR_RDM_LINK,
+                    sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+                    destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA : TapiStringConstants.XPDR,
+                    TapiStringConstants.PHTNC_MEDIA_OTS, TapiStringConstants.PHTNC_MEDIA_OTS,
+                    //adminState,
+                    link.augmentation(Link1.class).getAdministrativeState() == null || oppLnkAdmState == null
+                        ? null
+                        : this.tapiLink.setTapiAdminState(
+                            link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName(),
+                    //operState,
+                    link.augmentation(Link1.class).getOperationalState() == null || oppLnkOpState == null
+                        ? null
+                        : this.tapiLink.setTapiOperationalState(
+                            link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName(),
+                    Set.of(LayerProtocolName.PHOTONICMEDIA), Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
+                    this.tapiTopoUuid);
                 linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
                 this.tapiLinks.put(tapLink.key(), tapLink);
             }
@@ -387,7 +370,6 @@ public class ConvertORTopoToTapiFullTopo {
         }
     }
 
-
     public void setTapiNodes(Map<NodeKey,
             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap) {
         this.tapiNodes.putAll(nodeMap);