Merge "Debug tool for openconfig proprietary extensions"
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToTapiFullTopo.java
index 023b229dc168b39666bb6bdc51efafb371619bd3..1974b482f78ca04d3739a8a4858705f84480c70c 100644 (file)
@@ -17,6 +17,7 @@ import java.util.UUID;
 import java.util.stream.Collectors;
 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
 import org.opendaylight.transportpce.tapi.TapiStringConstants;
+import org.opendaylight.transportpce.tapi.impl.TapiProvider;
 import org.opendaylight.transportpce.tapi.utils.TapiLink;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
@@ -40,6 +41,11 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.glob
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1Builder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepList;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
@@ -79,7 +85,7 @@ public class ConvertORTopoToTapiFullTopo {
     private Map<LinkKey, Link> tapiLinks;
     private Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSips;
     private final TapiLink tapiLink;
-    private static String topologicalMode;
+    private static String topologicalMode = TapiProvider.TOPOLOGICAL_MODE;
 
 
     public ConvertORTopoToTapiFullTopo(Uuid tapiTopoUuid, TapiLink tapiLink) {
@@ -88,9 +94,6 @@ public class ConvertORTopoToTapiFullTopo {
         this.tapiLinks = new HashMap<>();
         this.tapiSips = new HashMap<>();
         this.tapiLink = tapiLink;
-        if (topologicalMode == null) {
-            ConvertORTopoToTapiFullTopo.topologicalMode = "Full";
-        }
     }
 
     public void convertRdmToRdmLinks(
@@ -99,43 +102,50 @@ public class ConvertORTopoToTapiFullTopo {
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
         for (var link : rdmTordmLinkList) {
-            if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                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();
-                }
-
-                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.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,
-                    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());
-                tapiLinks.put(tapLink.key(), tapLink);
+            if (linksToNotConvert.contains(link.getLinkId().getValue())) {
+                continue;
+            }
+            var lnk1 = link.augmentation(Link1.class);
+            var lnk1OppLnk = lnk1.getOppositeLink();
+            var oppositeLink = rdmTordmLinkList.stream()
+                .filter(l -> l.getLinkId().equals(lnk1OppLnk))
+                .findAny().orElse(null);
+            AdminStates oppLnkAdmState = null;
+            State oppLnkOpState = null;
+            if (oppositeLink != null) {
+                oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
+                oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
             }
+            var linkSrc = link.getSource();
+            String linkSrcNodeValue = linkSrc.getSourceNode().getValue();
+            var linkDst = link.getDestination();
+            String linkDstNodeValue = linkDst.getDestNode().getValue();
+            var lnkAdmState = lnk1.getAdministrativeState();
+            var lnkOpState = lnk1.getOperationalState();
+            Link tapLink = this.tapiLink.createTapiLink(
+                String.join("-", linkSrcNodeValue.split("-")[0], linkSrcNodeValue.split("-")[1]),
+                linkSrc.getSourceTp().getValue(),
+                String.join("-", linkDstNodeValue.split("-")[0], linkDstNodeValue.split("-")[1]),
+                linkDst.getDestTp().getValue(),
+                TapiStringConstants.OMS_RDM_RDM_LINK,
+                TapiStringConstants.PHTNC_MEDIA,
+                TapiStringConstants.PHTNC_MEDIA,
+                TapiStringConstants.PHTNC_MEDIA_OTS,
+                TapiStringConstants.PHTNC_MEDIA_OTS,
+                //adminState,
+                lnkAdmState == null || oppLnkAdmState == null
+                    ? null : this.tapiLink.setTapiAdminState(lnkAdmState, oppLnkAdmState).getName(),
+                //operState,
+                lnkOpState == null || oppLnkOpState == null
+                    ? null : this.tapiLink.setTapiOperationalState(lnkOpState, oppLnkOpState).getName(),
+                Set.of(LayerProtocolName.PHOTONICMEDIA),
+                Set.of(LayerProtocolName.PHOTONICMEDIA.getName()),
+                this.tapiTopoUuid);
+            linksToNotConvert.add(lnk1OppLnk.getValue());
+            tapiLinks.put(tapLink.key(), tapLink);
+            Map<Map<String, String>, ConnectionEndPoint> cepMap = this.tapiLink.getCepMap();
+            LOG.debug("CONVERTTOFULL147, cepMap is {}", cepMap);
+            addCepToOnepAndNode(cepMap);
         }
     }
 
@@ -148,6 +158,51 @@ public class ConvertORTopoToTapiFullTopo {
         }
     }
 
+    private void addCepToOnepAndNode(Map<Map<String, String>, ConnectionEndPoint> cepMap) {
+
+        for (Map.Entry<Map<String, String>, ConnectionEndPoint> cepEntry : cepMap.entrySet()) {
+            String nepNodeId = cepEntry.getKey().entrySet().stream().findFirst().orElseThrow().getValue();
+            LOG.debug("CONVERTTOFULL165, Node UUID is {}", nepNodeId);
+            List<NodeKey> listKey = tapiNodes.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList());
+            //.forEach(Function.identity().toString());
+            LOG.debug("CONVERTTOFULL168, TapiNode Keys are {}", tapiNodes
+                .entrySet().stream()
+                .map(Map.Entry::getKey)
+                .collect(Collectors.toList()));
+            LOG.debug("CONVERTTOFULL172, TapiNode Keys are {}", tapiNodes
+                .entrySet().stream()
+                .map(nep -> nep.getValue().getName().toString())
+                .collect(Collectors.toList()));
+            if (!listKey.toString().contains(nepNodeId)) {
+                LOG.info("ConvertToFullLINE178, ListKey {} of TapiNodes does not contain NodeUuid {}",
+                    listKey, nepNodeId);
+            }
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node = tapiNodes
+                .entrySet().stream()
+                .filter(theNode -> theNode.getKey().getUuid().toString().equals(nepNodeId))
+                .map(Map.Entry::getValue).findFirst().orElseThrow();
+            var onepMap = node.getOwnedNodeEdgePoint();
+            OwnedNodeEdgePoint ownedNep = onepMap.entrySet().stream()
+                .filter(onep -> onep.getKey().getUuid().toString()
+                    .equals(cepEntry.getKey().entrySet().stream().findFirst().orElseThrow().getKey()))
+                .map(Map.Entry::getValue).findFirst().orElseThrow();
+            CepList cepList = new CepListBuilder()
+                .setConnectionEndPoint(Map.of(cepEntry.getValue().key(), cepEntry.getValue()))
+                .build();
+            OwnedNodeEdgePoint1 onep1Bldr = new OwnedNodeEdgePoint1Builder().setCepList(cepList).build();
+            OwnedNodeEdgePoint newOnep = new OwnedNodeEdgePointBuilder(ownedNep)
+                    .addAugmentation(onep1Bldr)
+                    .build();
+            onepMap.put(newOnep.key(), newOnep);
+            var newNode = new  org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology
+                    .NodeBuilder(node)
+                .setOwnedNodeEdgePoint(onepMap)
+                .build();
+            this.tapiNodes.put(newNode.key(), newNode);
+            LOG.debug("CONVERTTOFULL201, successfully create node {} with CepList {} ", newNode.getName(), cepList);
+        }
+    }
+
     private void convertRoadmNodeFull(Node roadm, Network openroadmTopo) {
         this.ietfNodeId = roadm.getNodeId().getValue();
         this.ietfNodeType = roadm.augmentation(
@@ -163,30 +218,28 @@ public class ConvertORTopoToTapiFullTopo {
         int numSips = 0;
         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
         for (Node node:nodeList) {
+            String nodeId = node.getNodeId().getValue();
             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);
+                LOG.debug("Abstracted node {} is not part of {}", nodeId, 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) {
-                LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
-                    node.getNodeId().getValue());
+            var node1 = node.augmentation(
+                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
+            if (node.augmentation(Node1.class) == null && node1 == null) {
+                LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated", nodeId);
                 continue;
             }
             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());
+            var node1TpValues = node1.getTerminationPoint().values();
+            LOG.info("TPs of node: {}", node1TpValues);
             switch (nodeType.getIntValue()) {
                 case 11:
                     LOG.info("Degree node");
                     // Get only external TPs of the degree
-                    List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
+                    List<TerminationPoint> degPortList = node1TpValues.stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
                                 == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
@@ -197,16 +250,16 @@ public class ConvertORTopoToTapiFullTopo {
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Degree port List: {}", degPortList.toString());
                     // TODO: deg port could be sip. e.g. MDONS
-                    oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), degPortList, false,
-                        TapiStringConstants.PHTNC_MEDIA_OTS));
-                    oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), degPortList, false,
-                        TapiStringConstants.PHTNC_MEDIA_OMS));
+                    oneplist.putAll(populateNepsForRdmNode(
+                        nodeId, degPortList, false, TapiStringConstants.PHTNC_MEDIA_OTS));
+                    oneplist.putAll(populateNepsForRdmNode(
+                        nodeId, degPortList, false, TapiStringConstants.PHTNC_MEDIA_OMS));
                     numNeps += degPortList.size() * 2;
                     break;
                 case 12:
                     LOG.info("SRG node");
                     // Get only external TPs of the srg
-                    List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
+                    List<TerminationPoint> srgPortList = node1TpValues.stream()
                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
                                 == OpenroadmTpType.SRGTXRXPP.getIntValue()
                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
@@ -216,8 +269,9 @@ public class ConvertORTopoToTapiFullTopo {
                         .collect(Collectors.toList());
                     // Convert TP List in NEPs and put it in onepl
                     LOG.info("Srg port List: {}", srgPortList);
-                    oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), srgPortList, true,
-                        TapiStringConstants.PHTNC_MEDIA_OTS));
+                    oneplist.putAll(populateNepsForRdmNode(
+                        nodeId, srgPortList, true, TapiStringConstants.PHTNC_MEDIA_OTS));
+
                     numNeps += srgPortList.size();
                     numSips += srgPortList.size();
                     break;
@@ -227,9 +281,9 @@ public class ConvertORTopoToTapiFullTopo {
         }
         // create tapi Node
         // UUID
-        String nodeIdPhMed = String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA);
+        String nodeIdPhMed = String.join("+", this.ietfNodeId, 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);
+        LOG.info("Creation of PHOTONIC node for {}, of Uuid {}", this.ietfNodeId, nodeUuid);
         // Names
         Name nodeNames =  new NameBuilder().setValueName("roadm node name").setValue(nodeIdPhMed).build();
         Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
@@ -248,12 +302,13 @@ public class ConvertORTopoToTapiFullTopo {
         var roadmNode = createRoadmTapiNode(nodeUuid,
             Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist, "Full");
         // 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 {} should have {} NEPs and {} SIPs", TapiStringConstants.RDM_INFRA, numNeps, numSips);
         LOG.info("ROADM node {} has {} NEPs and {} SIPs",
-            roadm.getNodeId().getValue(),
+            TapiStringConstants.RDM_INFRA,
             roadmNode.nonnullOwnedNodeEdgePoint().values().size(),
             roadmNode.nonnullOwnedNodeEdgePoint().values().stream()
-                .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
+                .filter(nep -> nep.getMappedServiceInterfacePoint() != null)
+                .count());
         tapiNodes.put(roadmNode.key(), roadmNode);
     }
 
@@ -268,20 +323,22 @@ public class ConvertORTopoToTapiFullTopo {
         int numSips = 0;
         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
         for (Node node:nodeList) {
-            var node1 = node.augmentation(
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
-            if (node.augmentation(Node1.class) == null && node1 == null) {
+            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) {
                 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();
+            OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
+                .org.openroadm.common.network.rev230526.Node1.class).getNodeType();
             if (nodeType.getIntValue() != 11) {
                 // Only consider ROADMS SRG Nodes
                 continue;
             }
+            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);
             LOG.debug("Handling SRG node in Topology abstraction {}", node.getNodeId().toString());
             // Get only external TPs of the srg
             List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
@@ -303,17 +360,17 @@ public class ConvertORTopoToTapiFullTopo {
         LOG.info("abstraction of the ROADM infrastructure towards a photonic node");
         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(
             TapiStringConstants.RDM_INFRA.getBytes(Charset.forName("UTF-8"))).toString());
-        Name nodeName =
-            new NameBuilder().setValueName("roadm node name").setValue(TapiStringConstants.RDM_INFRA).build();
-        Name nameNodeType =
-            new NameBuilder().setValueName("Node Type").setValue(OpenroadmNodeType.ROADM.getName()).build();
+        Name nodeName =  new NameBuilder().setValueName("roadm node name").setValue(TapiStringConstants.RDM_INFRA)
+            .build();
+        Name nameNodeType = new NameBuilder().setValueName("Node Type")
+            .setValue(OpenroadmNodeType.ROADM.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(nodeName.key(), nodeName, nameNodeType.key(), nameNodeType),
-                layerProtocols, oneMap, "Abstracted");
+            layerProtocols, oneMap, "Abstracted");
         // TODO add states corresponding to device config
         LOG.info("ROADM node {} should have {} NEPs and {} SIPs", TapiStringConstants.RDM_INFRA, numNeps, numSips);
         LOG.info("ROADM node {} has {} NEPs and {} SIPs", TapiStringConstants.RDM_INFRA,
@@ -346,11 +403,18 @@ public class ConvertORTopoToTapiFullTopo {
             .build();
 
         var tapiFactory = new ConvertORToTapiTopology(this.tapiTopoUuid);
-        String choosenMode = topoMode.equals("Full") ? "Full" : "Abstracted";
-        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap =
-            tapiFactory.createAllNodeRuleGroupForRdmNode(choosenMode, nodeUuid, this.ietfNodeId, onepMap.values());
-        Map<InterRuleGroupKey, InterRuleGroup> interRuleGroupMap =
-            tapiFactory.createInterRuleGroupForRdmNode(choosenMode, nodeUuid, this.ietfNodeId,
+        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap
+            = tapiFactory.createAllNodeRuleGroupForRdmNode(
+                topoMode.equals("Full")
+                    ? "Full"
+                    : "Abstracted",
+                nodeUuid, this.ietfNodeId, onepMap.values());
+        Map<InterRuleGroupKey, InterRuleGroup> interRuleGroupMap
+            = tapiFactory.createInterRuleGroupForRdmNode(
+                topoMode.equals("Full")
+                    ? "Full"
+                    : "Abstracted",
+                nodeUuid, this.ietfNodeId,
                 nodeRuleGroupMap.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toList()));
         return new NodeBuilder()
             .setUuid(nodeUuid)
@@ -377,16 +441,16 @@ public class ConvertORTopoToTapiFullTopo {
             .build();
     }
 
-    public Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(String nodeId,
-            List<TerminationPoint> tpList, boolean withSip, String nepPhotonicSublayer) {
+    public Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(
+            String nodeId, List<TerminationPoint> tpList, boolean withSip, String nepPhotonicSublayer) {
         // create neps for MC and and Photonic Media OTS/OMS
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
         for (TerminationPoint tp:tpList) {
+            String tpId = tp.getTpId().getValue();
             // Admin and oper state common for all tps
             OpenroadmTpType tpType = tp.augmentation(TerminationPoint1.class).getTpType();
             // PHOTONIC MEDIA nep
-            LOG.debug("PHOTO NEP = {}", String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                tp.getTpId().getValue()));
+            LOG.debug("PHOTO NEP = {}", String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId));
             SupportedCepLayerProtocolQualifierInstancesBuilder sclpqiBd =
                 new SupportedCepLayerProtocolQualifierInstancesBuilder()
                     .setNumberOfCepInstances(Uint64.valueOf(1));
@@ -407,7 +471,36 @@ public class ConvertORTopoToTapiFullTopo {
                     break;
             }
             //List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>(List.of(sclpqiBd.build()));
-            OwnedNodeEdgePointBuilder onepBd = new OwnedNodeEdgePointBuilder();
+
+//          OwnedNodeEdgePointBuilder onepBd = new OwnedNodeEdgePointBuilder();
+
+
+            AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
+            State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
+            Name nepName = new NameBuilder()
+                .setValueName(nepPhotonicSublayer + "NodeEdgePoint")
+                .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId))
+                .build();
+            OwnedNodeEdgePointBuilder onepBdd = new OwnedNodeEdgePointBuilder()
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId))
+                    .getBytes(Charset.forName("UTF-8"))).toString()))
+                .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
+                .setName(Map.of(nepName.key(), nepName))
+                .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()))
+                .setLifecycleState(LifecycleState.INSTALLED);
+
             if (!nepPhotonicSublayer.equals(TapiStringConstants.MC)
                     && !nepPhotonicSublayer.equals(TapiStringConstants.OTSI_MC)) {
                 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(this.tapiTopoUuid);
@@ -421,17 +514,16 @@ public class ConvertORTopoToTapiFullTopo {
                     case SRGTXRXPP:
                         usedFreqMap = tapiFactory.getPPUsedWavelength(tp);
                         if (usedFreqMap == null || usedFreqMap.isEmpty()) {
-                            availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E09,
-                                GridConstant.START_EDGE_FREQUENCY * 1E09
-                                + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06);
+                            availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E12,
+                                GridConstant.START_EDGE_FREQUENCY * 1E12
+                                + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E09);
                         } else {
                             LOG.debug("EnteringLOOPcreateOTSiMC & MC with usedFreqMap non empty {} NEP {} for Node {}",
-                                usedFreqMap.toString(), String.join("+", this.ietfNodeId, nepPhotonicSublayer,
-                                tp.getTpId().getValue()), nodeId);
-                            onepMap.putAll(populateNepsForRdmNode(nodeId, new ArrayList<>(List.of(tp)),
-                                true, TapiStringConstants.MC));
-                            onepMap.putAll(populateNepsForRdmNode(nodeId, new ArrayList<>(List.of(tp)),
-                                true, TapiStringConstants.OTSI_MC));
+                                usedFreqMap, String.join("+", this.ietfNodeId, nepPhotonicSublayer, tpId), nodeId);
+                            onepMap.putAll(populateNepsForRdmNode(
+                                nodeId, new ArrayList<>(List.of(tp)), true, TapiStringConstants.MC));
+                            onepMap.putAll(populateNepsForRdmNode(
+                                nodeId, new ArrayList<>(List.of(tp)), true, TapiStringConstants.OTSI_MC));
                         }
                         break;
                     case DEGREERXTTP:
@@ -444,36 +536,12 @@ public class ConvertORTopoToTapiFullTopo {
                         break;
                 }
                 LOG.debug("calling add Photonic NEP spec for Roadm");
-                onepBd = tapiFactory.addPhotSpecToRoadmOnep(nodeId, usedFreqMap, availableFreqMap, onepBd,
-                    nepPhotonicSublayer);
+                onepBdd = tapiFactory.addPhotSpecToRoadmOnep(
+                    nodeId, usedFreqMap, availableFreqMap, onepBdd, String.join("+", nodeId, nepPhotonicSublayer));
             }
-            AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
-            State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
-            Name nepName = new NameBuilder()
-                .setValueName(nepPhotonicSublayer + "NodeEdgePoint")
-                .setValue(String.join("+", this.ietfNodeId, nepPhotonicSublayer, tp.getTpId().getValue()))
-                .build();
-            OwnedNodeEdgePoint onep = onepBd
-                .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
-                    nepPhotonicSublayer, tp.getTpId().getValue()))
-                        .getBytes(Charset.forName("UTF-8"))).toString()))
-                .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
-                .setName(Map.of(nepName.key(), nepName))
-                .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()))
-                .setLifecycleState(LifecycleState.INSTALLED)
-                .build();
+
+            OwnedNodeEdgePoint onep = onepBdd.build();
+            LOG.debug("ConvertORToTapiTopology.populateNepsForRdmNode onep is {}", onep);
             onepMap.put(onep.key(), onep);
         }
         return onepMap;
@@ -486,46 +554,47 @@ public class ConvertORTopoToTapiFullTopo {
         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
         LOG.debug("Link list = {}", xpdrRdmLinkList);
         for (var link:xpdrRdmLinkList) {
-            if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
-                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 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);
+            if (linksToNotConvert.contains(link.getLinkId().getValue())) {
+                continue;
+            }
+            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 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);
         }
     }