Junit tests for new TAPI module
[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, rdmTordmLinkList.stream()
262                     .filter(l -> l.getLinkId().equals(link.augmentation(org.opendaylight.yang.gen.v1.http
263                         .org.openroadm.common.network.rev200529.Link1.class).getOppositeLink()))
264                     .findAny().orElse(null));
265                 linksToNotConvert.add(link
266                     .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
267                     .getOppositeLink().getValue());
268                 tapiLinks.put(tapiLink.key(), tapiLink);
269             }
270         }
271     }
272
273     public void convertRoadmNode(Node roadm, Network openroadmTopo) {
274         this.ietfNodeId = roadm.getNodeId().getValue();
275         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist = new HashMap<>();
276         // 1. Get degree and srg nodes to map TPs into NEPs
277         if (openroadmTopo.getNode() == null) {
278             LOG.warn("Openroadm-topology is null.");
279             return;
280         }
281         int numNeps = 0;
282         int numSips = 0;
283         List<Node> nodeList = new ArrayList<Node>(openroadmTopo.getNode().values());
284         for (Node node:nodeList) {
285             if (node.getSupportingNode().values().stream().noneMatch(sp -> sp.getNodeRef().getValue()
286                 .equals(this.ietfNodeId))) {
287                 LOG.warn("Abstracted node {} is not part of {}",
288                     node.getNodeId().getValue(), this.ietfNodeId);
289                 continue;
290             }
291             if (node.augmentation(Node1.class) == null
292                 && node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
293                 .ietf.network.topology.rev180226.Node1.class) == null) {
294                 LOG.warn("Abstracted node {} doesnt have type of node or is not disaggregated",
295                     node.getNodeId().getValue());
296                 continue;
297             }
298             OpenroadmNodeType nodeType = node.augmentation(org.opendaylight.yang.gen.v1.http
299                 .org.openroadm.common.network.rev200529.Node1.class).getNodeType();
300             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
301                 node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
302                     .ietf.network.topology.rev180226.Node1.class);
303             LOG.info("TPs of node: {}", node1.getTerminationPoint().values());
304             switch (nodeType.getIntValue()) {
305                 case 11:
306                     LOG.info("Degree node");
307                     // Get only external TPs of the degree
308                     List<TerminationPoint> degPortList = node1.getTerminationPoint().values().stream()
309                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
310                             == OpenroadmTpType.DEGREETXRXTTP.getIntValue()
311                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
312                             == OpenroadmTpType.DEGREERXTTP.getIntValue()
313                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
314                             == OpenroadmTpType.DEGREETXTTP.getIntValue())
315                         .collect(Collectors.toList());
316                     // Convert TP List in NEPs and put it in onepl
317                     LOG.info("Degree port List: {}", degPortList);
318                     // TODO: deg port could be sip. e.g. MDONS
319                     oneplist.putAll(populateNepsForRdmNode(degPortList, false));
320                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), degPortList, false));
321                     numNeps += degPortList.size() * 3;
322                     break;
323                 case 12:
324                     LOG.info("SRG node");
325                     // Get only external TPs of the srg
326                     List<TerminationPoint> srgPortList = node1.getTerminationPoint().values().stream()
327                         .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
328                             == OpenroadmTpType.SRGTXRXPP.getIntValue()
329                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
330                             == OpenroadmTpType.SRGRXPP.getIntValue()
331                             || tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
332                             == OpenroadmTpType.SRGTXPP.getIntValue())
333                         .collect(Collectors.toList());
334                     // Convert TP List in NEPs and put it in onepl
335                     LOG.info("Srg port List: {}", srgPortList);
336                     oneplist.putAll(populateNepsForRdmNode(srgPortList, true));
337                     // oneplist.putAll(populateNepsForRdmNode(node.getNodeId().getValue(), srgPortList, true));
338                     numNeps += srgPortList.size() * 3;
339                     numSips += srgPortList.size();
340                     break;
341                 default:
342                     LOG.error("Node {} tyoe not supported", nodeType.getName());
343             }
344         }
345         // create tapi Node
346         // UUID
347         LOG.info("Creation of PHOTONIC node for {}", roadm.getNodeId().getValue());
348         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", roadm.getNodeId().getValue(),
349             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
350         // Names
351         Name nodeNames =  new NameBuilder().setValueName("roadm node name")
352             .setValue(String.join("+", roadm.getNodeId().getValue(), PHTNC_MEDIA)).build();
353         // Protocol Layer
354         List<LayerProtocolName> layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA);
355         // Build tapi node
356         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology
357             .Node roadmNode = createRoadmTapiNode(nodeUuid, nodeNames, layerProtocols, oneplist);
358         // TODO add states corresponding to device config
359         LOG.info("ROADM node {} should have {} NEPs and {} SIPs", roadm.getNodeId().getValue(), numNeps, numSips);
360         LOG.info("ROADM node {} has {} NEPs and {} SIPs", roadm.getNodeId().getValue(),
361             roadmNode.getOwnedNodeEdgePoint().values().size(),
362             roadmNode.getOwnedNodeEdgePoint().values().stream()
363                 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
364
365         tapiNodes.put(roadmNode.key(), roadmNode);
366     }
367
368     private OduSwitchingPools createOduSwitchingPoolForTp100G() {
369         Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
370         int count = 1;
371         for (TerminationPoint tp : this.oorNetworkPortList) {
372             TpId tpid1 = tp.getTpId();
373             TpId tpid2 = new TpId(tp.augmentation(
374                 org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.TerminationPoint1.class)
375                 .getAssociatedConnectionMapPort());
376             List<TpId> tpList = new ArrayList<>();
377             tpList.add(tpid1);
378             tpList.add(tpid2);
379             NonBlockingList nbl = new NonBlockingListBuilder()
380                 .setNblNumber(Uint16.valueOf(count))
381                 .setTpList(tpList)
382                 .build();
383             nblMap.put(nbl.key(), nbl);
384             count++;
385         }
386         return new OduSwitchingPoolsBuilder()
387             .setNonBlockingList(nblMap)
388             .setSwitchingPoolNumber(Uint16.valueOf(1))
389             .build();
390     }
391
392     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
393             createTapiNode(Map<NameKey, Name> nodeNames, List<LayerProtocolName> layerProtocols) {
394         Uuid nodeUuid = null;
395         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
396         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
397         Map<RuleKey, Rule> ruleList = new HashMap<>();
398         Rule rule = new RuleBuilder()
399             .setLocalId("forward")
400             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
401             .setRuleType(RuleType.FORWARDING)
402             .build();
403         ruleList.put(rule.key(), rule);
404         if (layerProtocols.contains(LayerProtocolName.DSR)) {
405             nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, ruleList);
406         } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
407             nodeUuid = getNodeUuid4Photonic(onepl, nodeRuleGroupList, ruleList);
408         } else {
409             LOG.error("Undefined LayerProtocolName for {} node {}", nodeNames.get(nodeNames.keySet().iterator().next())
410                 .getValueName(), nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
411         }
412         // Empty random creation of mandatory fields for avoiding errors....
413         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
414             .setCostAlgorithm("Restricted Shortest Path - RSP")
415             .setCostName("HOP_COUNT")
416             .setCostValue("12345678")
417             .build();
418         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
419             .setFixedLatencyCharacteristic("12345678")
420             .setQueingLatencyCharacteristic("12345678")
421             .setJitterCharacteristic("12345678")
422             .setWanderCharacteristic("12345678")
423             .setTrafficPropertyName("FIXED_LATENCY")
424             .build();
425         return new NodeBuilder()
426             .setUuid(nodeUuid)
427             .setName(nodeNames)
428             .setLayerProtocolName(layerProtocols)
429             .setAdministrativeState(setTapiAdminState(this.ietfNodeAdminState))
430             .setOperationalState(setTapiOperationalState(this.ietfNodeOperState))
431             .setLifecycleState(LifecycleState.INSTALLED)
432             .setOwnedNodeEdgePoint(onepl)
433             .setNodeRuleGroup(nodeRuleGroupList)
434             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
435             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
436             .setErrorCharacteristic("error")
437             .setLossCharacteristic("loss")
438             .setRepeatDeliveryCharacteristic("repeat delivery")
439             .setDeliveryOrderCharacteristic("delivery order")
440             .setUnavailableTimeCharacteristic("unavailable time")
441             .setServerIntegrityProcessCharacteristic("server integrity process")
442             .build();
443     }
444
445     private AdministrativeState setTapiAdminState(AdminStates adminState) {
446         if (adminState == null) {
447             return null;
448         }
449         return adminState.equals(AdminStates.InService)
450             ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
451     }
452
453     private AdministrativeState setTapiAdminState(AdminStates adminState1, AdminStates adminState2) {
454         if (adminState1 == null || adminState2 == null) {
455             return null;
456         }
457         LOG.info("Admin state 1 = {}, andmin state 2 = {}", adminState1.getName(), adminState2.getName());
458         if (AdminStates.InService.equals(adminState1) && AdminStates.InService.equals(adminState2)) {
459             return AdministrativeState.UNLOCKED;
460         } else {
461             return AdministrativeState.LOCKED;
462         }
463     }
464
465     private OperationalState setTapiOperationalState(State operState) {
466         if (operState == null) {
467             return null;
468         }
469         return operState.getName().equals("inService") ? OperationalState.ENABLED : OperationalState.DISABLED;
470     }
471
472     private OperationalState setTapiOperationalState(State operState1, State operState2) {
473         if (operState1 == null || operState2 == null) {
474             return null;
475         }
476         LOG.info("Oper state 1 = {}, Oper state 2 = {}", operState1.getName(), operState2.getName());
477         if (State.InService.equals(operState1) && State.InService.equals(operState2)) {
478             return OperationalState.ENABLED;
479         } else {
480             return OperationalState.DISABLED;
481         }
482     }
483
484     private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node
485             createRoadmTapiNode(Uuid nodeUuid, Name nodeNames, List<LayerProtocolName> layerProtocols,
486                         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> oneplist) {
487         // Empty random creation of mandatory fields for avoiding errors....
488         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
489             .setCostAlgorithm("Restricted Shortest Path - RSP")
490             .setCostName("HOP_COUNT")
491             .setCostValue("12345678")
492             .build();
493         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
494             .setFixedLatencyCharacteristic("12345678")
495             .setQueingLatencyCharacteristic("12345678")
496             .setJitterCharacteristic("12345678")
497             .setWanderCharacteristic("12345678")
498             .setTrafficPropertyName("FIXED_LATENCY")
499             .build();
500         return new NodeBuilder()
501             .setUuid(nodeUuid)
502             .setName(Map.of(nodeNames.key(), nodeNames))
503             .setLayerProtocolName(layerProtocols)
504             .setAdministrativeState(AdministrativeState.UNLOCKED)
505             .setOperationalState(OperationalState.ENABLED)
506             .setLifecycleState(LifecycleState.INSTALLED)
507             .setOwnedNodeEdgePoint(oneplist)
508             .setNodeRuleGroup(createNodeRuleGroupForRdmNode(nodeUuid, oneplist.values()))
509             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
510             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
511             .setErrorCharacteristic("error")
512             .setLossCharacteristic("loss")
513             .setRepeatDeliveryCharacteristic("repeat delivery")
514             .setDeliveryOrderCharacteristic("delivery order")
515             .setUnavailableTimeCharacteristic("unavailable time")
516             .setServerIntegrityProcessCharacteristic("server integrity process")
517             .build();
518     }
519
520     private Uuid getNodeUuid4Photonic(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
521                                       Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
522                                       Map<RuleKey, Rule> ruleList) {
523         Uuid nodeUuid;
524         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI));
525         // iNep creation on otsi node
526         for (int i = 0; i < oorNetworkPortList.size(); i++) {
527             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, I_OTSI,
528                 oorNetworkPortList.get(i).getTpId().getValue()));
529             Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(
530                 (String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
531                     .getBytes(Charset.forName("UTF-8")))
532                 .toString());
533             this.uuidMap.put(String.join("+", this.ietfNodeId, I_OTSI,
534                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid1);
535             Name onedName = new NameBuilder()
536                 .setValueName("iNodeEdgePoint")
537                 .setValue(String.join("+", this.ietfNodeId, I_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
538                 .build();
539
540             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
541                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
542                 String.join("+", this.ietfNodeId, I_OTSI));
543             onepl.put(onep.key(), onep);
544         }
545         // eNep creation on otsi node
546         for (int i = 0; i < oorNetworkPortList.size(); i++) {
547             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, E_OTSI,
548                 oorNetworkPortList.get(i).getTpId().getValue()));
549             Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(
550                 (String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
551                     .getBytes(Charset.forName("UTF-8")))
552                 .toString());
553             this.uuidMap.put(String.join("+", this.ietfNodeId, E_OTSI,
554                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid2);
555             Name onedName = new NameBuilder()
556                 .setValueName("eNodeEdgePoint")
557                 .setValue(String.join("+", this.ietfNodeId, E_OTSI, oorNetworkPortList.get(i).getTpId().getValue()))
558                 .build();
559
560             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
561                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
562                 String.join("+", this.ietfNodeId, E_OTSI));
563             onepl.put(onep.key(), onep);
564         }
565         // Photonic Media Nep creation on otsi node
566         for (int i = 0; i < oorNetworkPortList.size(); i++) {
567             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, PHTNC_MEDIA,
568                 oorNetworkPortList.get(i).getTpId().getValue()));
569             Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(
570                 (String.join("+", this.ietfNodeId, PHTNC_MEDIA,
571                     oorNetworkPortList.get(i).getTpId().getValue())).getBytes(Charset.forName("UTF-8")))
572                 .toString());
573             this.uuidMap.put(String.join("+", this.ietfNodeId, PHTNC_MEDIA,
574                 oorNetworkPortList.get(i).getTpId().getValue()), nepUuid3);
575             Name onedName = new NameBuilder()
576                 .setValueName("PhotMedNodeEdgePoint")
577                 .setValue(String.join("+", this.ietfNodeId, PHTNC_MEDIA,
578                     oorNetworkPortList.get(i).getTpId().getValue()))
579                 .build();
580
581             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
582                 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, false,
583                 String.join("+", this.ietfNodeId, PHTNC_MEDIA));
584             onepl.put(onep.key(), onep);
585         }
586         // create NodeRuleGroup
587         int count = 1;
588         LOG.info("OTSi switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
589         for (TerminationPoint tp : this.oorNetworkPortList) {
590             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
591                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
592                 nepList = new HashMap<>();
593             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
594                 .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
595                 .node.rule.group.NodeEdgePointBuilder()
596                 .setTopologyUuid(tapiTopoUuid)
597                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
598                 .setNodeEdgePointUuid(
599                     this.uuidMap.get(String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue())))
600                 .build();
601             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
602                 .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210
603                 .node.rule.group.NodeEdgePointBuilder()
604                 .setTopologyUuid(tapiTopoUuid)
605                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
606                 .setNodeEdgePointUuid(
607                     this.uuidMap.get(String.join("+", this.ietfNodeId, E_OTSI, tp.getTpId().getValue())))
608                 .build();
609             nepList.put(inep.key(), inep);
610             nepList.put(enep.key(), enep);
611             // Empty random creation of mandatory fields for avoiding errors....
612             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
613                 .setCostAlgorithm("Restricted Shortest Path - RSP")
614                 .setCostName("HOP_COUNT")
615                 .setCostValue("12345678")
616                 .build();
617             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
618                 .setFixedLatencyCharacteristic("12345678")
619                 .setQueingLatencyCharacteristic("12345678")
620                 .setJitterCharacteristic("12345678")
621                 .setWanderCharacteristic("12345678")
622                 .setTrafficPropertyName("FIXED_LATENCY")
623                 .build();
624             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
625                 .setRiskCharacteristicName("risk characteristic")
626                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
627                 .build();
628             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
629                 .setUuid(new Uuid(
630                     UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8")))
631                         .toString()))
632                 .setRule(ruleList)
633                 .setNodeEdgePoint(nepList)
634                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
635                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
636                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
637                 .build();
638             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
639             count++;
640         }
641         return nodeUuid;
642     }
643
644     private Uuid getNodeUuid4Dsr(Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
645                                  Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList, Map<RuleKey, Rule> ruleList) {
646         Uuid nodeUuid;
647         nodeUuid = this.uuidMap.get(String.join("+", this.ietfNodeId, DSR));
648         // client nep creation on DSR node
649         for (int i = 0; i < oorClientPortList.size(); i++) {
650             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, DSR,
651                 oorClientPortList.get(i).getTpId().getValue()));
652             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
653                 (String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()))
654                     .getBytes(Charset.forName("UTF-8"))).toString());
655             this.uuidMap.put(String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()),
656                 nepUuid);
657             NameBuilder nameBldr = new NameBuilder().setValue(
658                 String.join("+", this.ietfNodeId, DSR, oorClientPortList.get(i).getTpId().getValue()));
659             Name name;
660             if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
661                 name = nameBldr.setValueName("100G-tpdr").build();
662             } else {
663                 name = nameBldr.setValueName("NodeEdgePoint_C").build();
664             }
665
666             OwnedNodeEdgePoint onep = createNep(oorClientPortList.get(i), Map.of(name.key(), name),
667                 LayerProtocolName.DSR, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, DSR));
668             onepl.put(onep.key(), onep);
669         }
670         // network nep creation on I_ODU node
671         for (int i = 0; i < oorNetworkPortList.size(); i++) {
672             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, I_ODU,
673                 oorNetworkPortList.get(i).getTpId().getValue()));
674             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
675                 (String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
676                     .getBytes(Charset.forName("UTF-8"))).toString());
677             this.uuidMap.put(String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()),
678                 nepUuid);
679             Name onedName = new NameBuilder()
680                 .setValueName("iNodeEdgePoint_N")
681                 .setValue(String.join("+", this.ietfNodeId, I_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
682                 .build();
683
684             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
685                 LayerProtocolName.ODU, LayerProtocolName.DSR, false, String.join("+", this.ietfNodeId, I_ODU));
686             onepl.put(onep.key(), onep);
687         }
688         // network nep creation on E_ODU node
689         for (int i = 0; i < oorNetworkPortList.size(); i++) {
690             LOG.info("NEP = {}", String.join("+", this.ietfNodeId, E_ODU,
691                 oorNetworkPortList.get(i).getTpId().getValue()));
692             Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(
693                 (String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
694                     .getBytes(Charset.forName("UTF-8"))).toString());
695             this.uuidMap.put(String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()),
696                 nepUuid);
697             Name onedName = new NameBuilder()
698                 .setValueName("eNodeEdgePoint_N")
699                 .setValue(String.join("+", this.ietfNodeId, E_ODU, oorNetworkPortList.get(i).getTpId().getValue()))
700                 .build();
701
702             OwnedNodeEdgePoint onep = createNep(oorNetworkPortList.get(i), Map.of(onedName.key(), onedName),
703                 LayerProtocolName.ODU, LayerProtocolName.DSR, true, String.join("+", this.ietfNodeId, E_ODU));
704             onepl.put(onep.key(), onep);
705         }
706         // create NodeRuleGroup
707         int count = 1;
708         LOG.info("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
709         for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
710             Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
711                 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
712                 nepList = new HashMap<>();
713             LOG.info("UUidMap={}", this.uuidMap.keySet());
714             LOG.info("TP list = {}", nbl.getTpList());
715             for (TpId tp : nbl.getTpList()) {
716                 LOG.info("TP={}", tp.getValue());
717                 LOG.info("UuidKey={}", String.join("+", this.ietfNodeId, E_ODU, tp.getValue()));
718                 if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, E_ODU, tp.getValue()))
719                     || this.uuidMap.containsKey(String.join("+", this.ietfNodeId, DSR, tp.getValue()))) {
720                     org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
721                         nep = new org.opendaylight.yang.gen.v1.urn
722                         .onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointBuilder()
723                         .setTopologyUuid(tapiTopoUuid)
724                         .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR)))
725                         .setNodeEdgePointUuid((tp.getValue().contains("CLIENT")) ? this.uuidMap.get(String.join(
726                             "+", this.ietfNodeId, DSR, tp.getValue())) : this.uuidMap.get(String.join(
727                             "+", this.ietfNodeId, E_ODU, tp.getValue())))
728                         .build();
729                     nepList.put(nep.key(), nep);
730                 }
731             }
732             // Empty random creation of mandatory fields for avoiding errors....
733             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
734                 .setCostAlgorithm("Restricted Shortest Path - RSP")
735                 .setCostName("HOP_COUNT")
736                 .setCostValue("12345678")
737                 .build();
738             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
739                 .setFixedLatencyCharacteristic("12345678")
740                 .setQueingLatencyCharacteristic("12345678")
741                 .setJitterCharacteristic("12345678")
742                 .setWanderCharacteristic("12345678")
743                 .setTrafficPropertyName("FIXED_LATENCY")
744                 .build();
745             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
746                 .setRiskCharacteristicName("risk characteristic")
747                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
748                 .build();
749             NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
750                 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("dsr node rule group " + count)
751                     .getBytes(Charset.forName("UTF-8"))).toString()))
752                 .setRule(ruleList)
753                 .setNodeEdgePoint(nepList)
754                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
755                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
756                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
757                 .build();
758             nodeRuleGroupList.put(nodeRuleGroup.key(), nodeRuleGroup);
759             count++;
760         }
761         return nodeUuid;
762     }
763
764     private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
765                                          LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip,
766                                          String keyword) {
767         String key = String.join("+", keyword, oorTp.getTpId().getValue());
768         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
769             .setUuid(this.uuidMap.get(key))
770             .setLayerProtocolName(nepProtocol)
771             .setName(nepNames);
772         if (withSip) {
773             onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, oorTp, keyword));
774         }
775         onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier(oorTp, nodeProtocol))
776             .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
777             .setLinkPortRole(PortRole.SYMMETRIC)
778             .setAdministrativeState(setTapiAdminState(
779                 oorTp.augmentation(TerminationPoint1.class).getAdministrativeState()))
780             .setOperationalState(setTapiOperationalState(
781                 oorTp.augmentation(TerminationPoint1.class).getOperationalState()))
782             .setLifecycleState(LifecycleState.INSTALLED)
783             .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
784             .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
785         return onepBldr.build();
786     }
787
788     private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> populateNepsForRdmNode(List<TerminationPoint> tpList,
789                                                                                   boolean withSip) {
790         // create neps for MC and OTSiMC and Photonic Media
791         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
792         for (TerminationPoint tp:tpList) {
793             // Admin and oper state common for all tps
794             AdminStates admin = tp.augmentation(TerminationPoint1.class).getAdministrativeState();
795             State oper = tp.augmentation(TerminationPoint1.class).getOperationalState();
796             // PHOTONIC MEDIA nep
797             LOG.info("PHOTO NEP = {}", String.join("+", this.ietfNodeId, PHTNC_MEDIA, tp.getTpId().getValue()));
798             Name nepName = new NameBuilder()
799                 .setValueName(PHTNC_MEDIA + "NodeEdgePoint")
800                 .setValue(String.join("+", this.ietfNodeId, PHTNC_MEDIA, tp.getTpId().getValue()))
801                 .build();
802
803             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
804                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, PHTNC_MEDIA,
805                     tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString()))
806                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
807                 .setName(Map.of(nepName.key(), nepName))
808                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
809                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
810                 .setLinkPortRole(PortRole.SYMMETRIC)
811                 .setAdministrativeState(setTapiAdminState(admin))
812                 .setOperationalState(setTapiOperationalState(oper))
813                 .setLifecycleState(LifecycleState.INSTALLED)
814                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
815                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
816                 .build();
817             onepMap.put(onep.key(), onep);
818
819             // MC nep
820             LOG.info("MC NEP = {}", String.join("+", this.ietfNodeId, MC, tp.getTpId().getValue()));
821             Name nepName1 = new NameBuilder()
822                 .setValueName(MC + "NodeEdgePoint")
823                 .setValue(String.join("+", this.ietfNodeId, MC, tp.getTpId().getValue()))
824                 .build();
825             OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder()
826                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, MC,
827                     tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString()))
828                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
829                 .setName(Map.of(nepName1.key(), nepName1))
830                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
831                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
832                 .setLinkPortRole(PortRole.SYMMETRIC)
833                 .setAdministrativeState(setTapiAdminState(admin))
834                 .setOperationalState(setTapiOperationalState(oper))
835                 .setLifecycleState(LifecycleState.INSTALLED)
836                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
837                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL);
838             if (withSip) {
839                 onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA,
840                     tp, String.join("+", this.ietfNodeId, MC)));
841             }
842             OwnedNodeEdgePoint onep1 = onepBldr1.build();
843             onepMap.put(onep1.key(), onep1);
844
845             // OTSiMC nep
846             LOG.info("OTSi NEP = {}", String.join("+", this.ietfNodeId, OTSI_MC, tp.getTpId().getValue()));
847             Name nepName2 = new NameBuilder()
848                 .setValueName(OTSI_MC + "NodeEdgePoint")
849                 .setValue(String.join("+", this.ietfNodeId, OTSI_MC, tp.getTpId().getValue()))
850                 .build();
851
852             OwnedNodeEdgePoint onep2 = new OwnedNodeEdgePointBuilder()
853                 .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", this.ietfNodeId, OTSI_MC,
854                     tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString()))
855                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
856                 .setName(Map.of(nepName2.key(), nepName2))
857                 .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class))
858                 .setLinkPortDirection(PortDirection.BIDIRECTIONAL)
859                 .setLinkPortRole(PortRole.SYMMETRIC)
860                 .setAdministrativeState(setTapiAdminState(admin))
861                 .setOperationalState(setTapiOperationalState(oper))
862                 .setLifecycleState(LifecycleState.INSTALLED)
863                 .setTerminationDirection(TerminationDirection.BIDIRECTIONAL)
864                 .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL)
865                 .build();
866             onepMap.put(onep2.key(), onep2);
867         }
868         return onepMap;
869     }
870
871     private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(Uuid nodeUuid,
872                                                                                Collection<OwnedNodeEdgePoint> onepl) {
873         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
874             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
875             nepMap = new HashMap<>();
876         for (OwnedNodeEdgePoint onep : onepl) {
877             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint
878                 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
879                 .NodeEdgePointBuilder()
880                 .setTopologyUuid(tapiTopoUuid)
881                 .setNodeUuid(nodeUuid)
882                 .setNodeEdgePointUuid(onep.key().getUuid())
883                 .build();
884             nepMap.put(nep.key(), nep);
885         }
886         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
887         Map<RuleKey, Rule> ruleList = new HashMap<>();
888         Rule rule = new RuleBuilder()
889             .setLocalId("forward")
890             .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
891             .setRuleType(RuleType.FORWARDING)
892             .build();
893         ruleList.put(rule.key(), rule);
894         NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
895             .setUuid(new Uuid(UUID.nameUUIDFromBytes((this.ietfNodeId + " node rule group")
896                 .getBytes(Charset.forName("UTF-8"))).toString()))
897             .setRule(ruleList)
898             .setNodeEdgePoint(nepMap)
899             .build();
900         nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
901         return nodeRuleGroupMap;
902     }
903
904     private Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
905                                                                                         LayerProtocolName layerProtocol,
906                                                                                         TerminationPoint tp,
907                                                                                         String nodeid) {
908         // add them to SIP context
909         Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
910         for (int i = 0; i < nb; i++) {
911             LOG.info("SIP = {}", String.join("+", "SIP", nodeid, tp.getTpId().getValue()));
912             Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid,
913                 tp.getTpId().getValue())).getBytes(Charset.forName("UTF-8"))).toString());
914             MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
915                 .setServiceInterfacePointUuid(sipUuid).build();
916             ServiceInterfacePoint sip = createSIP(sipUuid, layerProtocol, tp, nodeid);
917             this.tapiSips.put(sip.key(), sip);
918             msipl.put(msip.key(), msip);
919         }
920         return msipl;
921     }
922
923     private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, TerminationPoint tp,
924                                             String nodeid) {
925         // TODO: what value should be set in total capacity and available capacity??
926         // LOG.info("SIP name = {}", String.join("+", nodeid, tp.getTpId().getValue()));
927         Name sipName = new NameBuilder()
928             .setValueName("SIP name")
929             .setValue(String.join("+", nodeid, tp.getTpId().getValue()))
930             .build();
931         return new ServiceInterfacePointBuilder()
932             .setUuid(sipUuid)
933             .setName(Map.of(sipName.key(), sipName))
934             .setLayerProtocolName(layerProtocol)
935             .setAdministrativeState(setTapiAdminState(
936                 tp.augmentation(TerminationPoint1.class).getAdministrativeState()))
937             .setOperationalState(setTapiOperationalState(
938                 tp.augmentation(TerminationPoint1.class).getOperationalState()))
939             .setLifecycleState(LifecycleState.INSTALLED)
940             .setAvailableCapacity(new AvailableCapacityBuilder().build())
941             .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
942             .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(tp, layerProtocol))
943             .build();
944     }
945
946     private List<Class<? extends LAYERPROTOCOLQUALIFIER>> createSupportedLayerProtocolQualifier(TerminationPoint tp,
947                                                                                                 LayerProtocolName lpn) {
948         Set<Class<? extends LAYERPROTOCOLQUALIFIER>> sclpqSet = new HashSet<>();
949         List<SupportedInterfaceCapability> sicList;
950         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1 tp1 =
951             tp.augmentation(org.opendaylight.yang.gen.v1.http
952                 .org.openroadm.otn.network.topology.rev200529.TerminationPoint1.class);
953         if (tp1 == null) {
954             return new ArrayList<>(sclpqSet);
955         }
956         if (tp1.getTpSupportedInterfaces() == null) {
957             LOG.warn("Tp supported interface doesnt exist on TP {}", tp.getTpId().getValue());
958             return new ArrayList<>(sclpqSet);
959         }
960         sicList = new ArrayList<>(tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values());
961         for (SupportedInterfaceCapability sic : sicList) {
962             switch (lpn.getName()) {
963                 case "DSR":
964                     switch (sic.getIfCapType().getSimpleName()) {
965                         case "If10GEODU2e":
966                             sclpqSet.add(ODUTYPEODU2E.class);
967                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
968                             break;
969                         case "If10GEODU2":
970                             sclpqSet.add(ODUTYPEODU2.class);
971                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
972                             break;
973                         case "If10GE":
974                             sclpqSet.add(DIGITALSIGNALTYPE10GigELAN.class);
975                             break;
976                         case "If100GEODU4":
977                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
978                             sclpqSet.add(ODUTYPEODU4.class);
979                             break;
980                         case "If100GE":
981                             sclpqSet.add(DIGITALSIGNALTYPE100GigE.class);
982                             break;
983                         case "IfOCHOTU4ODU4":
984                         case "IfOCH":
985                             sclpqSet.add(ODUTYPEODU4.class);
986                             break;
987                         default:
988                             LOG.error("IfCapability type not managed");
989                             break;
990                     }
991                     break;
992                 case "PHOTONIC_MEDIA":
993                     if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4")
994                         || sic.getIfCapType().getSimpleName().equals("IfOCH")) {
995                         sclpqSet.add(PHOTONICLAYERQUALIFIEROTSi.class);
996                         sclpqSet.add(PHOTONICLAYERQUALIFIEROMS.class);
997                     }
998                     break;
999                 default:
1000                     LOG.error("Layer Protocol Name is unknown");
1001                     break;
1002             }
1003         }
1004         return new ArrayList<>(sclpqSet);
1005     }
1006
1007     private void createTapiTransitionalLinks() {
1008         for (TerminationPoint tp : this.oorNetworkPortList) {
1009             Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1010             String sourceKey = String.join("+", this.ietfNodeId, I_ODU, tp.getTpId().getValue());
1011             Uuid sourceUuidTp = this.uuidMap.get(sourceKey);
1012             String destKey = String.join("+", this.ietfNodeId, I_OTSI, tp.getTpId().getValue());
1013             Uuid destUuidTp = this.uuidMap.get(destKey);
1014             NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1015                 .setTopologyUuid(this.tapiTopoUuid)
1016                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, DSR)))
1017                 .setNodeEdgePointUuid(sourceUuidTp)
1018                 .build();
1019             nepList.put(sourceNep.key(), sourceNep);
1020             NodeEdgePoint destNep = new NodeEdgePointBuilder()
1021                 .setTopologyUuid(this.tapiTopoUuid)
1022                 .setNodeUuid(this.uuidMap.get(String.join("+", this.ietfNodeId, OTSI)))
1023                 .setNodeEdgePointUuid(destUuidTp)
1024                 .build();
1025             nepList.put(destNep.key(), destNep);
1026             Name linkName = new NameBuilder().setValueName("transitional link name")
1027                 .setValue(String.join("--", this.ietfNodeId, sourceKey, destKey))
1028                 .build();
1029             CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1030                 .setCostAlgorithm("Restricted Shortest Path - RSP")
1031                 .setCostName("HOP_COUNT")
1032                 .setCostValue("12345678")
1033                 .build();
1034             LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1035                 .setFixedLatencyCharacteristic("12345678")
1036                 .setQueingLatencyCharacteristic("12345678")
1037                 .setJitterCharacteristic("12345678")
1038                 .setWanderCharacteristic("12345678")
1039                 .setTrafficPropertyName("FIXED_LATENCY")
1040                 .build();
1041             RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1042                 .setRiskCharacteristicName("risk characteristic")
1043                 .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1044                 .build();
1045             ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1046                 .setValidationMechanism("validation mechanism")
1047                 .setValidationRobustness("validation robustness")
1048                 .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1049                 .build();
1050             Link transiLink = new LinkBuilder()
1051                 .setUuid(new Uuid(
1052                     UUID.nameUUIDFromBytes((String.join("--", this.ietfNodeId, sourceKey, destKey))
1053                         .getBytes(Charset.forName("UTF-8")))
1054                         .toString()))
1055                 .setName(Map.of(linkName.key(), linkName))
1056                 .setTransitionedLayerProtocolName(Arrays.asList(LayerProtocolName.ODU.getName(),
1057                     LayerProtocolName.PHOTONICMEDIA.getName()))
1058                 .setLayerProtocolName(Arrays.asList(LayerProtocolName.ODU, LayerProtocolName.PHOTONICMEDIA))
1059                 .setNodeEdgePoint(nepList)
1060                 .setDirection(ForwardingDirection.BIDIRECTIONAL)
1061                 .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1062                     new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
1063                     .build())
1064                 .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1065                     .setRestorationPolicy(RestorationPolicy.NA)
1066                     .build())
1067                 .setAdministrativeState(AdministrativeState.UNLOCKED)
1068                 .setOperationalState(OperationalState.ENABLED)
1069                 .setLifecycleState(LifecycleState.INSTALLED)
1070                 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1071                     new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build())
1072                     .build())
1073                 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1074                 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1075                 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1076                 .setErrorCharacteristic("error")
1077                 .setLossCharacteristic("loss")
1078                 .setRepeatDeliveryCharacteristic("repeat delivery")
1079                 .setDeliveryOrderCharacteristic("delivery order")
1080                 .setUnavailableTimeCharacteristic("unavailable time")
1081                 .setServerIntegrityProcessCharacteristic("server integrity process")
1082                 .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1083                 .build();
1084             this.tapiLinks.put(transiLink.key(), transiLink);
1085         }
1086     }
1087
1088     private Link createTapiLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1089                                     .ietf.network.topology.rev180226.networks.network.Link link,
1090                                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1091                                     .ietf.network.topology.rev180226.networks.network.Link oppositeLink) {
1092         String prefix = link.getLinkId().getValue().split("-")[0];
1093         String sourceNode = link.getSource().getSourceNode().getValue();
1094         String sourceTp = link.getSource().getSourceTp().getValue();
1095         String destNode = link.getDestination().getDestNode().getValue();
1096         String destTp = link.getDestination().getDestTp().getValue();
1097         LOG.info("prefix = {}, sourceNode = {}, sourceTp = {}, destNode = {}, destTp = {}",
1098                 prefix, sourceNode, sourceTp, destNode, destTp);
1099         Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1100         Uuid sourceUuidTp;
1101         Uuid sourceUuidNode;
1102         Uuid destUuidTp;
1103         Uuid destUuidNode;
1104         Name linkName;
1105         AdminStates oppositeLinkAdminState = null;
1106         State oppositeLinkOperState = null;
1107         if (oppositeLink != null) {
1108             oppositeLinkAdminState = oppositeLink.augmentation(
1109                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1110                 .getAdministrativeState();
1111             oppositeLinkOperState = oppositeLink.augmentation(
1112                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1113                 .getOperationalState();
1114         }
1115         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1116             .setCostAlgorithm("Restricted Shortest Path - RSP")
1117             .setCostName("HOP_COUNT")
1118             .setCostValue("12345678")
1119             .build();
1120         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1121             .setFixedLatencyCharacteristic("12345678")
1122             .setQueingLatencyCharacteristic("12345678")
1123             .setJitterCharacteristic("12345678")
1124             .setWanderCharacteristic("12345678")
1125             .setTrafficPropertyName("FIXED_LATENCY")
1126             .build();
1127         RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1128             .setRiskCharacteristicName("risk characteristic")
1129             .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1130             .build();
1131         ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1132             .setValidationMechanism("validation mechanism")
1133             .setValidationRobustness("validation robustness")
1134             .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1135             .build();
1136         switch (prefix) {
1137             case "OTU4":
1138                 sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, I_OTSI, sourceTp));
1139                 sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, OTSI));
1140                 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1141                     .setTopologyUuid(this.tapiTopoUuid)
1142                     .setNodeUuid(sourceUuidNode)
1143                     .setNodeEdgePointUuid(sourceUuidTp)
1144                     .build();
1145                 nepList.put(sourceNep.key(), sourceNep);
1146                 destUuidTp = this.uuidMap.get(String.join("+", destNode, I_OTSI, destTp));
1147                 destUuidNode = this.uuidMap.get(String.join("+", destNode, OTSI));
1148                 NodeEdgePoint destNep = new NodeEdgePointBuilder()
1149                     .setTopologyUuid(this.tapiTopoUuid)
1150                     .setNodeUuid(destUuidNode)
1151                     .setNodeEdgePointUuid(destUuidTp)
1152                     .build();
1153                 nepList.put(destNep.key(), destNep);
1154                 linkName = new NameBuilder().setValueName("otn link name")
1155                     .setValue(link.getLinkId().getValue())
1156                     .build();
1157                 return new LinkBuilder()
1158                     .setUuid(new Uuid(UUID.nameUUIDFromBytes((link.getLinkId().getValue())
1159                         .getBytes(Charset.forName("UTF-8"))).toString()))
1160                     .setName(Map.of(linkName.key(), linkName))
1161                     .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA))
1162                     .setTransitionedLayerProtocolName(new ArrayList<>())
1163                     .setAdministrativeState(setTapiAdminState(link
1164                         .augmentation(
1165                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1166                         .getAdministrativeState(), oppositeLinkAdminState))
1167                     .setOperationalState(setTapiOperationalState(link
1168                         .augmentation(
1169                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1170                         .getOperationalState(), oppositeLinkOperState))
1171                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1172                     .setNodeEdgePoint(nepList)
1173                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1174                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1175                             .setValue(Uint64.valueOf(100)).build()).build())
1176                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1177                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1178                             .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build())
1179                         .build())
1180                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1181                         .setRestorationPolicy(RestorationPolicy.NA)
1182                         .build())
1183                     .setLifecycleState(LifecycleState.INSTALLED)
1184                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1185                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1186                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1187                     .setErrorCharacteristic("error")
1188                     .setLossCharacteristic("loss")
1189                     .setRepeatDeliveryCharacteristic("repeat delivery")
1190                     .setDeliveryOrderCharacteristic("delivery order")
1191                     .setUnavailableTimeCharacteristic("unavailable time")
1192                     .setServerIntegrityProcessCharacteristic("server integrity process")
1193                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1194                     .build();
1195             case "ODTU4":
1196                 sourceUuidTp = this.uuidMap.get(String.join("+", sourceNode, E_ODU, sourceTp));
1197                 sourceUuidNode = this.uuidMap.get(String.join("+", sourceNode, DSR));
1198                 NodeEdgePoint sourceNep2 = new NodeEdgePointBuilder()
1199                     .setTopologyUuid(this.tapiTopoUuid)
1200                     .setNodeUuid(sourceUuidNode)
1201                     .setNodeEdgePointUuid(sourceUuidTp)
1202                     .build();
1203                 nepList.put(sourceNep2.key(), sourceNep2);
1204                 destUuidTp = this.uuidMap.get(String.join("+", destNode, E_ODU, destTp));
1205                 destUuidNode = this.uuidMap.get(String.join("+", destNode, DSR));
1206                 NodeEdgePoint destNep2 = new NodeEdgePointBuilder()
1207                     .setTopologyUuid(this.tapiTopoUuid)
1208                     .setNodeUuid(destUuidNode)
1209                     .setNodeEdgePointUuid(destUuidTp)
1210                     .build();
1211                 nepList.put(destNep2.key(), destNep2);
1212                 linkName = new NameBuilder().setValueName("otn link name")
1213                     .setValue(link.getLinkId().getValue())
1214                     .build();
1215                 return new LinkBuilder()
1216                     .setUuid(new Uuid(UUID.nameUUIDFromBytes((link.getLinkId().getValue())
1217                         .getBytes(Charset.forName("UTF-8"))).toString()))
1218                     .setName(Map.of(linkName.key(), linkName))
1219                     .setLayerProtocolName(Arrays.asList(LayerProtocolName.ODU))
1220                     .setTransitionedLayerProtocolName(new ArrayList<>())
1221                     .setAdministrativeState(setTapiAdminState(link
1222                         .augmentation(
1223                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1224                         .getAdministrativeState(), oppositeLinkAdminState))
1225                     .setOperationalState(setTapiOperationalState(link
1226                         .augmentation(
1227                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1228                         .getOperationalState(), oppositeLinkOperState))
1229                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1230                     .setNodeEdgePoint(nepList)
1231                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1232                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1233                             .setValue(Uint64.valueOf(100)).build()).build())
1234                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1235                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1236                             .setValue(Uint64.valueOf(link.augmentation(Link1.class).getAvailableBandwidth())).build())
1237                         .build())
1238                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1239                         .setRestorationPolicy(RestorationPolicy.NA)
1240                         .build())
1241                     .setLifecycleState(LifecycleState.INSTALLED)
1242                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1243                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1244                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1245                     .setErrorCharacteristic("error")
1246                     .setLossCharacteristic("loss")
1247                     .setRepeatDeliveryCharacteristic("repeat delivery")
1248                     .setDeliveryOrderCharacteristic("delivery order")
1249                     .setUnavailableTimeCharacteristic("unavailable time")
1250                     .setServerIntegrityProcessCharacteristic("server integrity process")
1251                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1252                     .build();
1253             default:
1254                 LOG.error("OTN link of type {} not managed yet", prefix);
1255                 return null;
1256         }
1257     }
1258
1259     private Link createTapiOmsLink(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1260                                        .ietf.network.topology.rev180226.networks.network.Link link,
1261                                    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1262                                        .ietf.network.topology.rev180226.networks.network.Link oppositeLink) {
1263         String sourceNode = getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue());
1264         String sourceTp = link.getSource().getSourceTp().getValue();
1265         String destNode = getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue());
1266         String destTp = link.getDestination().getDestTp().getValue();
1267         AdminStates oppositeLinkAdminState = null;
1268         State oppositeLinkOperState = null;
1269         if (oppositeLink != null) {
1270             oppositeLinkAdminState = oppositeLink.augmentation(
1271                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1272                 .getAdministrativeState();
1273             oppositeLinkOperState = oppositeLink.augmentation(
1274                 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1275                 .getOperationalState();
1276         }
1277         Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1278         Uuid sourceUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode,
1279             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
1280         Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode, PHTNC_MEDIA, sourceTp))
1281             .getBytes(Charset.forName("UTF-8"))).toString());
1282         Uuid destUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode,
1283             PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
1284         Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode, PHTNC_MEDIA, destTp))
1285             .getBytes(Charset.forName("UTF-8"))).toString());
1286         NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1287             .setTopologyUuid(this.tapiTopoUuid)
1288             .setNodeUuid(sourceUuidNode)
1289             .setNodeEdgePointUuid(sourceUuidTp)
1290             .build();
1291         nepList.put(sourceNep.key(), sourceNep);
1292         NodeEdgePoint destNep = new NodeEdgePointBuilder()
1293             .setTopologyUuid(this.tapiTopoUuid)
1294             .setNodeUuid(destUuidNode)
1295             .setNodeEdgePointUuid(destUuidTp)
1296             .build();
1297         nepList.put(destNep.key(), destNep);
1298         Name linkName = new NameBuilder().setValueName("OMS link name")
1299             .setValue(link.getLinkId().getValue())
1300             .build();
1301         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1302             .setCostAlgorithm("Restricted Shortest Path - RSP")
1303             .setCostName("HOP_COUNT")
1304             .setCostValue("12345678")
1305             .build();
1306         LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1307             .setFixedLatencyCharacteristic("12345678")
1308             .setQueingLatencyCharacteristic("12345678")
1309             .setJitterCharacteristic("12345678")
1310             .setWanderCharacteristic("12345678")
1311             .setTrafficPropertyName("FIXED_LATENCY")
1312             .build();
1313         RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1314             .setRiskCharacteristicName("risk characteristic")
1315             .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1316             .build();
1317         ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1318             .setValidationMechanism("validation mechanism")
1319             .setValidationRobustness("validation robustness")
1320             .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1321             .build();
1322         return new LinkBuilder()
1323             .setUuid(new Uuid(
1324                 UUID.nameUUIDFromBytes((link.getLinkId().getValue()).getBytes(Charset.forName("UTF-8")))
1325                     .toString()))
1326             .setName(Map.of(linkName.key(), linkName))
1327             .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
1328             .setTransitionedLayerProtocolName(new ArrayList<>())
1329             .setNodeEdgePoint(nepList)
1330             .setDirection(ForwardingDirection.BIDIRECTIONAL)
1331             .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1332                 .setRestorationPolicy(RestorationPolicy.NA)
1333                 .build())
1334             .setAdministrativeState(setTapiAdminState(link
1335                 .augmentation(
1336                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1337                 .getAdministrativeState(), oppositeLinkAdminState))
1338             .setOperationalState(setTapiOperationalState(link
1339                 .augmentation(
1340                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1341                 .getOperationalState(), oppositeLinkOperState))
1342             .setLifecycleState(LifecycleState.INSTALLED)
1343             .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1344                 new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1345                     .setValue(Uint64.valueOf(100)).build()).build())
1346             .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1347                 new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1348                     .setValue(Uint64.valueOf(100)).build())
1349                 .build())
1350             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1351             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1352             .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1353             .setErrorCharacteristic("error")
1354             .setLossCharacteristic("loss")
1355             .setRepeatDeliveryCharacteristic("repeat delivery")
1356             .setDeliveryOrderCharacteristic("delivery order")
1357             .setUnavailableTimeCharacteristic("unavailable time")
1358             .setServerIntegrityProcessCharacteristic("server integrity process")
1359             .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1360             .build();
1361     }
1362
1363     public void convertXpdrToRdmLinks(List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1364             .ietf.network.topology.rev180226.networks.network.Link> xpdrRdmLinkList) {
1365         List<String> linksToNotConvert = new ArrayList<>();
1366         LOG.info("creation of {} xpdr to roadm links", xpdrRdmLinkList.size() / 2);
1367         // LOG.info("Link list = {}", xpdrRdmLinkList.toString());
1368         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1369             .ietf.network.topology.rev180226.networks.network.Link link:xpdrRdmLinkList) {
1370             if (!linksToNotConvert.contains(link.getLinkId().getValue())) {
1371                 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
1372                     .ietf.network.topology.rev180226.networks.network.Link oppositeLink = xpdrRdmLinkList.stream()
1373                     .filter(l -> l.getLinkId().equals(link.augmentation(org.opendaylight.yang.gen.v1.http
1374                         .org.openroadm.common.network.rev200529.Link1.class).getOppositeLink())).findAny().orElse(null);
1375
1376                 AdminStates oppositeLinkAdminState = null;
1377                 State oppositeLinkOperState = null;
1378                 if (oppositeLink != null) {
1379                     oppositeLinkAdminState = oppositeLink.augmentation(
1380                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1381                         .getAdministrativeState();
1382                     oppositeLinkOperState = oppositeLink.augmentation(
1383                         org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1384                         .getOperationalState();
1385                 }
1386
1387                 String sourceNode = (link.getSource().getSourceNode().getValue().contains("ROADM"))
1388                     ? getIdBasedOnModelVersion(link.getSource().getSourceNode().getValue())
1389                     : link.getSource().getSourceNode().getValue();
1390                 String sourceTp = link.getSource().getSourceTp().getValue();
1391                 String destNode = (link.getDestination().getDestNode().getValue().contains("ROADM"))
1392                     ? getIdBasedOnModelVersion(link.getDestination().getDestNode().getValue())
1393                     : link.getDestination().getDestNode().getValue();
1394                 String destTp = link.getDestination().getDestTp().getValue();
1395                 Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
1396                 Uuid sourceUuidNode = (sourceNode.contains("ROADM")) ? new Uuid(UUID.nameUUIDFromBytes((
1397                     String.join("+", sourceNode, PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString())
1398                     : new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode, OTSI))
1399                         .getBytes(Charset.forName("UTF-8"))).toString());
1400                 Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes(
1401                     (String.join("+", sourceNode, PHTNC_MEDIA, sourceTp))
1402                         .getBytes(Charset.forName("UTF-8"))).toString());
1403                 Uuid destUuidNode = (destNode.contains("ROADM")) ? new Uuid(UUID.nameUUIDFromBytes((
1404                     String.join("+", destNode, PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString())
1405                     : new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode, OTSI))
1406                         .getBytes(Charset.forName("UTF-8"))).toString());
1407                 Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode,
1408                     PHTNC_MEDIA, destTp)).getBytes(Charset.forName("UTF-8"))).toString());
1409                 NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
1410                     .setTopologyUuid(this.tapiTopoUuid)
1411                     .setNodeUuid(sourceUuidNode)
1412                     .setNodeEdgePointUuid(sourceUuidTp)
1413                     .build();
1414                 nepList.put(sourceNep.key(), sourceNep);
1415                 NodeEdgePoint destNep = new NodeEdgePointBuilder()
1416                     .setTopologyUuid(this.tapiTopoUuid)
1417                     .setNodeUuid(destUuidNode)
1418                     .setNodeEdgePointUuid(destUuidTp)
1419                     .build();
1420                 nepList.put(destNep.key(), destNep);
1421                 Name linkName = new NameBuilder().setValueName("XPDR-RDM link name")
1422                     .setValue(link.getLinkId().getValue())
1423                     .build();
1424                 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1425                     .setCostAlgorithm("Restricted Shortest Path - RSP")
1426                     .setCostName("HOP_COUNT")
1427                     .setCostValue("12345678")
1428                     .build();
1429                 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1430                     .setFixedLatencyCharacteristic("12345678")
1431                     .setQueingLatencyCharacteristic("12345678")
1432                     .setJitterCharacteristic("12345678")
1433                     .setWanderCharacteristic("12345678")
1434                     .setTrafficPropertyName("FIXED_LATENCY")
1435                     .build();
1436                 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1437                     .setRiskCharacteristicName("risk characteristic")
1438                     .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
1439                     .build();
1440                 ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
1441                     .setValidationMechanism("validation mechanism")
1442                     .setValidationRobustness("validation robustness")
1443                     .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
1444                     .build();
1445                 Link tapiLink = new LinkBuilder()
1446                     .setUuid(new Uuid(
1447                         UUID.nameUUIDFromBytes((link.getLinkId().getValue()).getBytes(Charset.forName("UTF-8")))
1448                             .toString()))
1449                     .setName(Map.of(linkName.key(), linkName))
1450                     .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
1451                     .setTransitionedLayerProtocolName(new ArrayList<>())
1452                     .setNodeEdgePoint(nepList)
1453                     .setDirection(ForwardingDirection.BIDIRECTIONAL)
1454                     .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
1455                         .setRestorationPolicy(RestorationPolicy.NA)
1456                         .build())
1457                     .setAdministrativeState(setTapiAdminState(link
1458                         .augmentation(
1459                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1460                         .getAdministrativeState(), oppositeLinkAdminState))
1461                     .setOperationalState(setTapiOperationalState(link
1462                         .augmentation(
1463                             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1464                         .getOperationalState(), oppositeLinkOperState))
1465                     .setLifecycleState(LifecycleState.INSTALLED)
1466                     .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
1467                         new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
1468                             .setValue(Uint64.valueOf(100)).build()).build())
1469                     .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
1470                         new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
1471                             .setValue(Uint64.valueOf(100)).build())
1472                         .build())
1473                     .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1474                     .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1475                     .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1476                     .setErrorCharacteristic("error")
1477                     .setLossCharacteristic("loss")
1478                     .setRepeatDeliveryCharacteristic("repeat delivery")
1479                     .setDeliveryOrderCharacteristic("delivery order")
1480                     .setUnavailableTimeCharacteristic("unavailable time")
1481                     .setServerIntegrityProcessCharacteristic("server integrity process")
1482                     .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
1483                     .build();
1484                 linksToNotConvert.add(link
1485                     .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1.class)
1486                     .getOppositeLink().getValue());
1487                 this.tapiLinks.put(tapiLink.key(), tapiLink);
1488             }
1489         }
1490     }
1491
1492     private String getIdBasedOnModelVersion(String linknodeid) {
1493         if (linknodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*")) {
1494             LOG.info("OpenROADM version > 1.2.1 {}", linknodeid);
1495             return String.join("-", linknodeid.split("-")[0], linknodeid.split("-")[1]);
1496         } else {
1497             LOG.info("OpenROADM version <= 1.2.1 {}", linknodeid);
1498             return linknodeid.split("-")[0];
1499         }
1500     }
1501
1502     public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node>
1503             getTapiNodes() {
1504         return tapiNodes;
1505     }
1506
1507     public Map<LinkKey, Link> getTapiLinks() {
1508         return tapiLinks;
1509     }
1510
1511     public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
1512         return tapiSips;
1513     }
1514 }