2 * Copyright © 2021 Nokia, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.tapi.topology;
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.CoreMatchers.either;
12 import static org.hamcrest.CoreMatchers.hasItem;
13 import static org.hamcrest.CoreMatchers.hasItems;
14 import static org.hamcrest.MatcherAssert.assertThat;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import static org.junit.jupiter.api.Assertions.assertNull;
18 import static org.junit.jupiter.api.Assertions.assertTrue;
19 import static org.junit.jupiter.api.Assertions.fail;
21 import java.nio.charset.Charset;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.UUID;
28 import java.util.concurrent.ExecutionException;
29 import java.util.stream.Collectors;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.Test;
32 import org.opendaylight.mdsal.binding.api.DataBroker;
33 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
34 import org.opendaylight.transportpce.common.InstanceIdentifiers;
35 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
36 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
37 import org.opendaylight.transportpce.tapi.TapiStringConstants;
38 import org.opendaylight.transportpce.tapi.utils.TapiLink;
39 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
40 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
41 import org.opendaylight.transportpce.test.AbstractTest;
42 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1Builder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
50 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
94 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
95 import org.slf4j.Logger;
96 import org.slf4j.LoggerFactory;
98 public class ConvertORTopoToFullTapiTopoTest extends AbstractTest {
99 private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToFullTapiTopoTest.class);
101 private static Node otnMuxA;
102 private static Node otnSwitch;
103 private static Node tpdr100G;
104 private static Node roadmA;
105 private static Node roadmC;
106 private static Network openroadmNet;
107 private static Map<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
108 .networks.network.Link> ortopoLinks;
109 private static Uuid topologyUuid;
110 private static NetworkTransactionService networkTransactionService;
111 private static TapiLink tapiLink;
112 private static DataBroker dataBroker = getDataBroker();
115 static void setUp() throws InterruptedException, ExecutionException {
116 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
117 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
118 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
119 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
120 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
121 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
122 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
123 TapiTopologyDataUtils.PORTMAPPING_FILE);
125 otnMuxA = dataBroker.newReadOnlyTransaction()
127 LogicalDatastoreType.CONFIGURATION,
128 InstanceIdentifier.create(Networks.class)
129 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
130 .networks.Network.class,
131 new NetworkKey(new NetworkId("otn-topology")))
132 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1"))))
133 .get().orElseThrow();
135 /*KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
136 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
137 .class, new NetworkKey(new NetworkId("otn-topology")))
138 .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
139 FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
140 .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
141 muxCFuture.get().orElseThrow();*/
143 otnSwitch = dataBroker.newReadOnlyTransaction()
145 LogicalDatastoreType.CONFIGURATION,
146 InstanceIdentifier.create(Networks.class)
147 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
148 .networks.Network.class,
149 new NetworkKey(new NetworkId("otn-topology")))
150 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2"))))
151 .get().orElseThrow();
152 roadmA = dataBroker.newReadOnlyTransaction()
154 LogicalDatastoreType.CONFIGURATION,
155 InstanceIdentifier.create(Networks.class)
156 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
157 .networks.Network.class,
158 new NetworkKey(new NetworkId("openroadm-network")))
159 .child(Node.class, new NodeKey(new NodeId("ROADM-A1"))))
160 .get().orElseThrow();
161 roadmC = dataBroker.newReadOnlyTransaction()
163 LogicalDatastoreType.CONFIGURATION,
164 InstanceIdentifier.create(Networks.class)
165 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
166 .networks.Network.class,
167 new NetworkKey(new NetworkId("openroadm-network")))
168 .child(Node.class, new NodeKey(new NodeId("ROADM-C1"))))
169 .get().orElseThrow();
171 tpdr100G = dataBroker.newReadOnlyTransaction()
173 LogicalDatastoreType.CONFIGURATION,
174 InstanceIdentifier.create(Networks.class)
175 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
176 .networks.Network.class,
177 new NetworkKey(new NetworkId("otn-topology")))
178 .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1"))))
179 .get().orElseThrow();
181 /*InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
182 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
183 .class, new NetworkKey(new NetworkId("otn-topology")))
184 .augmentation(Network1.class);
185 FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
186 .read(LogicalDatastoreType.CONFIGURATION, linksIID);
187 linksFuture.get().orElseThrow().getLink();*/
189 ortopoLinks = dataBroker.newReadOnlyTransaction()
191 LogicalDatastoreType.CONFIGURATION,
192 InstanceIdentifier.create(Networks.class)
193 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
194 .networks.Network.class,
195 new NetworkKey(new NetworkId("openroadm-topology")))
196 .augmentation(Network1.class))
197 .get().orElseThrow().getLink();
198 openroadmNet = dataBroker.newReadOnlyTransaction()
200 LogicalDatastoreType.CONFIGURATION,
201 InstanceIdentifier.create(Networks.class)
202 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
203 .networks.Network.class,
204 new NetworkKey(new NetworkId("openroadm-topology"))))
205 .get().orElseThrow();
207 topologyUuid = new Uuid(UUID.nameUUIDFromBytes(
208 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
210 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
211 tapiLink = new TapiLinkImpl(networkTransactionService);
212 LOG.info("TEST SETUP READY");
216 void convertNodeWhenNoStates() {
217 rawConvertNodeWhenBadStates(
218 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", null, null);
222 void convertNodeWhenBadStates1() {
223 rawConvertNodeWhenBadStates(
224 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", AdminStates.OutOfService, State.OutOfService);
228 void convertNodeWhenBadStates2() {
229 rawConvertNodeWhenBadStates(
230 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", AdminStates.Maintenance, State.Degraded);
233 private void rawConvertNodeWhenBadStates(
234 String nodeId, String networkId, String clientId, AdminStates admState, State rawState) {
235 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
236 tapiFactory.convertNode(
237 changeTerminationPointState(tpdr100G, networkId, clientId , admState, rawState),
238 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
239 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
240 .equals(OpenroadmTpType.XPONDERNETWORK))
241 .map(tp -> tp.getTpId().getValue())
242 .collect(Collectors.toList()));
243 var dsrNodeNnOnep = tapiFactory
245 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(new Uuid(
246 UUID.nameUUIDFromBytes((nodeId + "+XPONDER").getBytes(Charset.forName("UTF-8"))).toString())))
247 .nonnullOwnedNodeEdgePoint();
248 OwnedNodeEdgePoint enepN = dsrNodeNnOnep.get(new OwnedNodeEdgePointKey(new Uuid(
249 UUID.nameUUIDFromBytes(String.join("+", nodeId, "eODU", clientId).getBytes(Charset.forName("UTF-8")))
251 OwnedNodeEdgePoint inepN = dsrNodeNnOnep.get(new OwnedNodeEdgePointKey(new Uuid(
252 UUID.nameUUIDFromBytes(String.join("+", nodeId, "iODU", networkId).getBytes(Charset.forName("UTF-8")))
254 if (admState == null) {
255 assertNull(enepN.getAdministrativeState(), "Administrative State should not be present");
256 assertNull(inepN.getAdministrativeState(), "Administrative State should not be present");
258 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
259 "Administrative State should be Locked");
260 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
261 "Administrative State should be Locked");
263 if (rawState == null) {
264 assertNull(enepN.getOperationalState(), "Operational State should not be present");
265 assertNull(inepN.getOperationalState(), "Operational State should not be present");
267 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(),
268 "Operational State should be Disabled");
269 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(),
270 "Operational State should be Disabled");
275 void convertNodeForTransponder100G() {
276 rawConvertNode(tpdr100G, "tpdr", "XPDR-A1-XPDR1");
280 void convertNodeForOtnMuxponder() {
281 rawConvertNode(otnMuxA, "mux", "SPDR-SA1-XPDR1");
285 void convertNodeForOtnSwitch() {
286 rawConvertNode(otnSwitch, "switch", "SPDR-SA1-XPDR2");
291 void convertNodeForRoadmWhenNoOtnMuxAttached() {
292 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
293 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
294 assertEquals(1, tapiFullFactory.getTapiNodes().size(), "Node list size should be 1");
295 assertEquals(0, tapiFullFactory.getTapiLinks().size(), "Link list size should be empty");
296 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
297 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
298 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
299 .getBytes(Charset.forName("UTF-8"))).toString());
300 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
304 void convertNodeForRoadmWhenRoadmNeighborAttached() {
305 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
306 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
307 tapiFullFactory.convertRoadmNode(roadmC, openroadmNet, "Full");
309 List<Link> rdmTordmLinkList = ortopoLinks.values().stream()
310 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ROADMTOROADM))
311 .collect(Collectors.toList());
312 tapiFullFactory.convertRdmToRdmLinks(rdmTordmLinkList);
314 assertEquals(2, tapiFullFactory.getTapiNodes().size(), "Node list size should be 2");
315 assertEquals(1, tapiFullFactory.getTapiLinks().size(), "Link list size should be 1");
317 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
318 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
320 for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : tapiNodes) {
321 if (node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
322 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
323 LOG.info("LOOP ROADM node found at rank {}, with Name {} and Uuid {}",
324 myInt, node.getName(), node.getUuid());
328 Uuid roadmaNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
329 .getBytes(Charset.forName("UTF-8"))).toString());
330 LOG.info("ROADM node found at rank {} from getrank", getNodeRank("ROADM-A1", tapiNodes));
331 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmaNodeUuid, "roadm", "ROADM-A1");
333 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
334 = tapiFullFactory.getTapiLinks().values().stream()
335 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
336 .collect(Collectors.toList());
337 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
339 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-C1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
341 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
342 .getBytes(Charset.forName("UTF-8"))).toString());
343 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
344 .getBytes(Charset.forName("UTF-8"))).toString());
346 new Uuid(UUID.nameUUIDFromBytes(
347 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
348 .getBytes(Charset.forName("UTF-8"))).toString());
349 checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
350 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX");
354 void convertNodeForRoadmWhenOtnMuxAttached() {
355 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
356 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
357 List<String> networkPortListA = new ArrayList<>();
358 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
359 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
360 networkPortListA.add(tp.getTpId().getValue());
363 tapiFactory.convertNode(otnMuxA, networkPortListA);
364 tapiFullFactory.setTapiNodes(tapiFactory.getTapiNodes());
365 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
366 List<Link> xponderOutLinkList = ortopoLinks.values().stream()
367 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
368 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
369 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
370 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
371 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
372 .collect(Collectors.toList());
373 List<Link> xponderInLinkList = ortopoLinks.values().stream()
374 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
375 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
376 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
377 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
378 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
379 .collect(Collectors.toList());
380 xponderInLinkList.addAll(xponderOutLinkList);
381 tapiFullFactory.convertXpdrToRdmLinks(xponderInLinkList);
382 assertEquals(2, tapiFullFactory.getTapiNodes().size(),
383 "Node list size should be 2 (XPDR, DSR-ODU merged; ROADM)");
384 assertEquals(1, tapiFullFactory.getTapiLinks().size(),
385 "Link list size should be 1 : no more transitional link");
386 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
387 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
388 tapiFactory.getTapiNodes();
389 nodeMap.putAll(tapiFullFactory.getTapiNodes());
390 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
391 = nodeMap.values().stream()
392 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
393 .collect(Collectors.toList());
394 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
395 .getBytes(Charset.forName("UTF-8"))).toString());
396 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
398 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
400 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
402 LOG.info("ROADM-A1+PHOTONIC_MEDIA UUID is {}", node2Uuid);
403 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
404 .getBytes(Charset.forName("UTF-8"))).toString());
405 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRX")
406 .getBytes(Charset.forName("UTF-8"))).toString());
408 new Uuid(UUID.nameUUIDFromBytes(
409 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
410 .getBytes(Charset.forName("UTF-8"))).toString());
411 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
412 = tapiFullFactory.getTapiLinks().values().stream()
413 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
414 .collect(Collectors.toList());
415 checkXpdrRdmLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
416 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1");
419 private void rawConvertNode(Node node0, String dsrNodeType, String nodeId) {
420 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
421 tapiFactory.convertNode(
423 node0.augmentation(Node1.class).getTerminationPoint().values().stream()
424 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
425 .equals(OpenroadmTpType.XPONDERNETWORK))
426 .map(tp -> tp.getTpId().getValue())
427 .collect(Collectors.toList()));
428 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
429 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
430 //checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
431 // Uuid node9Uuid, String dsrNodeType, String nodeId) {
433 new Uuid(UUID.nameUUIDFromBytes((nodeId + "+XPONDER").getBytes(Charset.forName("UTF-8"))).toString());
435 tapiFactory.getTapiNodes().values().stream()
436 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
437 .findFirst().orElseThrow();
438 assertEquals(node9Uuid, node.getUuid(), "incorrect node uuid");
439 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
440 "incorrect node name");
441 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
442 "administrative state should be UNLOCKED");
443 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
444 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
445 assertThat("one value-name should be 'dsr/odu node name'",
446 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
447 assertEquals(4, node.getLayerProtocolName().size(), "dsr node should manage 4 protocol layers : dsr and odu"
448 + " DIGITALOTN, PHOTONICMEDIA");
449 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
450 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
451 List<OwnedNodeEdgePoint> inepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
452 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
453 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
454 .collect(Collectors.toList());
455 List<OwnedNodeEdgePoint> enepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
456 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint_N")))
457 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
458 .collect(Collectors.toList());
459 List<OwnedNodeEdgePoint> nepsC;
460 switch (dsrNodeType) {
462 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
463 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
464 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
465 .collect(Collectors.toList());
466 assertEquals(4, enepsN.size(), "Switch-DSR node should have 4 eNEPs network");
467 assertEquals(4, inepsN.size(), "Switch-DSR node should have 4 iNEPs network");
468 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
469 OwnedNodeEdgePoint nep1 = nepsC.get(2);
470 Uuid client4NepUuid = new Uuid(
471 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
473 checkNepClient100GSwitch(nep1, client4NepUuid, nodeId + "+DSR+XPDR2-CLIENT4", "NodeEdgePoint_C");
474 OwnedNodeEdgePoint enep2 = enepsN.get(2);
475 OwnedNodeEdgePoint inep2 = inepsN.get(3);
476 Uuid enetworkNepUuid = new Uuid(
477 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
479 Uuid inetworkNepUuid = new Uuid(
480 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
482 checkNepeODU4(enep2, enetworkNepUuid, nodeId + "+eODU+XPDR2-CLIENT4", "eNodeEdgePoint_N", false);
483 checkNepNetworkODU4(inep2, inetworkNepUuid, nodeId + "+iODU+XPDR2-NETWORK1", "iNodeEdgePoint_N", true);
484 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
485 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
486 .collect(Collectors.toList());
487 // keep trace of the previous test performed before the structure of the NRG was modified
488 // checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, enetworkNepUuid, node9Uuid);
489 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, inetworkNepUuid, node9Uuid);
492 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
493 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
494 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
495 .collect(Collectors.toList());
496 assertEquals(4, enepsN.size(), "Mux-DSR node should have 4 eNEP network");
497 assertEquals(1, inepsN.size(), "Mux-DSR node should have 1 iNEP network");
498 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
499 OwnedNodeEdgePoint nep3 = nepsC.get(2);
500 Uuid client3NepUuid = new Uuid(
501 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
503 checkNepClient10G(nep3, client3NepUuid, nodeId + "+DSR+XPDR1-CLIENT3", "NodeEdgePoint_C");
504 OwnedNodeEdgePoint enep4 = enepsN.get(3);
505 OwnedNodeEdgePoint inep4 = inepsN.get(0);
506 Uuid eclientNepUuid2 = new Uuid(
507 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
509 Uuid inetworkNepUuid2 = new Uuid(
510 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
512 checkNepeODU4(enep4, eclientNepUuid2, nodeId + "+eODU+XPDR1-CLIENT3", "eNodeEdgePoint_N", false);
513 checkNepNetworkODU4(inep4, inetworkNepUuid2, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
515 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
516 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
517 .collect(Collectors.toList());
518 // keep trace of the previous test performed before the structure of the NRG was modified
519 // checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, eclientNepUuid2, node9Uuid);
520 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, inetworkNepUuid2, node9Uuid);
523 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
524 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
525 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
526 .collect(Collectors.toList());
527 assertEquals(2, enepsN.size(), "Tpdr-DSR node should have 2 eNEPs network");
528 assertEquals(2, inepsN.size(), "Tpdr-DSR node should have 2 iNEPs network");
529 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
530 OwnedNodeEdgePoint nep5 = nepsC.get(0);
531 Uuid client1NepUuid = new Uuid(
532 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
534 checkNepClient100GTpdr(nep5, client1NepUuid, nodeId + "+DSR+XPDR1-CLIENT1", "100G-tpdr");
535 OwnedNodeEdgePoint enep6 = enepsN.get(0);
536 OwnedNodeEdgePoint inep6 = inepsN.get(1);
537 Uuid enetworkNepUuid3 = new Uuid(
538 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
540 Uuid inetworkNepUuid3 = new Uuid(
541 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
543 checkNepeODU4(enep6, enetworkNepUuid3, nodeId + "+eODU+XPDR1-CLIENT1", "eNodeEdgePoint_N", false);
544 checkNepNetworkODU4(inep6, inetworkNepUuid3, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
546 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
547 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
548 .collect(Collectors.toList());
549 // keep trace of the previous test performed before the structure of the NRG was modified
550 // checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, enetworkNepUuid3, node9Uuid);
551 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, inetworkNepUuid3, node9Uuid);
559 private void checkOtsiNode(
560 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
561 Uuid nodeUuid, String otsiNodeType, String nodeId) {
562 if (!node.getUuid().equals(nodeUuid)) {
563 LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName(), nodeId);
564 LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid);
566 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
567 List<OwnedNodeEdgePoint> nepsI = null;
568 List<OwnedNodeEdgePoint> nepsE = null;
569 List<OwnedNodeEdgePoint> nepsP = null;
570 List<OwnedNodeEdgePoint> nepsOMS = null;
571 List<OwnedNodeEdgePoint> nepsOTS = null;
572 List<OwnedNodeEdgePoint> nepsPhot = null;
573 if (!otsiNodeType.equals("roadm")) {
574 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
575 "incorrect node name");
576 assertThat("one value-name should be 'dsr/odu node name'",
577 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
578 nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
579 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
580 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
581 .collect(Collectors.toList());
582 nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
583 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
584 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
585 .collect(Collectors.toList());
586 nepsP = node.nonnullOwnedNodeEdgePoint().values().stream()
587 .filter(n -> n.getName().containsKey(new NameKey("PhotMedNodeEdgePoint")))
588 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
589 .collect(Collectors.toList());
591 assertEquals(nodeId + "+PHOTONIC_MEDIA", node.getName().get(new NameKey("roadm node name")).getValue(),
592 "incorrect node name");
593 assertThat("one value-name should be 'dsr/odu node name'",
594 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
595 //TODO this variable are only accessed in switch/case block -> report this in the right place
596 nepsOMS = node.nonnullOwnedNodeEdgePoint().values().stream()
597 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
598 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
599 .collect(Collectors.toList());
600 nepsOTS = node.nonnullOwnedNodeEdgePoint().values().stream()
601 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
602 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
603 .collect(Collectors.toList());
604 nepsPhot = node.nonnullOwnedNodeEdgePoint().values().stream()
605 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
606 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
607 .collect(Collectors.toList());
608 nepsPhot.addAll(node.nonnullOwnedNodeEdgePoint().values().stream()
609 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
610 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
611 .collect(Collectors.toList()));
613 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
614 "administrative state should be UNLOCKED");
615 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
616 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
617 assertEquals(1, node.getLayerProtocolName().size(),
618 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
619 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
620 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
622 switch (otsiNodeType) {
624 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
625 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
626 assertEquals(4, nepsP.size(), "Switch-OTSi node should have 4 photNEPs");
627 OwnedNodeEdgePoint nep1 = nepsI.get(1);
628 Uuid inepUuid = new Uuid(
629 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
631 checkNepOtsiNode(nep1, inepUuid, nodeId + "+iOTSi+XPDR2-NETWORK2", "iNodeEdgePoint", true);
632 OwnedNodeEdgePoint nep2 = nepsE.get(0);
633 Uuid enepUuid = new Uuid(
634 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
635 .getBytes(Charset.forName("UTF-8")))
637 checkNepOtsiNode(nep2, enepUuid, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2",
638 "eNodeEdgePoint", false);
639 OwnedNodeEdgePoint photNep = nepsP.get(1);
640 Uuid pnepUuid = new Uuid(
641 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2")
642 .getBytes(Charset.forName("UTF-8"))).toString());
643 checkNepOtsiNode(photNep, pnepUuid, nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2", "PhotMedNodeEdgePoint",
645 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
646 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
647 .collect(Collectors.toList());
648 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
651 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
652 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
653 assertEquals(1, nepsP.size(), "Mux-OTSi node should have 1 photNEPs");
654 OwnedNodeEdgePoint nep3 = nepsE.get(0);
655 Uuid enepUuid2 = new Uuid(
656 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
657 .getBytes(Charset.forName("UTF-8")))
659 checkNepOtsiNode(nep3, enepUuid2, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
660 "eNodeEdgePoint", false);
661 OwnedNodeEdgePoint nep4 = nepsI.get(0);
662 Uuid inepUuid2 = new Uuid(
663 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
665 checkNepOtsiNode(nep4, inepUuid2, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
666 OwnedNodeEdgePoint photNep1 = nepsP.get(0);
667 Uuid pnep1Uuid = new Uuid(
668 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
669 .getBytes(Charset.forName("UTF-8"))).toString());
670 checkNepOtsiNode(photNep1, pnep1Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
672 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
673 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
674 .collect(Collectors.toList());
675 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
678 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
679 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
680 assertEquals(2, nepsP.size(), "Tpdr-OTSi node should have 2 photNEPs");
681 OwnedNodeEdgePoint nep5 = nepsE.get(0);
682 Uuid enepUuid3 = new Uuid(
683 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
684 .getBytes(Charset.forName("UTF-8")))
686 checkNepOtsiNode(nep5, enepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
687 "eNodeEdgePoint", false);
688 OwnedNodeEdgePoint nep6 = nepsI.get(0);
689 Uuid inepUuid3 = new Uuid(
690 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
692 checkNepOtsiNode(nep6, inepUuid3, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
693 OwnedNodeEdgePoint photNep2 = nepsP.get(0);
694 Uuid pnep2Uuid = new Uuid(
695 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
696 .getBytes(Charset.forName("UTF-8"))).toString());
697 checkNepOtsiNode(photNep2, pnep2Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
699 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
700 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
701 .collect(Collectors.toList());
702 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
705 // Keep trace of MC NEP test to be restored after the new policy for creating NEP is applied
706 // assertEquals(0, nepsMc.size(), "MC NEP no more configured, Roadm node should have 0 MC NEPs");
707 // assertEquals(0, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs");
708 assertEquals(12, nepsPhot.size(), "Roadm node should have 12 PHOT_MEDIA NEPs (2x4 OTS +2x(OTS+OMS)");
710 OwnedNodeEdgePoint nep7 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
711 Uuid mcnepUuid3 = new Uuid(
712 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX").getBytes(Charset
713 .forName("UTF-8"))).toString());
714 checkNepOtsiRdmNode(nep7, mcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
715 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
716 OwnedNodeEdgePoint nep8 = nepsOTS.get(getRank("DEG1-TTP", nepsOTS));
717 Uuid otmcnepUuid3 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
718 .getBytes(Charset.forName("UTF-8"))).toString());
719 checkNepOtsiRdmNode(nep8, otmcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX",
720 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
721 OwnedNodeEdgePoint omsNep3 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
722 Uuid omsNep3Uuid = new Uuid(
723 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX")
724 .getBytes(Charset.forName("UTF-8"))).toString());
725 checkNepOtsiRdmNode(omsNep3, omsNep3Uuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
726 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
728 OwnedNodeEdgePoint nep10 = nepsOTS.get(getRank("SRG1-PP1", nepsOTS));
729 Uuid otsnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX")
730 .getBytes(Charset.forName("UTF-8"))).toString());
731 checkNepOtsiRdmNode(nep10, otsnepUuid4, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX",
732 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
733 OwnedNodeEdgePoint otsNep4 = nepsOTS.get(getRank("SRG1-PP3", nepsOTS));
734 Uuid otsNep4Uuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX")
735 .getBytes(Charset.forName("UTF-8"))).toString());
736 checkNepOtsiRdmNode(otsNep4, otsNep4Uuid, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX",
737 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
738 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
739 .sorted((nrg1, nrg2) -> nrg1.getName().entrySet().iterator().next().getValue().toString()
740 .compareTo(nrg2.getName().entrySet().iterator().next().getValue().toString()))
741 .collect(Collectors.toList());
742 LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4);
743 List<Integer> nepNumber = new ArrayList<>(List.of(2, 4, 4));
744 checkNodeRuleGroupForRdm(nrgList4, nepNumber);
752 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
754 List.of(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE), LayerProtocolName.DSR,
755 false, nep, nepUuid, portName, nepName, false);
758 private void checkNepeODU4(
759 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
761 List.of(ODUTYPEODU0.VALUE, ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, ODUTYPEODU4.VALUE), LayerProtocolName.ODU,
762 true, nep, nepUuid, portName, nepName, withSip);
765 private void checkNepNetworkODU4(
766 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
768 List.of(ODUTYPEODU4.VALUE), LayerProtocolName.ODU, false,
769 nep, nepUuid, portName, nepName, withSip);
772 private void checkNodeRuleGroupForTpdrDSR(
773 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
774 rawCheckNodeRuleGroupDSR("Transponder", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
777 private void checkNodeRuleGroupForMuxDSR(
778 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
779 rawCheckNodeRuleGroupDSR("Muxponder", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
782 private void checkNodeRuleGroupForSwitchDSR(
783 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
784 rawCheckNodeRuleGroupDSR("Switch", nrgList, clientNepUuid, networkNepUuid, nodeUuid);
787 private void rawCheckNodeRuleGroupDSR(String nodeType,
788 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
792 List<Integer> nepUuidCheckList;
793 List<Integer> nodeIdCheckList;
799 nepUuidCheckList = List.of(5,6);
800 nodeIdCheckList = List.of(3,4);
806 nepUuidCheckList = List.of(0,1);
807 nodeIdCheckList = List.of(0,1);
814 nepUuidCheckList = List.of(1);
815 nodeIdCheckList = List.of(0,1);
818 assertEquals(nrgListSize, nrgList.size(),
819 nodeType + " DSR should contain " + nrgListSize + " node rule group (DSR-I_ODU/I-ODU-E_ODU)");
820 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
821 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
822 List<NodeEdgePoint> nodeEdgePointList;
823 if (nodeType.equals("Switch")) {
824 assertEquals(8, nrgList.get(indNrg).getNodeEdgePoint().size(), "Switch-DSR nrg should contain 8 NEP");
825 nodeEdgePointList = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
826 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
827 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
828 .collect(Collectors.toList());
830 for (NodeEdgePoint nep : nodeEdgePointList) {
831 LOG.info("nep number {} UUID is {} ", xxxxx, nep.getNodeEdgePointUuid());
834 LOG.info("nep SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK1 UUID is {} ",
835 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))));
836 LOG.info("nep SPDR-SA1-XPDR2+DSR+XPDR2-CLIENT4 UUID is {} ",
837 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))));
838 assertEquals(networkNepUuid, nodeEdgePointList.get(6).getNodeEdgePointUuid(),
839 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
840 assertEquals(clientNepUuid, nodeEdgePointList.get(5).getNodeEdgePointUuid(),
841 "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
842 //TODO nep number 6 rather ?
843 //TODO regroup with else condition ?
845 nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
846 for (int i : nepUuidCheckList) {
847 assertThat("node-rule-group nb " + nrgNb + " should be between nep-client" + nepClNb
848 + " and nep-network1",
849 nodeEdgePointList.get(i).getNodeEdgePointUuid().getValue(),
850 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
853 for (int i : nodeIdCheckList) {
854 assertEquals(nodeEdgePointList.get(i).getNodeUuid(), nodeUuid,
855 "any item of the node-rule-group should have the same nodeUuid");
857 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
858 assertEquals(1, rule.size(), "node-rule-group should contain a single rule");
859 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
860 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
861 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
862 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
863 "the rule type should be 'FORWARDING'");
864 //TODO regroup with rawCheckNodeRuleGroupOTsi ?
867 private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, List<Integer> nbNeps) {
868 assertEquals(3, nrgList.size(), "RDM infra node - OTS should contain 3 node rule groups");
870 for (NodeRuleGroup nrg : nrgList) {
871 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrg.getNodeEdgePoint().values());
872 assertEquals(nbNeps.get(index), nodeEdgePointList.size(),
873 "RDM infra node -rule-group should contain " + nbNeps.get(index) + " NEP");
874 List<Rule> ruleList = new ArrayList<>(nrg.nonnullRule().values());
875 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
876 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
877 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
878 "the rule type should be 'FORWARDING'");
879 if (nrg.getName().entrySet().iterator().next().getValue().toString().contains("DEG")) {
880 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
881 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
883 assertEquals(FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
884 "the forwarding rule should be 'CANNOTFORWARDACROSSGROUP'");
890 private void checkNodeRuleGroupForTpdrOTSi(
891 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
892 rawCheckNodeRuleGroupOTsi("Tpdr", nrgList, enepUuid, inepUuid, nodeUuid);
895 private void checkNodeRuleGroupForMuxOTSi(
896 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
897 rawCheckNodeRuleGroupOTsi("Mux", nrgList, enepUuid, inepUuid, nodeUuid);
900 private void checkNodeRuleGroupForSwitchOTSi(
901 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
902 rawCheckNodeRuleGroupOTsi("Switch", nrgList, enepUuid, inepUuid, nodeUuid);
905 private void rawCheckNodeRuleGroupOTsi(String nodeType,
906 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
912 network = "XPDR2-NETWORK2";
918 network = "XPDR1-NETWORK1";
921 assertEquals(nrgListSize, nrgList.size(),
922 nodeType + "-OTSi should contain " + nrgListSize + " node rule group");
923 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
924 for (NodeRuleGroup nodeRuleGroup : nrgList) {
925 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
926 "each node-rule-group should contain 2 NEP for " + nodeType + "-OTSi");
928 assertThat(nodeType + "-OTSi node-rule-group should be between eNEP and iNEP of " + network,
929 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
930 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
931 assertThat(nodeType + "-OTSi node-rule-group should be between eNEP and iNEP of " + network,
932 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
933 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
934 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
935 "any item of the node-rule-group should have the same nodeUuid");
936 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
937 "any item of the node-rule-group should have the same nodeUuid");
938 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
939 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
940 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
941 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
942 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
943 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
944 "the rule type should be 'FORWARDING'");
947 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
949 List.of(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
950 nep, nepUuid, portName, nepName, false);
953 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
955 List.of(DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
956 nep, nepUuid, portName, nepName, false);
959 private void checkNepOtsiNode(
960 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
962 List.of(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE), LayerProtocolName.PHOTONICMEDIA,
963 false, nep, nepUuid, portName, nepName, withSip);
966 private void checkNepOtsiRdmNode(
967 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
968 if (!nep.getUuid().equals(nepUuid)) {
969 LOG.info("ERRORUUIDNEP on Nep {}, expected {}", nep.getName(), portName);
971 rawCheckNep(nepName.contains("OMS")
972 ? List.of(PHOTONICLAYERQUALIFIEROMS.VALUE)
973 : nepName.contains("OTS") ? List.of(PHOTONICLAYERQUALIFIEROTS.VALUE) : null,
974 LayerProtocolName.PHOTONICMEDIA, false, nep, nepUuid, portName, nepName, withSip);
977 private void rawCheckNep(List<LAYERPROTOCOLQUALIFIER> lpqList, LayerProtocolName lpn, boolean anyInList,
978 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
979 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
980 Name name0 = nep.nonnullName().values().stream().findFirst().orElseThrow();
981 assertEquals(portName, name0.getValue(), "Value of nep port should be '" + portName + "'");
982 assertEquals(nepName, name0.getValueName(), "value-name of nep should be '" + nepName + "'");
983 if (lpqList != null) {
984 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
985 .map(entry -> entry.getLayerProtocolQualifier())
986 .collect(Collectors.toList());
989 lpql.size() < lpqList.size(),
990 //TODO lpqList.size() = 4 here -> check if this is the correct formula from an optical standpoint
991 "eODU nep should support less than " + lpqList.size() + " kind of cep, it depends on client port");
993 lpqList.stream().anyMatch(splc -> lpql.contains(splc)),
994 "eODU nep should support 1 kind of cep");
996 assertEquals(lpqList.size(), lpql.size(), "nep should support " + lpqList.size() + " kind of cep(s)");
997 for (LAYERPROTOCOLQUALIFIER lpq: lpqList) {
998 assertThat("nep should support " + lpq + " cep", lpql, hasItem(lpq));
1000 assertEquals(lpn, nep.getLayerProtocolName(), "nep should be of " + lpn.toString() + " protocol type");
1003 // CommonPartOfNep(OwnedNodeEdgePoint nep, boolean withSip)
1004 assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(), "link port direction should be DIRECTIONAL");
1005 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1006 "administrative state should be UNLOCKED");
1007 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1008 // assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1009 // "termination state should be TERMINATED BIDIRECTIONAL");
1010 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(), "life-cycle state should be INSTALLED");
1012 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "Given nep should support 1 SIP");
1014 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1015 // assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1016 // "termination direction should be BIDIRECTIONAL");
1017 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1018 "operational state of client nep should be ENABLED");
1019 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(),
1020 "link-port-role of client nep should be SYMMETRIC");
1023 private void checkOmsLink(
1024 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1025 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1026 assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1027 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1030 private void checkXpdrRdmLink(
1031 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1032 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1033 assertEquals(linkName, link.getName().get(new NameKey("XPDR-RDM link name")).getValue(),
1034 "bad name for the link");
1035 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1038 private void linkNepsCheck(
1039 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1040 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid) {
1041 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1043 LayerProtocolName.PHOTONICMEDIA.getName(),
1044 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1045 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1046 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1047 "otn tapi link should be BIDIRECTIONAL");
1048 var nodeEdgePointList = link.nonnullNodeEdgePoint().values().stream().collect(Collectors.toList());
1049 assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1050 var nep0 = nodeEdgePointList.get(0);
1051 var nep1 = nodeEdgePointList.get(1);
1052 assertEquals(topologyUuid, nep0.getTopologyUuid(),
1053 "topology uuid should be the same for the two termination point of the link");
1054 assertEquals(topologyUuid, nep1.getTopologyUuid(),
1055 "topology uuid should be the same for the two termination point of the link");
1056 String node1UuidVal = node1Uuid.getValue();
1057 String node2UuidVal = node2Uuid.getValue();
1058 assertThat("oms links should terminate on two distinct nodes",
1059 nep0.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1060 assertThat("oms links should terminate on two distinct nodes",
1061 nep1.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1062 String tp1UuidVal = tp1Uuid.getValue();
1063 String tp2UuidVal = tp2Uuid.getValue();
1064 assertThat("oms links should terminate on two distinct tps",
1065 nep0.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1066 assertThat("oms links should terminate on two distinct tps",
1067 nep1.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1070 private Node changeTerminationPointState(
1071 Node initialNode, String tpid, String tpid1, AdminStates admin, State oper) {
1072 var tpdr1Bldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1073 .Node1Builder(initialNode.augmentation(Node1.class));
1074 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1075 TerminationPointBuilder tpBldr = new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid))));
1076 tpBldr.addAugmentation(
1077 new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1078 .setAdministrativeState(admin)
1079 .setOperationalState(oper)
1081 tps.replace(tpBldr.key(), tpBldr.build());
1082 TerminationPointBuilder tpBldr1 =
1083 new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid1))));
1084 tpBldr1.addAugmentation(
1085 new TerminationPoint1Builder(tpBldr1.augmentation(TerminationPoint1.class))
1086 .setAdministrativeState(admin)
1087 .setOperationalState(oper)
1089 tps.replace(tpBldr1.key(), tpBldr1.build());
1090 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.setTerminationPoint(tps).build()).build();
1093 private int getRank(String searchedChar, List<OwnedNodeEdgePoint> onepList) {
1095 searchedChar, onepList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1098 private int getNodeRank(String searchedChar,
1099 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1101 searchedChar, nodeList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1104 private int rawRank(String searchedChar, List<Collection<Name>> nameCL) {
1105 int foundAtRank = 0;
1107 for (var nameC: nameCL) {
1108 for (Name name: nameC) {
1109 if (name.getValue().contains(searchedChar)) {
1111 //TODO should we really pursue once it is found ?
1116 LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
1120 private Integer nrgContainsClientAndNetwork(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid) {
1121 // 1 NRG should at least contain the NEP of interest in the NEP List
1122 Integer indexNrg = 0;
1123 for (NodeRuleGroup nrg : nrgList) {
1124 Boolean foundClient = false;
1125 Boolean foundNetwork = false;
1126 for (NodeEdgePoint nep : nrg.nonnullNodeEdgePoint().values()) {
1127 foundClient = foundClient || nep.getNodeEdgePointUuid().equals(clientNepUuid);
1128 foundNetwork = foundNetwork || nep.getNodeEdgePointUuid().equals(networkNepUuid);
1130 if (foundClient && foundNetwork) {