Initial OR-TAPI mapping: Topology
[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.Collections;
15 import java.util.HashMap;
16 import java.util.HashSet;
17 import java.util.List;
18 import java.util.Map;
19 import java.util.Set;
20 import java.util.UUID;
21 import java.util.stream.Collectors;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Link1;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
39 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
40 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit;
41 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection;
42 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LAYERPROTOCOLQUALIFIER;
43 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName;
44 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState;
45 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState;
46 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection;
47 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole;
48 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationDirection;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointBuilder;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN;
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.ProtectionType;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RestorationPolicy;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePoint;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointBuilder;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointKey;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.ResilienceTypeBuilder;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.Rule;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanism;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanismBuilder;
100 import org.opendaylight.yangtools.yang.common.Uint16;
101 import org.opendaylight.yangtools.yang.common.Uint64;
102 import org.slf4j.Logger;
103 import org.slf4j.LoggerFactory;
104
105
106 public class ConvertORTopoToTapiFullTopo {
107
108     private static final String DSR = "DSR";
109     private static final String I_ODU = "iODU";
110     private static final String E_ODU = "eODU";
111     private static final String OTSI = "OTSi";
112     private static final String E_OTSI = "eOTSi";
113     private static final String I_OTSI = "iOTSi";
114     private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA";
115     private static final String MC = "MEDIA_CHANNEL";
116     private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL";
117     private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToTapiFullTopo.class);
118     private String ietfNodeId;
119     private OpenroadmNodeType ietfNodeType;
120     private AdminStates ietfNodeAdminState;
121     private State ietfNodeOperState;
122     private List<TerminationPoint> oorClientPortList;
123     private List<TerminationPoint> oorNetworkPortList;
124     private OduSwitchingPools oorOduSwitchingPool;
125     private Uuid tapiTopoUuid;
126     private Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
127         tapiNodes;
128     private Map<LinkKey, Link> tapiLinks;
129     private Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSips;
130     private Map<String, Uuid> uuidMap;
131
132
133     public ConvertORTopoToTapiFullTopo(Uuid tapiTopoUuid) {
134         this.tapiTopoUuid = tapiTopoUuid;
135         this.tapiNodes = new HashMap<>();
136         this.tapiLinks = new HashMap<>();
137         this.uuidMap = new HashMap<>();
138         this.tapiSips = new HashMap<>();
139     }
140
141     public void convertNode(Node ietfNode, List<String> networkPorts) {
142         this.ietfNodeId = ietfNode.getNodeId().getValue();
143         if (ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
144                 == null) {
145             return;
146         }
147         this.ietfNodeType = ietfNode.augmentation(
148             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class).getNodeType();
149         this.ietfNodeAdminState = ietfNode.augmentation(
150             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
151                 .getAdministrativeState();
152         this.ietfNodeOperState = ietfNode.augmentation(
153             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1.class)
154                 .getOperationalState();
155         this.oorNetworkPortList = ietfNode.augmentation(
156             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
157                 .getTerminationPoint().values().stream()
158                 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
159                     == OpenroadmTpType.XPONDERNETWORK.getIntValue()
160                     && networkPorts.contains(tp.getTpId().getValue()))
161                 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
162                 .collect(Collectors.toList());
163         if (!OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
164             this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
165                 .values().stream().findFirst().get();
166             this.oorClientPortList = ietfNode.augmentation(
167                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
168                     .getTerminationPoint().values().stream()
169                     .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
170                         == OpenroadmTpType.XPONDERCLIENT.getIntValue())
171                     .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
172                     .collect(Collectors.toList());
173         } else {
174             this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
175             List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
176                 .flatMap(nbl -> nbl.getTpList().stream())
177                 .collect(Collectors.toList());
178             this.oorClientPortList = ietfNode.augmentation(
179                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
180                     .getTerminationPoint().values().stream()
181                     .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
182                         == OpenroadmTpType.XPONDERCLIENT.getIntValue() && tpList.contains(tp.getTpId()))
183                     .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
184                     .collect(Collectors.toList());
185             this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
186         }
187
188         // node creation [DSR/ODU]
189         LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
190         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, DSR))
191             .getBytes(Charset.forName("UTF-8"))).toString());
192         this.uuidMap.put(String.join("+", this.ietfNodeId, DSR), nodeUuid);
193         Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(
194             String.join("+", this.ietfNodeId, DSR)).build();
195         List<LayerProtocolName> dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, LayerProtocolName.ODU);
196         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
197             .Node dsrNode = createTapiNode(Map.of(nameDsr.key(), nameDsr), dsrLayerProtocols);
198         LOG.info("DSR Node {} should have {} NEPs and {} SIPs", this.ietfNodeId,
199             this.oorClientPortList.size() + 2 * this.oorNetworkPortList.size(),
200             this.oorClientPortList.size() + this.oorNetworkPortList.size());
201         LOG.info("DSR Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
202             dsrNode.getOwnedNodeEdgePoint().values().size(), dsrNode.getOwnedNodeEdgePoint().values().stream()
203                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
204         tapiNodes.put(dsrNode.key(), dsrNode);
205
206         // node creation [otsi]
207         LOG.info("creation of an OTSi node for {}", this.ietfNodeId);
208         nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, OTSI))
209             .getBytes(Charset.forName("UTF-8"))).toString());
210         this.uuidMap.put(String.join("+", this.ietfNodeId, OTSI), nodeUuid);
211         Name nameOtsi =  new NameBuilder().setValueName("otsi node name").setValue(
212             String.join("+", this.ietfNodeId, OTSI)).build();
213         List<LayerProtocolName> otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
214         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
215             .Node otsiNode = createTapiNode(Map.of(nameOtsi.key(), nameOtsi), otsiLayerProtocols);
216         LOG.info("OTSi Node {} should have {} NEPs and {} SIPs", this.ietfNodeId, 3 * this.oorNetworkPortList.size(),
217             this.oorNetworkPortList.size());
218         LOG.info("OTSi Node {} has {} NEPs and {} SIPs", this.ietfNodeId,
219             otsiNode.getOwnedNodeEdgePoint().values().size(), otsiNode.getOwnedNodeEdgePoint().values().stream()
220                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
221         tapiNodes.put(otsiNode.key(), otsiNode);
222
223         // transitional link cration between network nep of DSR/ODU node and iNep of otsi node
224         LOG.info("creation of transitional links between DSR/ODU and OTSi nodes");
225         createTapiTransitionalLinks();
226     }
227
228     public void convertLinks(
229             Map<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
230                 .ietf.network.topology.rev180226.networks.network.LinkKey,
231             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
232                 .ietf.network.topology.rev180226.networks.network.Link> otnLinkMap) {
233         List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
234             .Link> otnLinkList = new ArrayList<>(otnLinkMap.values());
235         Collections.sort(otnLinkList, (l1, l2) -> l1.getLinkId().getValue()
236             .compareTo(l2.getLinkId().getValue()));
237         List<String> linksToNotConvert = new ArrayList<>();
238         LOG.info("creation of {} otn links", otnLinkMap.size() / 2);
239         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
240             .Link otnlink : otnLinkList) {
241             if (!linksToNotConvert.contains(otnlink.getLinkId().getValue())) {
242                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks
243                     .network.Link oppositeLink = otnLinkMap.get(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns
244                     .yang.ietf.network.topology.rev180226.networks.network.LinkKey(otnlink.augmentation(
245                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
246                     .getOppositeLink()));
247                 Link tapiLink = createTapiLink(otnlink, oppositeLink);
248                 linksToNotConvert.add(oppositeLink.getLinkId().getValue());
249                 tapiLinks.put(tapiLink.key(), tapiLink);
250             }
251         }
252     }
253
254     public void convertRdmToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
255             .ietf.network.topology.rev180226.networks.network.Link> rdmTordmLinkList) {
256         List<String> linksToNotConvert = new ArrayList<>();
257         LOG.info("creation of {} roadm to roadm links", rdmTordmLinkList.size() / 2);
258         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
259             .Link link : rdmTordmLinkList) {
260             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
261                 Link tapiLink = createTapiOmsLink(link);
262                 linksToNotConvert.add(link
263                     .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
264                     .getOppositeLink().getValue());
265                 tapiLinks.put(tapiLink.key(), tapiLink);
266             }
267         }
268     }
269
270     public void convertRoadmNode(Node roadm, Network openroadmTopo) {
271         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
272         // 1. Get degree and srg nodes to map TPs into NEPs
273         if (openroadmTopo.getNode() == null) {
274             LOG.warn("Openroadm-topology is null.");
275             return;
276         }
277         int numNeps = 0;
278         int numSips = 0;
279         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
280         for (Node node:nodeList) {
281             if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
282                 .equals(roadm.getNodeId().getValue()))) {
283                 LOG.warn("Abstracted node {} is not part of {}",
284                     node.getNodeId().getValue(), roadm.getNodeId().getValue());
285                 continue;
286             }
287             if (node.augmentation(Node1.class) == null
288                 && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
289                 .ietf.network.topology.rev180226.Node1.class) == null) {
290                 LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
291                     node.getNodeId().getValue());
292                 continue;
293             }
294             OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
295                 .org.openroadm.common.network.rev200529.Node1.class).getNodeType();
296             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
297                 node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
298                     .ietf.network.topology.rev180226.Node1.class);
299             LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
300             switch (nodeType.getIntValue()) {
301                 case 11:
302                     LOG.info("Degree node");
303                     // Get only external TPs of the degree
304                     List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
305                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
306                             == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
307                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
308                             == OpenroadmTpType.DEGREERXTTP.getIntValue()
309                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
310                             == OpenroadmTpType.DEGREETXTTP.getIntValue())
311                         .collect(Collectors.toList());
312                     // Convert TP List in NEPs and put it in onepl
313                     LOG.info("Degree port List: {}", degPortList);
314                     // TODO: deg port could be sip. e.g. MDONS
315                     oneplist.putAll(populateNepsForRdmNode(roadm.getNodeId().getValue(), degPortList, false));
316                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), degPortList, false));
317                     numNeps += degPortList.size() * 3;
318                     break;
319                 case 12:
320                     LOG.info("SRG node");
321                     // Get only external TPs of the srg
322                     List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
323                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
324                             == OpenroadmTpType.SRGTXRXPP.getIntValue()
325                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
326                             == OpenroadmTpType.SRGRXPP.getIntValue()
327                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
328                             == OpenroadmTpType.SRGTXPP.getIntValue())
329                         .collect(Collectors.toList());
330                     // Convert TP List in NEPs and put it in onepl
331                     LOG.info("Srg port List: {}", srgPortList);
332                     oneplist.putAll(populateNepsForRdmNode(roadm.getNodeId().getValue(), srgPortList, true));
333                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), srgPortList, true));
334                     numNeps += srgPortList.size() * 3;
335                     numSips += srgPortList.size();
336                     break;
337                 default:
338                     LOG.error("Node {} tyoe not supported", nodeType.getName());
339             }
340         }
341         // create tapi Node
342         // UUID
343         LOG.info("Creation of PHOTONIC node for {}", roadm.getNodeId().getValue());
344         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
345             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
346         // Names
347         Name nodeNames =  new NameBuilder().setValueName("roadm node name")
348             .setValue(String.join("+", roadm.getNodeId().getValue(), PHTNC_MEDIA)).build();
349         // Protocol Layer
350         List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
351         // Build tapi node
352         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
353             .Node roadmNode = createRoadmTapiNode(nodeUuid, nodeNames, 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.rev201019.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(setTapiAdminState(this.ietfNodeAdminState))
426             .setOperationalState(setTapiOperationalState(this.ietfNodeOperState))
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 AdministrativeState setTapiAdminState(AdminStates adminState) {
442         if (adminState == null) {
443             return null;
444         }
445         return adminState.equals(AdminStates.InService)
446             ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
447     }
448
449     private AdministrativeState setTapiAdminState(AdminStates adminState1, AdminStates adminState2) {
450         if (adminState1 == null || adminState2 == null) {
451             return null;
452         }
453         LOG.info("Admin state 1 = {}, andmin state 2 = {}", adminState1.getName(), adminState2.getName());
454         if (AdminStates.InService.equals(adminState1) && AdminStates.InService.equals(adminState2)) {
455             return AdministrativeState.UNLOCKED;
456         } else {
457             return AdministrativeState.LOCKED;
458         }
459     }
460
461     private OperationalState setTapiOperationalState(State operState) {
462         if (operState == null) {
463             return null;
464         }
465         return operState.getName().equals("inService") ? OperationalState.ENABLED : OperationalState.DISABLED;
466     }
467
468     private OperationalState setTapiOperationalState(State operState1, State operState2) {
469         if (operState1 == null || operState2 == null) {
470             return null;
471         }
472         LOG.info("Oper state 1 = {}, Oper state 2 = {}", operState1.getName(), operState2.getName());
473         if (State.InService.equals(operState1) && State.InService.equals(operState2)) {
474             return OperationalState.ENABLED;
475         } else {
476             return OperationalState.DISABLED;
477         }
478     }
479
480     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
481             createRoadmTapiNode(Uuid nodeUuid, Name nodeNames, List<LayerProtocolName> layerProtocols,
482                         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
483         // Empty random creation of mandatory fields for avoiding errors....
484         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
485             .setCostAlgorithm("Restricted Shortest Path - RSP")
486             .setCostName("HOP_COUNT")
487             .setCostValue("12345678")
488             .build();
489         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
490             .setFixedLatencyCharacteristic("12345678")
491             .setQueingLatencyCharacteristic("12345678")
492             .setJitterCharacteristic("12345678")
493             .setWanderCharacteristic("12345678")
494             .setTrafficPropertyName("FIXED_LATENCY")
495             .build();
496         return new NodeBuilder()
497             .setUuid(nodeUuid)
498             .setName(Map.of(nodeNames.key(), nodeNames))
499             .setLayerProtocolName(layerProtocols)
500             .setAdministrativeState(AdministrativeState.UNLOCKED)
501             .setOperationalState(OperationalState.ENABLED)
502             .setLifecycleState(LifecycleState.INSTALLED)
503             .setOwnedNodeEdgePoint(oneplist)
504             .setNodeRuleGroup(createNodeRuleGroupForRdmNode(nodeUuid, oneplist.values()))
505             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
506             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
507             .setErrorCharacteristic("error")
508             .setLossCharacteristic("loss")
509             .setRepeatDeliveryCharacteristic("repeat delivery")
510             .setDeliveryOrderCharacteristic("delivery order")
511             .setUnavailableTimeCharacteristic("unavailable time")
512             .setServerIntegrityProcessCharacteristic("server integrity process")
513             .build();
514     }
515
516     private Uuid getNodeUuid4Photonic(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
517                                       Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
518                                       Map<RuleKey, Rule> ruleList) {
519         Uuid nodeUuid;
520         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI));
521         // iNep creation on otsi node
522         for (int i = 0; i < oorNetworkPortList.size(); i++) {
523             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, I_OTSI,
524                 oorNetworkPortList.get(i).getTpId().getValue()));
525             Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
526                 (String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
527                     .getBytes(Charset.forName("UTF-8")))
528                 .toString());
529             this.uuidMap.put(String.join("+", this.ietfNodeId, I_OTSI,
530                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
531             Name onedName = new NameBuilder()
532                 .setValueName("iNodeEdgePoint")
533                 .setValue(String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
534                 .build();
535
536             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
537                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
538                 String.join("+", this.ietfNodeId, I_OTSI));
539             onepl.put(onep.key(), onep);
540         }
541         // eNep creation on otsi node
542         for (int i = 0; i < oorNetworkPortList.size(); i++) {
543             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, E_OTSI,
544                 oorNetworkPortList.get(i).getTpId().getValue()));
545             Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
546                 (String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
547                     .getBytes(Charset.forName("UTF-8")))
548                 .toString());
549             this.uuidMap.put(String.join("+", this.ietfNodeId, E_OTSI,
550                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
551             Name onedName = new NameBuilder()
552                 .setValueName("eNodeEdgePoint")
553                 .setValue(String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
554                 .build();
555
556             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
557                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
558                 String.join("+", this.ietfNodeId, E_OTSI));
559             onepl.put(onep.key(), onep);
560         }
561         // Photonic Media Nep creation on otsi node
562         for (int i = 0; i < oorNetworkPortList.size(); i++) {
563             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, PHTNC_MEDIA,
564                 oorNetworkPortList.get(i).getTpId().getValue()));
565             Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
566                 (String.join("+", this.ietfNodeId, PHTNC_MEDIA,
567                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
568                 .toString());
569             this.uuidMap.put(String.join("+", this.ietfNodeId, PHTNC_MEDIA,
570                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
571             Name onedName = new NameBuilder()
572                 .setValueName("PhotMedNodeEdgePoint")
573                 .setValue(String.join("+", this.ietfNodeId, PHTNC_MEDIA,
574                     oorNetworkPortList.get(i).getTpId().getValue()))
575                 .build();
576
577             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
578                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
579                 String.join("+", this.ietfNodeId, PHTNC_MEDIA));
580             onepl.put(onep.key(), onep);
581         }
582         // create NodeRuleGroup
583         int count = 1;
584         LOG.info("OTSi switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
585         for (TerminationPoint tp : this.oorNetworkPortList) {
586             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
587                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
588                 nepList = new HashMap<>();
589             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
590                 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
591                 .node.rule.group.NodeEdgePointBuilder()
592                 .setTopologyUuid(tapiTopoUuid)
593                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
594                 .setNodeEdgePointUuid(
595                     this.uuidMap.get(String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue())))
596                 .build();
597             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
598                 .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
599                 .node.rule.group.NodeEdgePointBuilder()
600                 .setTopologyUuid(tapiTopoUuid)
601                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
602                 .setNodeEdgePointUuid(
603                     this.uuidMap.get(String.join("+", this.ietfNodeId, E_OTSI, tp.getTpId().getValue())))
604                 .build();
605             nepList.put(inep.key(), inep);
606             nepList.put(enep.key(), enep);
607             // Empty random creation of mandatory fields for avoiding errors....
608             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
609                 .setCostAlgorithm("Restricted Shortest Path - RSP")
610                 .setCostName("HOP_COUNT")
611                 .setCostValue("12345678")
612                 .build();
613             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
614                 .setFixedLatencyCharacteristic("12345678")
615                 .setQueingLatencyCharacteristic("12345678")
616                 .setJitterCharacteristic("12345678")
617                 .setWanderCharacteristic("12345678")
618                 .setTrafficPropertyName("FIXED_LATENCY")
619                 .build();
620             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
621                 .setRiskCharacteristicName("risk characteristic")
622                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
623                 .build();
624             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
625                 .setUuid(new Uuid(
626                     UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
627                         .toString()))
628                 .setRule(ruleList)
629                 .setNodeEdgePoint(nepList)
630                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
631                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
632                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
633                 .build();
634             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
635             count++;
636         }
637         return nodeUuid;
638     }
639
640     private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
641                                  Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
642         Uuid nodeUuid;
643         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, DSR));
644         // client nep creation on DSR node
645         for (int i = 0; i < oorClientPortList.size(); i++) {
646             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, DSR,
647                 oorClientPortList.get(i).getTpId().getValue()));
648             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
649                 (String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()))
650                     .getBytes(Charset.forName("UTF-8"))).toString());
651             this.uuidMap.put(String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()),
652                 nepUuid);
653             NameBuilder nameBldr = new NameBuilder().setValue(
654                 String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()));
655             Name name;
656             if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
657                 name = nameBldr.setValueName("100G-tpdr").build();
658             } else {
659                 name = nameBldr.setValueName("NodeEdgePoint_C").build();
660             }
661
662             OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
663                 LayerProtocolName.DSR, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, DSR));
664             onepl.put(onep.key(), onep);
665         }
666         // network nep creation on I_ODU node
667         for (int i = 0; i < oorNetworkPortList.size(); i++) {
668             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, I_ODU,
669                 oorNetworkPortList.get(i).getTpId().getValue()));
670             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
671                 (String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
672                     .getBytes(Charset.forName("UTF-8"))).toString());
673             this.uuidMap.put(String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()),
674                 nepUuid);
675             Name onedName = new NameBuilder()
676                 .setValueName("iNodeEdgePoint_N")
677                 .setValue(String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
678                 .build();
679
680             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
681                 LayerProtocolName.ODU, LayerProtocolName.DSR, false, String.join("+", this.ietfNodeId, I_ODU));
682             onepl.put(onep.key(), onep);
683         }
684         // network nep creation on E_ODU node
685         for (int i = 0; i < oorNetworkPortList.size(); i++) {
686             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, E_ODU,
687                 oorNetworkPortList.get(i).getTpId().getValue()));
688             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
689                 (String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
690                     .getBytes(Charset.forName("UTF-8"))).toString());
691             this.uuidMap.put(String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()),
692                 nepUuid);
693             Name onedName = new NameBuilder()
694                 .setValueName("eNodeEdgePoint_N")
695                 .setValue(String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
696                 .build();
697
698             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
699                 LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, E_ODU));
700             onepl.put(onep.key(), onep);
701         }
702         // create NodeRuleGroup
703         int count = 1;
704         LOG.info("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
705         for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
706             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
707                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
708                 nepList = new HashMap<>();
709             LOG.info("UUidMap={}", this.uuidMap.keySet());
710             LOG.info("TP list = {}", nbl.getTpList());
711             for (TpId tp : nbl.getTpList()) {
712                 LOG.info("TP={}", tp.getValue());
713                 LOG.info("UuidKey={}", String.join("+", this.ietfNodeId, E_ODU, tp.getValue()));
714                 if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, E_ODU, tp.getValue()))
715                     || this.uuidMap.containsKey(String.join("+", this.ietfNodeId, DSR, tp.getValue()))) {
716                     org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
717                         nep = new org.opendaylight.yang.gen.v1.urn
718                         .onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder()
719                         .setTopologyUuid(tapiTopoUuid)
720                         .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR)))
721                         .setNodeEdgePointUuid((tp.getValue().contains("CLIENT")) ? this.uuidMap.get(String.join(
722                             "+", this.ietfNodeId, DSR, tp.getValue())) : this.uuidMap.get(String.join(
723                             "+", this.ietfNodeId, E_ODU, tp.getValue())))
724                         .build();
725                     nepList.put(nep.key(), nep);
726                 }
727             }
728             // Empty random creation of mandatory fields for avoiding errors....
729             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
730                 .setCostAlgorithm("Restricted Shortest Path - RSP")
731                 .setCostName("HOP_COUNT")
732                 .setCostValue("12345678")
733                 .build();
734             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
735                 .setFixedLatencyCharacteristic("12345678")
736                 .setQueingLatencyCharacteristic("12345678")
737                 .setJitterCharacteristic("12345678")
738                 .setWanderCharacteristic("12345678")
739                 .setTrafficPropertyName("FIXED_LATENCY")
740                 .build();
741             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
742                 .setRiskCharacteristicName("risk characteristic")
743                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
744                 .build();
745             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
746                 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("dsr node rule group " + count)
747                     .getBytes(Charset.forName("UTF-8"))).toString()))
748                 .setRule(ruleList)
749                 .setNodeEdgePoint(nepList)
750                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
751                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
752                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
753                 .build();
754             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
755             count++;
756         }
757         return nodeUuid;
758     }
759
760     private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
761                                          LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
762                                          String keyword) {
763         String key = String.join("+", keyword, oorTp.getTpId().getValue());
764         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
765             .setUuid(this.uuidMap.get(key))
766             .setLayerProtocolName(nepProtocol)
767             .setName(nepNames);
768         if (withSip) {
769             onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, oorTp, keyword));
770         }
771         onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(oorTp, nodeProtocol))
772             .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
773             .setLinkPortRole(PortRole.SYMMETRIC)
774             .setAdministrativeState(setTapiAdminState(
775                 oorTp.augmentation(TerminationPoint1.class).getAdministrativeState()))
776             .setOperationalState(setTapiOperationalState(
777                 oorTp.augmentation(TerminationPoint1.class).getOperationalState()))
778             .setLifecycleState(LifecycleState.INSTALLED)
779             .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
780             .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
781         return onepBldr.build();
782     }
783
784     private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(String nodeId,
785                                                                                   List<TerminationPoint> tpList,
786                                                                                   boolean withSip) {
787         // create neps for MC and OTSiMC and Photonic Media
788         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
789         for (int i = 0; i < tpList.size(); i++) {
790             // PHOTONIC MEDIA nep
791             LOG.info("NEP = {}", String.join("+", nodeId, PHTNC_MEDIA, tpList.get(i).getTpId().getValue()));
792             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, PHTNC_MEDIA,
793                 tpList.get(i).getTpId().getValue()))
794                 .getBytes(Charset.forName("UTF-8")))
795                 .toString());
796             Name nepName = new NameBuilder()
797                 .setValueName("NodeEdgePoint name")
798                 .setValue(String.join("+", nodeId, PHTNC_MEDIA, tpList.get(i).getTpId().getValue()))
799                 .build();
800             OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
801                 .setUuid(nepUuid)
802                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
803                 .setName(Map.of(nepName.key(), nepName))
804                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
805                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
806                 .setLinkPortRole(PortRole.SYMMETRIC)
807                 .setAdministrativeState(AdministrativeState.UNLOCKED)
808                 .setOperationalState(OperationalState.ENABLED)
809                 .setLifecycleState(LifecycleState.INSTALLED)
810                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
811                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
812             OwnedNodeEdgePoint onep = onepBldr.build();
813             onepMap.put(onep.key(), onep);
814         }
815         for (int i = 0; i < tpList.size(); i++) {
816             // MC nep
817             LOG.info("NEP = {}", String.join("+", nodeId, MC, tpList.get(i).getTpId().getValue()));
818             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, MC,
819                 tpList.get(i).getTpId().getValue()))
820                 .getBytes(Charset.forName("UTF-8")))
821                 .toString());
822             Name nepName = new NameBuilder()
823                 .setValueName("NodeEdgePoint name")
824                 .setValue(String.join("+", nodeId, MC, tpList.get(i).getTpId().getValue()))
825                 .build();
826             OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
827                 .setUuid(nepUuid)
828                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
829                 .setName(Map.of(nepName.key(), nepName))
830                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
831                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
832                 .setLinkPortRole(PortRole.SYMMETRIC)
833                 .setAdministrativeState(AdministrativeState.UNLOCKED)
834                 .setOperationalState(OperationalState.ENABLED)
835                 .setLifecycleState(LifecycleState.INSTALLED)
836                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
837                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
838             if (withSip) {
839                 onepBldr.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
840                     tpList.get(i), String.join("+", nodeId, MC)));
841             }
842             OwnedNodeEdgePoint onep = onepBldr.build();
843             onepMap.put(onep.key(), onep);
844         }
845         for (int i = 0; i < tpList.size(); i++) {
846             // OTSiMC nep
847             LOG.info("NEP = {}", String.join("+", nodeId, OTSI_MC, tpList.get(i).getTpId().getValue()));
848             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, OTSI_MC,
849                 tpList.get(i).getTpId().getValue()))
850                 .getBytes(Charset.forName("UTF-8")))
851                 .toString());
852             Name nepName = new NameBuilder()
853                 .setValueName("NodeEdgePoint name")
854                 .setValue(String.join("+", nodeId, OTSI_MC, tpList.get(i).getTpId().getValue()))
855                 .build();
856             OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
857                 .setUuid(nepUuid)
858                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
859                 .setName(Map.of(nepName.key(), nepName))
860                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
861                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
862                 .setLinkPortRole(PortRole.SYMMETRIC)
863                 .setAdministrativeState(AdministrativeState.UNLOCKED)
864                 .setOperationalState(OperationalState.ENABLED)
865                 .setLifecycleState(LifecycleState.INSTALLED)
866                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
867                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
868             OwnedNodeEdgePoint onep = onepBldr.build();
869             onepMap.put(onep.key(), onep);
870         }
871         return onepMap;
872     }
873
874     private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(Uuid nodeUuid,
875                                                                                Collection<OwnedNodeEdgePoint> onepl) {
876         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
877             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
878             nepMap = new HashMap<>();
879         for (OwnedNodeEdgePoint onep : onepl) {
880             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
881                 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
882                 .NodeEdgePointBuilder()
883                 .setTopologyUuid(tapiTopoUuid)
884                 .setNodeUuid(nodeUuid)
885                 .setNodeEdgePointUuid(onep.key().getUuid())
886                 .build();
887             nepMap.put(nep.key(), nep);
888         }
889         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
890         Map<RuleKey, Rule> ruleList = new HashMap<>();
891         Rule rule = new RuleBuilder()
892             .setLocalId("forward")
893             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
894             .setRuleType(RuleType.FORWARDING)
895             .build();
896         ruleList.put(rule.key(), rule);
897         NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
898             .setUuid(new Uuid(UUID.nameUUIDFromBytes(("rdm infra node rule group").getBytes(Charset.forName("UTF-8")))
899                 .toString()))
900             .setRule(ruleList)
901             .setNodeEdgePoint(nepMap)
902             .build();
903         nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
904         return nodeRuleGroupMap;
905     }
906
907     private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
908                                                                                         LayerProtocolName layerProtocol,
909                                                                                         TerminationPoint tp,
910                                                                                         String nodeid) {
911         // add them to SIP context
912         Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
913         for (int i = 0; i < nb; i++) {
914             LOG.info("SIP = {}", String.join("+", "SIP", nodeid, tp.getTpId().getValue()));
915             Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
916                 tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
917             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
918                 .setServiceInterfacePointUuid(sipUuid).build();
919             ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tp, nodeid);
920             this.tapiSips.put(sip.key(), sip);
921             msipl.put(msip.key(), msip);
922         }
923         return msipl;
924     }
925
926     private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, TerminationPoint tp,
927                                             String nodeid) {
928         // TODO: what value should be set in total capacity and available capacity??
929         // LOG.info("SIP name = {}", String.join("+", nodeid, tp.getTpId().getValue()));
930         Name sipName = new NameBuilder()
931             .setValueName("SIP name")
932             .setValue(String.join("+", nodeid, tp.getTpId().getValue()))
933             .build();
934         return new ServiceInterfacePointBuilder()
935             .setUuid(sipUuid)
936             .setName(Map.of(sipName.key(), sipName))
937             .setLayerProtocolName(layerProtocol)
938             .setAdministrativeState(AdministrativeState.UNLOCKED)
939             .setOperationalState(OperationalState.ENABLED)
940             .setLifecycleState(LifecycleState.INSTALLED)
941             .setAvailableCapacity(new AvailableCapacityBuilder().build())
942             .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
943             .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(tp, layerProtocol))
944             .build();
945     }
946
947     private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(TerminationPoint tp,
948                                                                                                 LayerProtocolName lpn) {
949         Set<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqSet = new HashSet<>();
950         List<SupportedInterfaceCapability> sicList;
951         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1 tp1 =
952             tp.augmentation(org.opendaylight.yang.gen.v1.http
953                 .org.openroadm.otn.network.topology.rev200529.TerminationPoint1.class);
954         if (tp1 == null) {
955             return new ArrayList<>(sclpqSet);
956         }
957         if (tp1.getTpSupportedInterfaces() == null) {
958             LOG.warn("Tp supported interface doesnt exist on TP {}", tp.getTpId().getValue());
959             return new ArrayList<>(sclpqSet);
960         }
961         sicList = new ArrayList<>(tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values());
962         for (SupportedInterfaceCapability sic : sicList) {
963             switch (lpn.getName()) {
964                 case "DSR":
965                     switch (sic.getIfCapType().getSimpleName()) {
966                         case "If10GEODU2e":
967                             sclpqSet.add(ODUTYPEODU2E.class);
968                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
969                             break;
970                         case "If10GEODU2":
971                             sclpqSet.add(ODUTYPEODU2.class);
972                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
973                             break;
974                         case "If10GE":
975                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
976                             break;
977                         case "If100GEODU4":
978                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
979                             sclpqSet.add(ODUTYPEODU4.class);
980                             break;
981                         case "If100GE":
982                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
983                             break;
984                         case "IfOCHOTU4ODU4":
985                         case "IfOCH":
986                             sclpqSet.add(ODUTYPEODU4.class);
987                             break;
988                         default:
989                             LOG.error("IfCapability type not managed");
990                             break;
991                     }
992                     break;
993                 case "PHOTONIC_MEDIA":
994                     if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
995                         || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
996                         sclpqSet.add(PHOTONICLAYERQUALIFIEROTSi.class);
997                         sclpqSet.add(PHOTONICLAYERQUALIFIEROMS.class);
998                     }
999                     break;
1000                 default:
1001                     LOG.error("Layer Protocol Name is unknown");
1002                     break;
1003             }
1004         }
1005         return new ArrayList<>(sclpqSet);
1006     }
1007
1008     private void createTapiTransitionalLinks() {
1009         for (TerminationPoint tp : this.oorNetworkPortList) {
1010             Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1011             String sourceKey = String.join("+", this.ietfNodeId, I_ODU, tp.getTpId().getValue());
1012             Uuid sourceUuidTp = this.uuidMap.get(sourceKey);
1013             String destKey = String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue());
1014             Uuid destUuidTp = this.uuidMap.get(destKey);
1015             NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1016                 .setTopologyUuid(this.tapiTopoUuid)
1017                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR)))
1018                 .setNodeEdgePointUuid(sourceUuidTp)
1019                 .build();
1020             nepList.put(sourceNep.key(), sourceNep);
1021             NodeEdgePoint destNep = new NodeEdgePointBuilder()
1022                 .setTopologyUuid(this.tapiTopoUuid)
1023                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
1024                 .setNodeEdgePointUuid(destUuidTp)
1025                 .build();
1026             nepList.put(destNep.key(), destNep);
1027             Name linkName = new NameBuilder().setValueName("transitional link name")
1028                 .setValue(String.join("--", this.ietfNodeId, sourceKey, destKey))
1029                 .build();
1030             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1031                 .setCostAlgorithm("Restricted Shortest Path - RSP")
1032                 .setCostName("HOP_COUNT")
1033                 .setCostValue("12345678")
1034                 .build();
1035             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1036                 .setFixedLatencyCharacteristic("12345678")
1037                 .setQueingLatencyCharacteristic("12345678")
1038                 .setJitterCharacteristic("12345678")
1039                 .setWanderCharacteristic("12345678")
1040                 .setTrafficPropertyName("FIXED_LATENCY")
1041                 .build();
1042             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1043                 .setRiskCharacteristicName("risk characteristic")
1044                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1045                 .build();
1046             ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1047                 .setValidationMechanism("validation mechanism")
1048                 .setValidationRobustness("validation robustness")
1049                 .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1050                 .build();
1051             Link transiLink = new LinkBuilder()
1052                 .setUuid(new Uuid(
1053                     UUID.nameUUIDFromBytes((String.join("--", this.ietfNodeId, sourceKey, destKey))
1054                         .getBytes(Charset.forName("UTF-8")))
1055                         .toString()))
1056                 .setName(Map.of(linkName.key(), linkName))
1057                 .setTransitionedLayerProtocolName(Arrays.asList(LayerProtocolName.ODU.getName(),
1058                     LayerProtocolName.PHOTONICMEDIA.getName()))
1059                 .setLayerProtocolName(Arrays.asList(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA))
1060                 .setNodeEdgePoint(nepList)
1061                 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1062                 .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1063                     new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
1064                     .build())
1065                 .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1066                     .setRestorationPolicy(RestorationPolicy.NA)
1067                     .build())
1068                 .setAdministrativeState(AdministrativeState.UNLOCKED)
1069                 .setOperationalState(OperationalState.ENABLED)
1070                 .setLifecycleState(LifecycleState.INSTALLED)
1071                 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1072                     new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
1073                     .build())
1074                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1075                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1076                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1077                 .setErrorCharacteristic("error")
1078                 .setLossCharacteristic("loss")
1079                 .setRepeatDeliveryCharacteristic("repeat delivery")
1080                 .setDeliveryOrderCharacteristic("delivery order")
1081                 .setUnavailableTimeCharacteristic("unavailable time")
1082                 .setServerIntegrityProcessCharacteristic("server integrity process")
1083                 .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1084                 .build();
1085             this.tapiLinks.put(transiLink.key(), transiLink);
1086         }
1087     }
1088
1089     private Link createTapiLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1090                                     .ietf.network.topology.rev180226.networks.network.Link link,
1091                                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1092                                     .ietf.network.topology.rev180226.networks.network.Link oppositeLink) {
1093         String prefix = link.getLinkId().getValue().split("-")[0];
1094         String sourceNode = link.getSource().getSourceNode().getValue();
1095         String sourceTp = link.getSource().getSourceTp().toString();
1096         String destNode = link.getDestination().getDestNode().getValue();
1097         String destTp = link.getDestination().getDestTp().toString();
1098         LOG.info("prefix = {}, sourceNode = {}, sourceTp = {}, destNode = {}, destTp = {}",
1099                 prefix, sourceNode, sourceTp, destNode, destTp);
1100         Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1101         Uuid sourceUuidTp;
1102         Uuid sourceUuidNode;
1103         Uuid destUuidTp;
1104         Uuid destUuidNode;
1105         Name linkName;
1106         AdminStates oppositeLinkAdminState = null;
1107         State oppositeLinkOperState = null;
1108         if (oppositeLink != null) {
1109             oppositeLinkAdminState = oppositeLink.augmentation(
1110                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1111                 .getAdministrativeState();
1112             oppositeLinkOperState = oppositeLink.augmentation(
1113                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1114                 .getOperationalState();
1115         }
1116         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1117             .setCostAlgorithm("Restricted Shortest Path - RSP")
1118             .setCostName("HOP_COUNT")
1119             .setCostValue("12345678")
1120             .build();
1121         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1122             .setFixedLatencyCharacteristic("12345678")
1123             .setQueingLatencyCharacteristic("12345678")
1124             .setJitterCharacteristic("12345678")
1125             .setWanderCharacteristic("12345678")
1126             .setTrafficPropertyName("FIXED_LATENCY")
1127             .build();
1128         RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1129             .setRiskCharacteristicName("risk characteristic")
1130             .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1131             .build();
1132         ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1133             .setValidationMechanism("validation mechanism")
1134             .setValidationRobustness("validation robustness")
1135             .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1136             .build();
1137         switch (prefix) {
1138             case "OTU4":
1139                 sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, I_OTSI, sourceTp));
1140                 sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, OTSI));
1141                 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1142                     .setTopologyUuid(this.tapiTopoUuid)
1143                     .setNodeUuid(sourceUuidNode)
1144                     .setNodeEdgePointUuid(sourceUuidTp)
1145                     .build();
1146                 nepList.put(sourceNep.key(), sourceNep);
1147                 destUuidTp = this.uuidMap.get(String.join("+", destNode, I_OTSI, destTp));
1148                 destUuidNode = this.uuidMap.get(String.join("+", destNode, OTSI));
1149                 NodeEdgePoint destNep = new NodeEdgePointBuilder()
1150                     .setTopologyUuid(this.tapiTopoUuid)
1151                     .setNodeUuid(destUuidNode)
1152                     .setNodeEdgePointUuid(destUuidTp)
1153                     .build();
1154                 nepList.put(destNep.key(), destNep);
1155                 linkName = new NameBuilder().setValueName("otn link name")
1156                     .setValue(link.getLinkId().getValue())
1157                     .build();
1158                 return new LinkBuilder()
1159                     .setUuid(new Uuid(UUID.nameUUIDFromBytes((link.getLinkId().getValue())
1160                         .getBytes(Charset.forName("UTF-8"))).toString()))
1161                     .setName(Map.of(linkName.key(), linkName))
1162                     .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA))
1163                     .setTransitionedLayerProtocolName(new ArrayList<>())
1164                     .setAdministrativeState(setTapiAdminState(link
1165                         .augmentation(
1166                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1167                         .getAdministrativeState(), oppositeLinkAdminState))
1168                     .setOperationalState(setTapiOperationalState(link
1169                         .augmentation(
1170                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1171                         .getOperationalState(), oppositeLinkOperState))
1172                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1173                     .setNodeEdgePoint(nepList)
1174                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1175                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1176                             .setValue(Uint64.valueOf(100)).build()).build())
1177                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1178                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1179                             .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build())
1180                         .build())
1181                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1182                         .setRestorationPolicy(RestorationPolicy.NA)
1183                         .build())
1184                     .setAdministrativeState(AdministrativeState.UNLOCKED)
1185                     .setOperationalState(OperationalState.ENABLED)
1186                     .setLifecycleState(LifecycleState.INSTALLED)
1187                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1188                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1189                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1190                     .setErrorCharacteristic("error")
1191                     .setLossCharacteristic("loss")
1192                     .setRepeatDeliveryCharacteristic("repeat delivery")
1193                     .setDeliveryOrderCharacteristic("delivery order")
1194                     .setUnavailableTimeCharacteristic("unavailable time")
1195                     .setServerIntegrityProcessCharacteristic("server integrity process")
1196                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1197                     .build();
1198             case "ODU4":
1199                 sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, E_ODU, sourceTp));
1200                 sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, DSR));
1201                 NodeEdgePoint sourceNep2 = new NodeEdgePointBuilder()
1202                     .setTopologyUuid(this.tapiTopoUuid)
1203                     .setNodeUuid(sourceUuidNode)
1204                     .setNodeEdgePointUuid(sourceUuidTp)
1205                     .build();
1206                 nepList.put(sourceNep2.key(), sourceNep2);
1207                 destUuidTp = this.uuidMap.get(String.join("+", destNode, E_ODU, destTp));
1208                 destUuidNode = this.uuidMap.get(String.join("+", destNode, DSR));
1209                 NodeEdgePoint destNep2 = new NodeEdgePointBuilder()
1210                     .setTopologyUuid(this.tapiTopoUuid)
1211                     .setNodeUuid(destUuidNode)
1212                     .setNodeEdgePointUuid(destUuidTp)
1213                     .build();
1214                 nepList.put(destNep2.key(), destNep2);
1215                 linkName = new NameBuilder().setValueName("otn link name")
1216                     .setValue(link.getLinkId().getValue())
1217                     .build();
1218                 return new LinkBuilder()
1219                     .setUuid(new Uuid(UUID.nameUUIDFromBytes((link.getLinkId().getValue())
1220                         .getBytes(Charset.forName("UTF-8"))).toString()))
1221                     .setName(Map.of(linkName.key(), linkName))
1222                     .setLayerProtocolName(Arrays.asList(LayerProtocolName.ODU))
1223                     .setTransitionedLayerProtocolName(new ArrayList<>())
1224                     .setAdministrativeState(setTapiAdminState(link
1225                         .augmentation(
1226                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1227                         .getAdministrativeState(), oppositeLinkAdminState))
1228                     .setOperationalState(setTapiOperationalState(link
1229                         .augmentation(
1230                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1231                         .getOperationalState(), oppositeLinkOperState))
1232                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1233                     .setNodeEdgePoint(nepList)
1234                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1235                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1236                             .setValue(Uint64.valueOf(100)).build()).build())
1237                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1238                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1239                             .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build())
1240                         .build())
1241                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1242                         .setRestorationPolicy(RestorationPolicy.NA)
1243                         .build())
1244                     .setAdministrativeState(AdministrativeState.UNLOCKED)
1245                     .setOperationalState(OperationalState.ENABLED)
1246                     .setLifecycleState(LifecycleState.INSTALLED)
1247                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1248                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1249                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1250                     .setErrorCharacteristic("error")
1251                     .setLossCharacteristic("loss")
1252                     .setRepeatDeliveryCharacteristic("repeat delivery")
1253                     .setDeliveryOrderCharacteristic("delivery order")
1254                     .setUnavailableTimeCharacteristic("unavailable time")
1255                     .setServerIntegrityProcessCharacteristic("server integrity process")
1256                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1257                     .build();
1258             default:
1259                 LOG.error("OTN link of type {} not managed yet", prefix);
1260                 return null;
1261         }
1262     }
1263
1264     private Link createTapiOmsLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1265                                        .ietf.network.topology.rev180226.networks.network.Link link) {
1266         String sourceNode = getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue());
1267         String sourceTp = link.getSource().getSourceTp().toString();
1268         String destNode = getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue());
1269         String destTp = link.getDestination().getDestTp().toString();
1270         Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1271         Uuid sourceUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode,
1272             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
1273         Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode, PHTNC_MEDIA, sourceTp))
1274             .getBytes(Charset.forName("UTF-8"))).toString());
1275         Uuid destUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode,
1276             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
1277         Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode, PHTNC_MEDIA, destTp))
1278             .getBytes(Charset.forName("UTF-8"))).toString());
1279         NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1280             .setTopologyUuid(this.tapiTopoUuid)
1281             .setNodeUuid(sourceUuidNode)
1282             .setNodeEdgePointUuid(sourceUuidTp)
1283             .build();
1284         nepList.put(sourceNep.key(), sourceNep);
1285         NodeEdgePoint destNep = new NodeEdgePointBuilder()
1286             .setTopologyUuid(this.tapiTopoUuid)
1287             .setNodeUuid(destUuidNode)
1288             .setNodeEdgePointUuid(destUuidTp)
1289             .build();
1290         nepList.put(destNep.key(), destNep);
1291         Name linkName = new NameBuilder().setValueName("OMS link name")
1292             .setValue(link.getLinkId().getValue())
1293             .build();
1294         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1295             .setCostAlgorithm("Restricted Shortest Path - RSP")
1296             .setCostName("HOP_COUNT")
1297             .setCostValue("12345678")
1298             .build();
1299         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1300             .setFixedLatencyCharacteristic("12345678")
1301             .setQueingLatencyCharacteristic("12345678")
1302             .setJitterCharacteristic("12345678")
1303             .setWanderCharacteristic("12345678")
1304             .setTrafficPropertyName("FIXED_LATENCY")
1305             .build();
1306         RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1307             .setRiskCharacteristicName("risk characteristic")
1308             .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1309             .build();
1310         ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1311             .setValidationMechanism("validation mechanism")
1312             .setValidationRobustness("validation robustness")
1313             .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1314             .build();
1315         return new LinkBuilder()
1316             .setUuid(new Uuid(
1317                 UUID.nameUUIDFromBytes((link.getLinkId().getValue()).getBytes(Charset.forName("UTF-8")))
1318                     .toString()))
1319             .setName(Map.of(linkName.key(), linkName))
1320             .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
1321             .setTransitionedLayerProtocolName(new ArrayList<>())
1322             .setNodeEdgePoint(nepList)
1323             .setDirection(ForwardingDirection.BIDIRECTIONAL)
1324             .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1325                 .setRestorationPolicy(RestorationPolicy.NA)
1326                 .build())
1327             .setAdministrativeState(AdministrativeState.UNLOCKED)
1328             .setOperationalState(OperationalState.ENABLED)
1329             .setLifecycleState(LifecycleState.INSTALLED)
1330             .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1331                 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1332                     .setValue(Uint64.valueOf(100)).build()).build())
1333             .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1334                 new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1335                     .setValue(Uint64.valueOf(100)).build())
1336                 .build())
1337             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1338             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1339             .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1340             .setErrorCharacteristic("error")
1341             .setLossCharacteristic("loss")
1342             .setRepeatDeliveryCharacteristic("repeat delivery")
1343             .setDeliveryOrderCharacteristic("delivery order")
1344             .setUnavailableTimeCharacteristic("unavailable time")
1345             .setServerIntegrityProcessCharacteristic("server integrity process")
1346             .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1347             .build();
1348     }
1349
1350     public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1351             .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
1352         List<String> linksToNotConvert = new ArrayList<>();
1353         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
1354         // LOG.info("Link list = {}", xpdrRdmLinkList.toString());
1355         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1356             .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
1357             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
1358                 String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
1359                     ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
1360                     : link.getSource().getSourceNode().getValue();
1361                 String sourceTp = link.getSource().getSourceTp().toString();
1362                 String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
1363                     ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
1364                     : link.getDestination().getDestNode().getValue();
1365                 String destTp = link.getDestination().getDestTp().toString();
1366                 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1367                 Uuid sourceUuidNode = (sourceNode.contains("ROADM")) ? new Uuid(UUID.nameUUIDFromBytes((
1368                     String.join("+", sourceNode, PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString())
1369                     : new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode, OTSI))
1370                         .getBytes(Charset.forName("UTF-8"))).toString());
1371                 Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes(
1372                     (String.join("+", sourceNode, PHTNC_MEDIA, sourceTp))
1373                         .getBytes(Charset.forName("UTF-8"))).toString());
1374                 Uuid destUuidNode = (destNode.contains("ROADM")) ? new Uuid(UUID.nameUUIDFromBytes((
1375                     String.join("+", destNode, PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString())
1376                     : new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode, OTSI))
1377                         .getBytes(Charset.forName("UTF-8"))).toString());
1378                 Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode,
1379                     PHTNC_MEDIA, destTp)).getBytes(Charset.forName("UTF-8"))).toString());
1380                 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1381                     .setTopologyUuid(this.tapiTopoUuid)
1382                     .setNodeUuid(sourceUuidNode)
1383                     .setNodeEdgePointUuid(sourceUuidTp)
1384                     .build();
1385                 nepList.put(sourceNep.key(), sourceNep);
1386                 NodeEdgePoint destNep = new NodeEdgePointBuilder()
1387                     .setTopologyUuid(this.tapiTopoUuid)
1388                     .setNodeUuid(destUuidNode)
1389                     .setNodeEdgePointUuid(destUuidTp)
1390                     .build();
1391                 nepList.put(destNep.key(), destNep);
1392                 Name linkName = new NameBuilder().setValueName("XPDR-RDM link name")
1393                     .setValue(link.getLinkId().getValue())
1394                     .build();
1395                 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1396                     .setCostAlgorithm("Restricted Shortest Path - RSP")
1397                     .setCostName("HOP_COUNT")
1398                     .setCostValue("12345678")
1399                     .build();
1400                 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1401                     .setFixedLatencyCharacteristic("12345678")
1402                     .setQueingLatencyCharacteristic("12345678")
1403                     .setJitterCharacteristic("12345678")
1404                     .setWanderCharacteristic("12345678")
1405                     .setTrafficPropertyName("FIXED_LATENCY")
1406                     .build();
1407                 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1408                     .setRiskCharacteristicName("risk characteristic")
1409                     .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1410                     .build();
1411                 ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1412                     .setValidationMechanism("validation mechanism")
1413                     .setValidationRobustness("validation robustness")
1414                     .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1415                     .build();
1416                 Link tapiLink = new LinkBuilder()
1417                     .setUuid(new Uuid(
1418                         UUID.nameUUIDFromBytes((link.getLinkId().getValue()).getBytes(Charset.forName("UTF-8")))
1419                             .toString()))
1420                     .setName(Map.of(linkName.key(), linkName))
1421                     .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
1422                     .setTransitionedLayerProtocolName(new ArrayList<>())
1423                     .setNodeEdgePoint(nepList)
1424                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1425                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1426                         .setRestorationPolicy(RestorationPolicy.NA)
1427                         .build())
1428                     .setAdministrativeState(AdministrativeState.UNLOCKED)
1429                     .setOperationalState(OperationalState.ENABLED)
1430                     .setLifecycleState(LifecycleState.INSTALLED)
1431                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1432                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1433                             .setValue(Uint64.valueOf(100)).build()).build())
1434                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1435                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1436                             .setValue(Uint64.valueOf(100)).build())
1437                         .build())
1438                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1439                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1440                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1441                     .setErrorCharacteristic("error")
1442                     .setLossCharacteristic("loss")
1443                     .setRepeatDeliveryCharacteristic("repeat delivery")
1444                     .setDeliveryOrderCharacteristic("delivery order")
1445                     .setUnavailableTimeCharacteristic("unavailable time")
1446                     .setServerIntegrityProcessCharacteristic("server integrity process")
1447                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1448                     .build();
1449                 linksToNotConvert.add(link
1450                     .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1451                     .getOppositeLink().getValue());
1452                 this.tapiLinks.put(tapiLink.key(), tapiLink);
1453             }
1454         }
1455     }
1456
1457     private String getIdBasedOnModelVersion(String linknodeid) {
1458         if (linknodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")) {
1459             LOG.info("OpenROADM version > 1.2.1 {}", linknodeid);
1460             return String.join("-", linknodeid.split("-")[0], linknodeid.split("-")[1]);
1461         } else {
1462             LOG.info("OpenROADM version <= 1.2.1 {}", linknodeid);
1463             return linknodeid.split("-")[0];
1464         }
1465     }
1466
1467     public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
1468             getTapiNodes() {
1469         return tapiNodes;
1470     }
1471
1472     public Map<LinkKey, Link> getTapiLinks() {
1473         return tapiLinks;
1474     }
1475
1476     public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
1477         return tapiSips;
1478     }
1479 }