Merge "Revert "Device renderer functional tests intermediate rate""
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / topology / ConvertORTopoToTapiFullTopo.java
1 /*
2  * Copyright © 2021 Nokia.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.tapi.topology;
9
10 import java.nio.charset.Charset;
11 import java.util.ArrayList;
12 import java.util.Arrays;
13 import java.util.Collection;
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.Set;
19 import java.util.UUID;
20 import java.util.stream.Collectors;
21 import org.opendaylight.transportpce.tapi.TapiStringConstants;
22 import org.opendaylight.transportpce.tapi.utils.TapiLink;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
42 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
43 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPEGigE;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU0;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
91 import org.opendaylight.yangtools.yang.common.Uint16;
92 import org.slf4j.Logger;
93 import org.slf4j.LoggerFactory;
94
95
96 public class ConvertORTopoToTapiFullTopo {
97
98     private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToTapiFullTopo.class);
99     private String ietfNodeId;
100     private OpenroadmNodeType ietfNodeType;
101     private AdminStates ietfNodeAdminState;
102     private State ietfNodeOperState;
103     private List<TerminationPoint> oorClientPortList;
104     private List<TerminationPoint> oorNetworkPortList;
105     private OduSwitchingPools oorOduSwitchingPool;
106     private Uuid tapiTopoUuid;
107     private Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
108         tapiNodes;
109     private Map<LinkKey, Link> tapiLinks;
110     private Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSips;
111     private Map<String, Uuid> uuidMap;
112     private final TapiLink tapiLink;
113
114
115     public ConvertORTopoToTapiFullTopo(Uuid tapiTopoUuid, TapiLink tapiLink) {
116         this.tapiTopoUuid = tapiTopoUuid;
117         this.tapiNodes = new HashMap<>();
118         this.tapiLinks = new HashMap<>();
119         this.uuidMap = new HashMap<>();
120         this.tapiSips = new HashMap<>();
121         this.tapiLink = tapiLink;
122     }
123
124     public void convertNode(Node ietfNode, List<String> networkPorts) {
125         this.ietfNodeId = ietfNode.getNodeId().getValue();
126         if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
127                 == null) {
128             return;
129         }
130         this.ietfNodeType = ietfNode.augmentation(
131             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class).getNodeType();
132         this.ietfNodeAdminState = ietfNode.augmentation(
133             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
134                 .getAdministrativeState();
135         this.ietfNodeOperState = ietfNode.augmentation(
136             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
137                 .getOperationalState();
138         this.oorNetworkPortList = ietfNode.augmentation(
139             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
140                 .getTerminationPoint().values().stream()
141                 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
142                     == OpenroadmTpType.XPONDERNETWORK.getIntValue()
143                     && networkPorts.contains(tp.getTpId().getValue()))
144                 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
145                 .collect(Collectors.toList());
146         if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
147             this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
148                 .values().stream().findFirst().get();
149             this.oorClientPortList = ietfNode.augmentation(
150                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
151                     .getTerminationPoint().values().stream()
152                     .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
153                         == OpenroadmTpType.XPONDERCLIENT.getIntValue())
154                     .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
155                     .collect(Collectors.toList());
156         } else {
157             this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
158             List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
159                 .flatMap(nbl -> nbl.getTpList().stream())
160                 .collect(Collectors.toList());
161             this.oorClientPortList = ietfNode.augmentation(
162                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
163                     .getTerminationPoint().values().stream()
164                     .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
165                         == OpenroadmTpType.XPONDERCLIENT.getIntValue() && tpList.contains(tp.getTpId()))
166                     .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
167                     .collect(Collectors.toList());
168             this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
169         }
170
171         // node creation [DSR/ODU]
172         LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
173         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
174             TapiStringConstants.DSR)).getBytes(Charset.forName("UTF-8"))).toString());
175         this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.DSR), nodeUuid);
176         Name nameDsrNode = new NameBuilder().setValueName("dsr/odu node name").setValue(
177             String.join("+", this.ietfNodeId, TapiStringConstants.DSR)).build();
178         Name nameNodeType = new NameBuilder().setValueName("Node Type")
179             .setValue(this.ietfNodeType.getName()).build();
180         List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, LayerProtocolName.ODU);
181         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
182             .Node dsrNode = createTapiNode(Map.of(nameDsrNode.key(), nameDsrNode, nameNodeType.key(), nameNodeType),
183             dsrLayerProtocols);
184         LOG.info("DSR Node {} should have {} NEPs and {} SIPs", this.ietfNodeId,
185             this.oorClientPortList.size() + 2 * this.oorNetworkPortList.size(),
186             this.oorClientPortList.size() + this.oorNetworkPortList.size());
187         LOG.info("DSR Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
188             dsrNode.getOwnedNodeEdgePoint().values().size(), dsrNode.getOwnedNodeEdgePoint().values().stream()
189                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
190         tapiNodes.put(dsrNode.key(), dsrNode);
191
192         // node creation [otsi]
193         LOG.info("creation of an OTSi node for {}", this.ietfNodeId);
194         nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, TapiStringConstants.OTSI))
195             .getBytes(Charset.forName("UTF-8"))).toString());
196         this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI), nodeUuid);
197         Name nameOtsiNode =  new NameBuilder().setValueName("otsi node name").setValue(
198             String.join("+", this.ietfNodeId, TapiStringConstants.OTSI)).build();
199         List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
200         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
201             .Node otsiNode = createTapiNode(Map.of(nameOtsiNode.key(), nameOtsiNode, nameNodeType.key(), nameNodeType),
202             otsiLayerProtocols);
203         LOG.info("OTSi Node {} should have {} NEPs and {} SIPs", this.ietfNodeId, 3 * this.oorNetworkPortList.size(),
204             this.oorNetworkPortList.size());
205         LOG.info("OTSi Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
206             otsiNode.getOwnedNodeEdgePoint().values().size(), otsiNode.getOwnedNodeEdgePoint().values().stream()
207                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
208         tapiNodes.put(otsiNode.key(), otsiNode);
209
210         // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
211         LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
212         createTapiTransitionalLinks();
213     }
214
215     public void convertRdmToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
216             .ietf.network.topology.rev180226.networks.network.Link> rdmTordmLinkList) {
217         List<String> linksToNotConvert = new ArrayList<>();
218         LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
219         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
220             .Link link : rdmTordmLinkList) {
221             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
222                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
223                         .ietf.network.topology.rev180226.networks.network.Link oppositeLink = rdmTordmLinkList.stream()
224                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink()))
225                     .findAny().orElse(null);
226
227                 AdminStates oppLnkAdmState = null;
228                 State oppLnkOpState = null;
229                 if (oppositeLink != null) {
230                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
231                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
232                 }
233                 String adminState =
234                     link.augmentation(Link1.class).getAdministrativeState() == null
235                         || oppLnkAdmState == null
236                     ? null
237                     : this.tapiLink.setTapiAdminState(
238                         link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
239                 String operState =
240                     link.augmentation(Link1.class).getOperationalState() == null
241                         || oppLnkOpState == null
242                     ? null
243                     : this.tapiLink.setTapiOperationalState(
244                         link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
245
246                 Link tapLink = this.tapiLink.createTapiLink(String.join("-",
247                         link.getSource().getSourceNode().getValue().split("-")[0],
248                         link.getSource().getSourceNode().getValue().split("-")[1]),
249                     link.getSource().getSourceTp().getValue(), String.join("-",
250                         link.getDestination().getDestNode().getValue().split("-")[0],
251                         link.getDestination().getDestNode().getValue().split("-")[1]),
252                     link.getDestination().getDestTp().getValue(), TapiStringConstants.OMS_RDM_RDM_LINK,
253                     TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA,
254                     TapiStringConstants.PHTNC_MEDIA, adminState, operState, List.of(LayerProtocolName.PHOTONICMEDIA),
255                     List.of(LayerProtocolName.PHOTONICMEDIA.getName()), this.tapiTopoUuid);
256                 linksToNotConvert.add(link
257                     .augmentation(Link1.class)
258                     .getOppositeLink().getValue());
259                 tapiLinks.put(tapLink.key(), tapLink);
260             }
261         }
262     }
263
264     public void convertRoadmNode(Node roadm, Network openroadmTopo) {
265         this.ietfNodeId = roadm.getNodeId().getValue();
266         this.ietfNodeType = roadm.augmentation(
267             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class).getNodeType();
268         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
269         // 1. Get degree and srg nodes to map TPs into NEPs
270         if (openroadmTopo.getNode() == null) {
271             LOG.warn("Openroadm-topology is null.");
272             return;
273         }
274         int numNeps = 0;
275         int numSips = 0;
276         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
277         for (Node node:nodeList) {
278             if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
279                 .equals(this.ietfNodeId))) {
280                 LOG.warn("Abstracted node {} is not part of {}",
281                     node.getNodeId().getValue(), this.ietfNodeId);
282                 continue;
283             }
284             if (node.augmentation(Node1.class) == null
285                 && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
286                 .ietf.network.topology.rev180226.Node1.class) == null) {
287                 LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
288                     node.getNodeId().getValue());
289                 continue;
290             }
291             OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
292                 .org.openroadm.common.network.rev200529.Node1.class).getNodeType();
293             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
294                 node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
295                     .ietf.network.topology.rev180226.Node1.class);
296             LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
297             switch (nodeType.getIntValue()) {
298                 case 11:
299                     LOG.info("Degree node");
300                     // Get only external TPs of the degree
301                     List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
302                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
303                             == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
304                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
305                             == OpenroadmTpType.DEGREERXTTP.getIntValue()
306                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
307                             == OpenroadmTpType.DEGREETXTTP.getIntValue())
308                         .collect(Collectors.toList());
309                     // Convert TP List in NEPs and put it in onepl
310                     LOG.info("Degree port List: {}", degPortList);
311                     // TODO: deg port could be sip. e.g. MDONS
312                     oneplist.putAll(populateNepsForRdmNode(degPortList, false));
313                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), degPortList, false));
314                     numNeps += degPortList.size() * 3;
315                     break;
316                 case 12:
317                     LOG.info("SRG node");
318                     // Get only external TPs of the srg
319                     List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
320                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
321                             == OpenroadmTpType.SRGTXRXPP.getIntValue()
322                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
323                             == OpenroadmTpType.SRGRXPP.getIntValue()
324                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
325                             == OpenroadmTpType.SRGTXPP.getIntValue())
326                         .collect(Collectors.toList());
327                     // Convert TP List in NEPs and put it in onepl
328                     LOG.info("Srg port List: {}", srgPortList);
329                     oneplist.putAll(populateNepsForRdmNode(srgPortList, true));
330                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), srgPortList, true));
331                     numNeps += srgPortList.size() * 3;
332                     numSips += srgPortList.size();
333                     break;
334                 default:
335                     LOG.error("Node {} tyoe not supported", nodeType.getName());
336             }
337         }
338         // create tapi Node
339         // UUID
340         LOG.info("Creation of PHOTONIC node for {}", roadm.getNodeId().getValue());
341         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
342             TapiStringConstants.PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
343         // Names
344         Name nodeNames =  new NameBuilder().setValueName("roadm node name")
345             .setValue(String.join("+", roadm.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA)).build();
346         Name nameNodeType = new NameBuilder().setValueName("Node Type")
347             .setValue(this.ietfNodeType.getName()).build();
348         // Protocol Layer
349         List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
350         // Build tapi node
351         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
352             .Node roadmNode = createRoadmTapiNode(nodeUuid,
353             Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType), layerProtocols, oneplist);
354         // TODO add states corresponding to device config
355         LOG.info("ROADM node {} should have {} NEPs and {} SIPs", roadm.getNodeId().getValue(), numNeps, numSips);
356         LOG.info("ROADM node {} has {} NEPs and {} SIPs", roadm.getNodeId().getValue(),
357             roadmNode.getOwnedNodeEdgePoint().values().size(),
358             roadmNode.getOwnedNodeEdgePoint().values().stream()
359                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
360
361         tapiNodes.put(roadmNode.key(), roadmNode);
362     }
363
364     private OduSwitchingPools createOduSwitchingPoolForTp100G() {
365         Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
366         int count = 1;
367         for (TerminationPoint tp : this.oorNetworkPortList) {
368             TpId tpid1 = tp.getTpId();
369             TpId tpid2 = new TpId(tp.augmentation(
370                 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.TerminationPoint1.class)
371                 .getAssociatedConnectionMapPort());
372             List<TpId> tpList = new ArrayList<>();
373             tpList.add(tpid1);
374             tpList.add(tpid2);
375             NonBlockingList nbl = new NonBlockingListBuilder()
376                 .setNblNumber(Uint16.valueOf(count))
377                 .setTpList(tpList)
378                 .build();
379             nblMap.put(nbl.key(), nbl);
380             count++;
381         }
382         return new OduSwitchingPoolsBuilder()
383             .setNonBlockingList(nblMap)
384             .setSwitchingPoolNumber(Uint16.valueOf(1))
385             .build();
386     }
387
388     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
389             createTapiNode(Map<NameKey, Name> nodeNames, List<LayerProtocolName> layerProtocols) {
390         Uuid nodeUuid = null;
391         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
392         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
393         Map<RuleKey, Rule> ruleList = new HashMap<>();
394         Rule rule = new RuleBuilder()
395             .setLocalId("forward")
396             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
397             .setRuleType(RuleType.FORWARDING)
398             .build();
399         ruleList.put(rule.key(), rule);
400         if (layerProtocols.contains(LayerProtocolName.DSR)) {
401             nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, ruleList);
402         } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
403             nodeUuid = getNodeUuid4Photonic(onepl, nodeRuleGroupList, ruleList);
404         } else {
405             LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(nodeNames.keySet().iterator().next())
406                 .getValueName(), nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
407         }
408         // Empty random creation of mandatory fields for avoiding errors....
409         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
410             .setCostAlgorithm("Restricted Shortest Path - RSP")
411             .setCostName("HOP_COUNT")
412             .setCostValue("12345678")
413             .build();
414         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
415             .setFixedLatencyCharacteristic("12345678")
416             .setQueingLatencyCharacteristic("12345678")
417             .setJitterCharacteristic("12345678")
418             .setWanderCharacteristic("12345678")
419             .setTrafficPropertyName("FIXED_LATENCY")
420             .build();
421         return new NodeBuilder()
422             .setUuid(nodeUuid)
423             .setName(nodeNames)
424             .setLayerProtocolName(layerProtocols)
425             .setAdministrativeState(this.tapiLink.setTapiAdminState(this.ietfNodeAdminState.getName()))
426             .setOperationalState(this.tapiLink.setTapiOperationalState(this.ietfNodeOperState.getName()))
427             .setLifecycleState(LifecycleState.INSTALLED)
428             .setOwnedNodeEdgePoint(onepl)
429             .setNodeRuleGroup(nodeRuleGroupList)
430             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
431             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
432             .setErrorCharacteristic("error")
433             .setLossCharacteristic("loss")
434             .setRepeatDeliveryCharacteristic("repeat delivery")
435             .setDeliveryOrderCharacteristic("delivery order")
436             .setUnavailableTimeCharacteristic("unavailable time")
437             .setServerIntegrityProcessCharacteristic("server integrity process")
438             .build();
439     }
440
441     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
442             createRoadmTapiNode(Uuid nodeUuid, Map<NameKey, Name> nameMap, List<LayerProtocolName> layerProtocols,
443                         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
444         // Empty random creation of mandatory fields for avoiding errors....
445         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
446             .setCostAlgorithm("Restricted Shortest Path - RSP")
447             .setCostName("HOP_COUNT")
448             .setCostValue("12345678")
449             .build();
450         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
451             .setFixedLatencyCharacteristic("12345678")
452             .setQueingLatencyCharacteristic("12345678")
453             .setJitterCharacteristic("12345678")
454             .setWanderCharacteristic("12345678")
455             .setTrafficPropertyName("FIXED_LATENCY")
456             .build();
457         return new NodeBuilder()
458             .setUuid(nodeUuid)
459             .setName(nameMap)
460             .setLayerProtocolName(layerProtocols)
461             .setAdministrativeState(AdministrativeState.UNLOCKED)
462             .setOperationalState(OperationalState.ENABLED)
463             .setLifecycleState(LifecycleState.INSTALLED)
464             .setOwnedNodeEdgePoint(oneplist)
465             .setNodeRuleGroup(createNodeRuleGroupForRdmNode(nodeUuid, oneplist.values()))
466             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
467             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
468             .setErrorCharacteristic("error")
469             .setLossCharacteristic("loss")
470             .setRepeatDeliveryCharacteristic("repeat delivery")
471             .setDeliveryOrderCharacteristic("delivery order")
472             .setUnavailableTimeCharacteristic("unavailable time")
473             .setServerIntegrityProcessCharacteristic("server integrity process")
474             .build();
475     }
476
477     private Uuid getNodeUuid4Photonic(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
478                                       Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
479                                       Map<RuleKey, Rule> ruleList) {
480         Uuid nodeUuid;
481         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI));
482         // iNep creation on otsi node
483         for (int i = 0; i < oorNetworkPortList.size(); i++) {
484             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI,
485                 oorNetworkPortList.get(i).getTpId().getValue()));
486             Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
487                 (String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI,
488                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
489                 .toString());
490             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI,
491                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
492             Name onedName = new NameBuilder()
493                 .setValueName("iNodeEdgePoint")
494                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI,
495                     oorNetworkPortList.get(i).getTpId().getValue()))
496                 .build();
497
498             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
499                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
500                 String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI));
501             onepl.put(onep.key(), onep);
502         }
503         // eNep creation on otsi node
504         for (int i = 0; i < oorNetworkPortList.size(); i++) {
505             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI,
506                 oorNetworkPortList.get(i).getTpId().getValue()));
507             Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
508                 (String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI,
509                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
510                 .toString());
511             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI,
512                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
513             Name onedName = new NameBuilder()
514                 .setValueName("eNodeEdgePoint")
515                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI,
516                     oorNetworkPortList.get(i).getTpId().getValue()))
517                 .build();
518
519             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
520                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
521                 String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI));
522             onepl.put(onep.key(), onep);
523         }
524         // Photonic Media Nep creation on otsi node
525         for (int i = 0; i < oorNetworkPortList.size(); i++) {
526             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
527                 oorNetworkPortList.get(i).getTpId().getValue()));
528             Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
529                 (String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
530                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
531                 .toString());
532             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
533                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
534             Name onedName = new NameBuilder()
535                 .setValueName("PhotMedNodeEdgePoint")
536                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
537                     oorNetworkPortList.get(i).getTpId().getValue()))
538                 .build();
539
540             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
541                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
542                 String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA));
543             onepl.put(onep.key(), onep);
544         }
545         // create NodeRuleGroup
546         int count = 1;
547         LOG.info("OTSi switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
548         for (TerminationPoint tp : this.oorNetworkPortList) {
549             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
550                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
551                 nepList = new HashMap<>();
552             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
553                 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
554                 .node.rule.group.NodeEdgePointBuilder()
555                 .setTopologyUuid(tapiTopoUuid)
556                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI)))
557                 .setNodeEdgePointUuid(
558                     this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.I_OTSI,
559                         tp.getTpId().getValue())))
560                 .build();
561             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
562                 .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
563                 .node.rule.group.NodeEdgePointBuilder()
564                 .setTopologyUuid(tapiTopoUuid)
565                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI)))
566                 .setNodeEdgePointUuid(
567                     this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.E_OTSI,
568                         tp.getTpId().getValue())))
569                 .build();
570             nepList.put(inep.key(), inep);
571             nepList.put(enep.key(), enep);
572             // Empty random creation of mandatory fields for avoiding errors....
573             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
574                 .setCostAlgorithm("Restricted Shortest Path - RSP")
575                 .setCostName("HOP_COUNT")
576                 .setCostValue("12345678")
577                 .build();
578             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
579                 .setFixedLatencyCharacteristic("12345678")
580                 .setQueingLatencyCharacteristic("12345678")
581                 .setJitterCharacteristic("12345678")
582                 .setWanderCharacteristic("12345678")
583                 .setTrafficPropertyName("FIXED_LATENCY")
584                 .build();
585             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
586                 .setRiskCharacteristicName("risk characteristic")
587                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
588                 .build();
589             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
590                 .setUuid(new Uuid(
591                     UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
592                         .toString()))
593                 .setRule(ruleList)
594                 .setNodeEdgePoint(nepList)
595                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
596                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
597                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
598                 .build();
599             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
600             count++;
601         }
602         return nodeUuid;
603     }
604
605     private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
606                                  Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
607         Uuid nodeUuid;
608         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, TapiStringConstants.DSR));
609         // client nep creation on DSR node
610         for (int i = 0; i < oorClientPortList.size(); i++) {
611             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
612                 oorClientPortList.get(i).getTpId().getValue()));
613             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
614                 (String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
615                     oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
616             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
617                     oorClientPortList.get(i).getTpId().getValue()), nepUuid);
618             NameBuilder nameBldr = new NameBuilder().setValue(
619                 String.join("+", this.ietfNodeId, TapiStringConstants.DSR,
620                     oorClientPortList.get(i).getTpId().getValue()));
621             Name name;
622             if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
623                 name = nameBldr.setValueName("100G-tpdr").build();
624             } else {
625                 name = nameBldr.setValueName("NodeEdgePoint_C").build();
626             }
627
628             OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
629                 LayerProtocolName.DSR, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
630                     TapiStringConstants.DSR));
631             onepl.put(onep.key(), onep);
632         }
633         // network nep creation on I_ODU node
634         for (int i = 0; i < oorNetworkPortList.size(); i++) {
635             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
636                 oorNetworkPortList.get(i).getTpId().getValue()));
637             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
638                 (String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
639                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
640             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
641                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid);
642             Name onedName = new NameBuilder()
643                 .setValueName("iNodeEdgePoint_N")
644                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU,
645                     oorNetworkPortList.get(i).getTpId().getValue()))
646                 .build();
647
648             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
649                 LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId,
650                     TapiStringConstants.I_ODU));
651             onepl.put(onep.key(), onep);
652         }
653         // network nep creation on E_ODU node
654         for (int i = 0; i < oorClientPortList.size(); i++) {
655             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
656                 oorClientPortList.get(i).getTpId().getValue()));
657             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
658                 (String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
659                     oorClientPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
660             this.uuidMap.put(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
661                 oorClientPortList.get(i).getTpId().getValue()), nepUuid);
662             Name onedName = new NameBuilder()
663                 .setValueName("eNodeEdgePoint_N")
664                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU,
665                     oorClientPortList.get(i).getTpId().getValue()))
666                 .build();
667
668             OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(onedName.key(), onedName),
669                 LayerProtocolName.ODU, LayerProtocolName.DSR, false, String.join("+", this.ietfNodeId,
670                     TapiStringConstants.E_ODU));
671             onepl.put(onep.key(), onep);
672         }
673         // create NodeRuleGroup
674         int count = 1;
675         LOG.info("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
676         for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
677             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
678                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
679                 nepList = new HashMap<>();
680             LOG.info("UUidMap={}", this.uuidMap.keySet());
681             LOG.info("TP list = {}", nbl.getTpList());
682             for (TpId tp : nbl.getTpList()) {
683                 LOG.info("TP={}", tp.getValue());
684                 LOG.info("UuidKey={}", String.join("+", this.ietfNodeId,
685                     TapiStringConstants.E_ODU, tp.getValue()));
686                 if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
687                             TapiStringConstants.E_ODU, tp.getValue()))
688                         && this.uuidMap.containsKey(String.join("+", this.ietfNodeId,
689                             TapiStringConstants.DSR, tp.getValue()))) {
690                     org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
691                         nep1 = new org.opendaylight.yang.gen.v1.urn
692                         .onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder()
693                         .setTopologyUuid(tapiTopoUuid)
694                         .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
695                             TapiStringConstants.DSR)))
696                         .setNodeEdgePointUuid(this.uuidMap.get(String.join(
697                             "+", this.ietfNodeId, TapiStringConstants.DSR, tp.getValue())))
698                         .build();
699                     org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
700                         nep2 = new org.opendaylight.yang.gen.v1.urn
701                         .onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder()
702                         .setTopologyUuid(tapiTopoUuid)
703                         .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId,
704                             TapiStringConstants.DSR)))
705                         .setNodeEdgePointUuid(this.uuidMap.get(String.join(
706                             "+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue())))
707                         .build();
708                     nepList.put(nep1.key(), nep1);
709                     nepList.put(nep2.key(), nep2);
710                 }
711             }
712             // Empty random creation of mandatory fields for avoiding errors....
713             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
714                 .setCostAlgorithm("Restricted Shortest Path - RSP")
715                 .setCostName("HOP_COUNT")
716                 .setCostValue("12345678")
717                 .build();
718             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
719                 .setFixedLatencyCharacteristic("12345678")
720                 .setQueingLatencyCharacteristic("12345678")
721                 .setJitterCharacteristic("12345678")
722                 .setWanderCharacteristic("12345678")
723                 .setTrafficPropertyName("FIXED_LATENCY")
724                 .build();
725             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
726                 .setRiskCharacteristicName("risk characteristic")
727                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
728                 .build();
729             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
730                 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("dsr node rule group " + count)
731                     .getBytes(Charset.forName("UTF-8"))).toString()))
732                 .setRule(ruleList)
733                 .setNodeEdgePoint(nepList)
734                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
735                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
736                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
737                 .build();
738             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
739             count++;
740         }
741         return nodeUuid;
742     }
743
744     private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
745                                          LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
746                                          String keyword) {
747         String key = String.join("+", keyword, oorTp.getTpId().getValue());
748         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
749             .setUuid(this.uuidMap.get(key))
750             .setLayerProtocolName(nepProtocol)
751             .setName(nepNames);
752         if (withSip) {
753             onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, oorTp, keyword));
754         }
755         AdministrativeState adminState = null;
756         OperationalState operState = null;
757         if (oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() != null) {
758             adminState = this.tapiLink.setTapiAdminState(oorTp.augmentation(TerminationPoint1.class)
759                 .getAdministrativeState().getName());
760         }
761         if (oorTp.augmentation(TerminationPoint1.class).getOperationalState() != null) {
762             operState = this.tapiLink.setTapiOperationalState(oorTp.augmentation(TerminationPoint1.class)
763                 .getOperationalState().getName());
764         }
765         onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(oorTp, nepProtocol))
766             .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
767             .setLinkPortRole(PortRole.SYMMETRIC)
768             .setAdministrativeState(adminState)
769             .setOperationalState(operState)
770             .setLifecycleState(LifecycleState.INSTALLED)
771             .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
772             .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
773         return onepBldr.build();
774     }
775
776     private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(List<TerminationPoint> tpList,
777                                                                                   boolean withSip) {
778         // create neps for MC and OTSiMC and Photonic Media
779         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
780         for (TerminationPoint tp:tpList) {
781             // Admin and oper state common for all tps
782             AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
783             State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
784             // PHOTONIC MEDIA nep
785             LOG.info("PHOTO NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
786                 tp.getTpId().getValue()));
787             Name nepName = new NameBuilder()
788                 .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint")
789                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA,
790                     tp.getTpId().getValue()))
791                 .build();
792
793             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
794                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
795                     TapiStringConstants.PHTNC_MEDIA, tp.getTpId().getValue()))
796                     .getBytes(Charset.forName("UTF-8"))).toString()))
797                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
798                 .setName(Map.of(nepName.key(), nepName))
799                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
800                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
801                 .setLinkPortRole(PortRole.SYMMETRIC)
802                 .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName()))
803                 .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName()))
804                 .setLifecycleState(LifecycleState.INSTALLED)
805                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
806                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
807                 .build();
808             onepMap.put(onep.key(), onep);
809
810             // MC nep
811             LOG.info("MC NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.MC,
812                 tp.getTpId().getValue()));
813             Name nepName1 = new NameBuilder()
814                 .setValueName(TapiStringConstants.MC + "NodeEdgePoint")
815                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.MC, tp.getTpId().getValue()))
816                 .build();
817             OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
818                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
819                     TapiStringConstants.MC, tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString()))
820                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
821                 .setName(Map.of(nepName1.key(), nepName1))
822                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
823                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
824                 .setLinkPortRole(PortRole.SYMMETRIC)
825                 .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName()))
826                 .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName()))
827                 .setLifecycleState(LifecycleState.INSTALLED)
828                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
829                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
830             if (withSip) {
831                 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
832                     tp, String.join("+", this.ietfNodeId, TapiStringConstants.MC)));
833             }
834             OwnedNodeEdgePoint onep1 = onepBldr1.build();
835             onepMap.put(onep1.key(), onep1);
836
837             // OTSiMC nep
838             LOG.info("OTSi NEP = {}", String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
839                 tp.getTpId().getValue()));
840             Name nepName2 = new NameBuilder()
841                 .setValueName(TapiStringConstants.OTSI_MC + "NodeEdgePoint")
842                 .setValue(String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC,
843                     tp.getTpId().getValue()))
844                 .build();
845
846             OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
847                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId,
848                         TapiStringConstants.OTSI_MC, tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
849                     .toString()))
850                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
851                 .setName(Map.of(nepName2.key(), nepName2))
852                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
853                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
854                 .setLinkPortRole(PortRole.SYMMETRIC)
855                 .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName()))
856                 .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName()))
857                 .setLifecycleState(LifecycleState.INSTALLED)
858                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
859                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
860                 .build();
861             onepMap.put(onep2.key(), onep2);
862         }
863         return onepMap;
864     }
865
866     private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(Uuid nodeUuid,
867                                                                                Collection<OwnedNodeEdgePoint> onepl) {
868         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
869             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
870             nepMap = new HashMap<>();
871         for (OwnedNodeEdgePoint onep : onepl) {
872             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
873                 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
874                 .NodeEdgePointBuilder()
875                 .setTopologyUuid(tapiTopoUuid)
876                 .setNodeUuid(nodeUuid)
877                 .setNodeEdgePointUuid(onep.key().getUuid())
878                 .build();
879             nepMap.put(nep.key(), nep);
880         }
881         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
882         Map<RuleKey, Rule> ruleList = new HashMap<>();
883         Rule rule = new RuleBuilder()
884             .setLocalId("forward")
885             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
886             .setRuleType(RuleType.FORWARDING)
887             .build();
888         ruleList.put(rule.key(), rule);
889         NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
890             .setUuid(new Uuid(UUID.nameUUIDFromBytes((this.ietfNodeId + " node rule group")
891                 .getBytes(Charset.forName("UTF-8"))).toString()))
892             .setRule(ruleList)
893             .setNodeEdgePoint(nepMap)
894             .build();
895         nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
896         return nodeRuleGroupMap;
897     }
898
899     private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
900                                                                                         LayerProtocolName layerProtocol,
901                                                                                         TerminationPoint tp,
902                                                                                         String nodeid) {
903         // add them to SIP context
904         Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
905         for (int i = 0; i < nb; i++) {
906             LOG.info("SIP = {}", String.join("+", "SIP", nodeid, tp.getTpId().getValue()));
907             Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
908                 tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
909             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
910                 .setServiceInterfacePointUuid(sipUuid).build();
911             ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tp, nodeid);
912             this.tapiSips.put(sip.key(), sip);
913             msipl.put(msip.key(), msip);
914         }
915         return msipl;
916     }
917
918     private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, TerminationPoint tp,
919                                             String nodeid) {
920         // TODO: what value should be set in total capacity and available capacity??
921         // LOG.info("SIP name = {}", String.join("+", nodeid, tp.getTpId().getValue()));
922         Name sipName = new NameBuilder()
923             .setValueName("SIP name")
924             .setValue(String.join("+", nodeid, tp.getTpId().getValue()))
925             .build();
926         AdministrativeState adminState = null;
927         OperationalState operState = null;
928         if (tp.augmentation(TerminationPoint1.class).getAdministrativeState() != null) {
929             adminState = this.tapiLink.setTapiAdminState(tp.augmentation(TerminationPoint1.class)
930                 .getAdministrativeState().getName());
931         }
932         if (tp.augmentation(TerminationPoint1.class).getOperationalState() != null) {
933             operState = this.tapiLink.setTapiOperationalState(tp.augmentation(TerminationPoint1.class)
934                 .getOperationalState().getName());
935         }
936         return new ServiceInterfacePointBuilder()
937             .setUuid(sipUuid)
938             .setName(Map.of(sipName.key(), sipName))
939             .setLayerProtocolName(layerProtocol)
940             .setAdministrativeState(adminState)
941             .setOperationalState(operState)
942             .setLifecycleState(LifecycleState.INSTALLED)
943             .setAvailableCapacity(new AvailableCapacityBuilder().build())
944             .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
945             .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(tp, layerProtocol))
946             .build();
947     }
948
949     private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(TerminationPoint tp,
950                                                                                                 LayerProtocolName lpn) {
951         Set<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqSet = new HashSet<>();
952         List<SupportedInterfaceCapability> sicList;
953         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1 tp1 =
954             tp.augmentation(org.opendaylight.yang.gen.v1.http
955                 .org.openroadm.otn.network.topology.rev200529.TerminationPoint1.class);
956         if (tp1 == null) {
957             return new ArrayList<>(sclpqSet);
958         }
959         if (tp1.getTpSupportedInterfaces() == null) {
960             LOG.warn("Tp supported interface doesnt exist on TP {}", tp.getTpId().getValue());
961             return new ArrayList<>(sclpqSet);
962         }
963         sicList = new ArrayList<>(tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values());
964         for (SupportedInterfaceCapability sic : sicList) {
965             switch (lpn.getName()) {
966                 case "DSR":
967                     switch (sic.getIfCapType().getSimpleName()) {
968                         // TODO: it may be needed to add more cases clauses if the interface capabilities of a
969                         //  port are extended in the config file
970                         case "If1GEODU0":
971                             sclpqSet.add(ODUTYPEODU0.class);
972                             sclpqSet.add(DIGITALSIGNALTYPEGigE.class);
973                             break;
974                         case "If10GEODU2e":
975                             sclpqSet.add(ODUTYPEODU2E.class);
976                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
977                             break;
978                         case "If10GEODU2":
979                             sclpqSet.add(ODUTYPEODU2.class);
980                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
981                             break;
982                         case "If10GE":
983                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
984                             break;
985                         case "If100GEODU4":
986                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
987                             sclpqSet.add(ODUTYPEODU4.class);
988                             break;
989                         case "If100GE":
990                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
991                             break;
992                         case "IfOCHOTU4ODU4":
993                         case "IfOCH":
994                             sclpqSet.add(ODUTYPEODU4.class);
995                             break;
996                         default:
997                             LOG.error("IfCapability type not managed");
998                             break;
999                     }
1000                     break;
1001                 case "ODU":
1002                     switch (sic.getIfCapType().getSimpleName()) {
1003                         // TODO: it may be needed to add more cases clauses if the interface capabilities of a
1004                         //  port are extended in the config file
1005                         case "If1GEODU0":
1006                             sclpqSet.add(ODUTYPEODU0.class);
1007                             break;
1008                         case "If10GEODU2e":
1009                             sclpqSet.add(ODUTYPEODU2E.class);
1010                             break;
1011                         case "If10GEODU2":
1012                         case "If10GE":
1013                             sclpqSet.add(ODUTYPEODU2.class);
1014                             break;
1015                         case "If100GEODU4":
1016                         case "If100GE":
1017                         case "IfOCHOTU4ODU4":
1018                         case "IfOCH":
1019                             sclpqSet.add(ODUTYPEODU4.class);
1020                             break;
1021                         default:
1022                             LOG.error("IfCapability type not managed");
1023                             break;
1024                     }
1025                     break;
1026                 case "PHOTONIC_MEDIA":
1027                     if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
1028                             || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
1029                         sclpqSet.add(PHOTONICLAYERQUALIFIEROTSi.class);
1030                         sclpqSet.add(PHOTONICLAYERQUALIFIEROMS.class);
1031                     }
1032                     break;
1033                 default:
1034                     LOG.error("Layer Protocol Name is unknown");
1035                     break;
1036             }
1037         }
1038         return new ArrayList<>(sclpqSet);
1039     }
1040
1041     private void createTapiTransitionalLinks() {
1042         for (TerminationPoint tp : this.oorNetworkPortList) {
1043             Link transiLink = tapiLink.createTapiLink(this.ietfNodeId, tp.getTpId().getValue(), this.ietfNodeId,
1044                 tp.getTpId().getValue(), TapiStringConstants.TRANSITIONAL_LINK, TapiStringConstants.DSR,
1045                 TapiStringConstants.OTSI, TapiStringConstants.I_ODU, TapiStringConstants.I_OTSI,
1046                 "inService", "inService", Arrays.asList(LayerProtocolName.ODU,
1047                     LayerProtocolName.PHOTONICMEDIA),
1048                 Arrays.asList(LayerProtocolName.ODU.getName(), LayerProtocolName.PHOTONICMEDIA.getName()),
1049                 this.tapiTopoUuid);
1050             this.tapiLinks.put(transiLink.key(), transiLink);
1051         }
1052     }
1053
1054     public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1055             .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
1056         List<String> linksToNotConvert = new ArrayList<>();
1057         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
1058         // LOG.info("Link list = {}", xpdrRdmLinkList.toString());
1059         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1060             .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
1061             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
1062                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1063                     .ietf.network.topology.rev180226.networks.network.Link oppositeLink = xpdrRdmLinkList.stream()
1064                     .filter(l -> l.getLinkId().equals(link.augmentation(Link1.class).getOppositeLink())).findAny()
1065                     .orElse(null);
1066
1067                 AdminStates oppLnkAdmState = null;
1068                 State oppLnkOpState = null;
1069                 if (oppositeLink != null) {
1070                     oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
1071                     oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
1072                 }
1073                 String adminState =
1074                     link.augmentation(Link1.class).getAdministrativeState() == null
1075                         || oppLnkAdmState == null
1076                     ? null
1077                     : this.tapiLink.setTapiAdminState(
1078                         link.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
1079                 String operState =
1080                     link.augmentation(Link1.class).getOperationalState() == null
1081                         || oppLnkOpState == null
1082                     ? null
1083                     : this.tapiLink.setTapiOperationalState(
1084                         link.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
1085
1086                 String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
1087                     ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
1088                     : link.getSource().getSourceNode().getValue();
1089                 String sourceTp = link.getSource().getSourceTp().getValue();
1090                 String sourceNodeQual = sourceNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
1091                     : TapiStringConstants.OTSI;
1092                 String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
1093                     ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
1094                     : link.getDestination().getDestNode().getValue();
1095                 String destTp = link.getDestination().getDestTp().getValue();
1096                 String destNodeQual = destNode.contains("ROADM") ? TapiStringConstants.PHTNC_MEDIA
1097                     : TapiStringConstants.OTSI;
1098                 Link tapLink = this.tapiLink.createTapiLink(sourceNode, sourceTp, destNode, destTp,
1099                     TapiStringConstants.OMS_XPDR_RDM_LINK, sourceNodeQual, destNodeQual,
1100                     TapiStringConstants.PHTNC_MEDIA, TapiStringConstants.PHTNC_MEDIA, adminState,
1101                     operState, List.of(LayerProtocolName.PHOTONICMEDIA),
1102                     List.of(LayerProtocolName.PHOTONICMEDIA.getName()), this.tapiTopoUuid);
1103                 linksToNotConvert.add(link.augmentation(Link1.class).getOppositeLink().getValue());
1104                 this.tapiLinks.put(tapLink.key(), tapLink);
1105             }
1106         }
1107     }
1108
1109     private String getIdBasedOnModelVersion(String linknodeid) {
1110         if (linknodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")) {
1111             LOG.info("OpenROADM version > 1.2.1 {}", linknodeid);
1112             return String.join("-", linknodeid.split("-")[0], linknodeid.split("-")[1]);
1113         } else {
1114             LOG.info("OpenROADM version <= 1.2.1 {}", linknodeid);
1115             return linknodeid.split("-")[0];
1116         }
1117     }
1118
1119     public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
1120             getTapiNodes() {
1121         return tapiNodes;
1122     }
1123
1124     public Map<LinkKey, Link> getTapiLinks() {
1125         return tapiLinks;
1126     }
1127
1128     public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
1129         return tapiSips;
1130     }
1131 }