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.eclipse.jdt.annotation.Nullable;
31 import org.junit.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.Test;
33 import org.opendaylight.mdsal.binding.api.DataBroker;
34 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
35 import org.opendaylight.transportpce.common.InstanceIdentifiers;
36 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
37 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
38 import org.opendaylight.transportpce.tapi.TapiStringConstants;
39 import org.opendaylight.transportpce.tapi.utils.TapiLink;
40 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
41 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
42 import org.opendaylight.transportpce.test.AbstractTest;
43 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1Builder;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
95 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
96 import org.slf4j.Logger;
97 import org.slf4j.LoggerFactory;
99 public class ConvertORTopoToFullTapiTopoTest extends AbstractTest {
100 private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToFullTapiTopoTest.class);
102 private static Node otnMuxA;
103 private static Node otnSwitch;
104 private static Node tpdr100G;
105 private static Node roadmA;
106 private static Node roadmC;
107 private static Network openroadmNet;
108 private static Map<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
109 .networks.network.Link> ortopoLinks;
110 private static Uuid topologyUuid;
111 private static NetworkTransactionService networkTransactionService;
112 private static TapiLink tapiLink;
113 private static DataBroker dataBroker = getDataBroker();
116 static void setUp() throws InterruptedException, ExecutionException {
117 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
118 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
119 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
120 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
121 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
122 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
123 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
124 TapiTopologyDataUtils.PORTMAPPING_FILE);
126 otnMuxA = dataBroker.newReadOnlyTransaction()
128 LogicalDatastoreType.CONFIGURATION,
129 InstanceIdentifier.create(Networks.class)
130 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
131 .networks.Network.class,
132 new NetworkKey(new NetworkId("otn-topology")))
133 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1"))))
134 .get().orElseThrow();
136 /*KeyedInstanceIdentifier<Node, NodeKey> muxCIID = InstanceIdentifier.create(Networks.class)
137 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
138 .class, new NetworkKey(new NetworkId("otn-topology")))
139 .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1")));
140 FluentFuture<Optional<Node>> muxCFuture = dataBroker.newReadOnlyTransaction()
141 .read(LogicalDatastoreType.CONFIGURATION, muxCIID);
142 muxCFuture.get().orElseThrow();*/
144 otnSwitch = dataBroker.newReadOnlyTransaction()
146 LogicalDatastoreType.CONFIGURATION,
147 InstanceIdentifier.create(Networks.class)
148 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
149 .networks.Network.class,
150 new NetworkKey(new NetworkId("otn-topology")))
151 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2"))))
152 .get().orElseThrow();
153 roadmA = dataBroker.newReadOnlyTransaction()
155 LogicalDatastoreType.CONFIGURATION,
156 InstanceIdentifier.create(Networks.class)
157 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
158 .networks.Network.class,
159 new NetworkKey(new NetworkId("openroadm-network")))
160 .child(Node.class, new NodeKey(new NodeId("ROADM-A1"))))
161 .get().orElseThrow();
162 roadmC = dataBroker.newReadOnlyTransaction()
164 LogicalDatastoreType.CONFIGURATION,
165 InstanceIdentifier.create(Networks.class)
166 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
167 .networks.Network.class,
168 new NetworkKey(new NetworkId("openroadm-network")))
169 .child(Node.class, new NodeKey(new NodeId("ROADM-C1"))))
170 .get().orElseThrow();
172 tpdr100G = dataBroker.newReadOnlyTransaction()
174 LogicalDatastoreType.CONFIGURATION,
175 InstanceIdentifier.create(Networks.class)
176 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
177 .networks.Network.class,
178 new NetworkKey(new NetworkId("otn-topology")))
179 .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1"))))
180 .get().orElseThrow();
182 /*InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
183 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
184 .class, new NetworkKey(new NetworkId("otn-topology")))
185 .augmentation(Network1.class);
186 FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
187 .read(LogicalDatastoreType.CONFIGURATION, linksIID);
188 linksFuture.get().orElseThrow().getLink();*/
190 ortopoLinks = dataBroker.newReadOnlyTransaction()
192 LogicalDatastoreType.CONFIGURATION,
193 InstanceIdentifier.create(Networks.class)
194 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
195 .networks.Network.class,
196 new NetworkKey(new NetworkId("openroadm-topology")))
197 .augmentation(Network1.class))
198 .get().orElseThrow().getLink();
199 openroadmNet = dataBroker.newReadOnlyTransaction()
201 LogicalDatastoreType.CONFIGURATION,
202 InstanceIdentifier.create(Networks.class)
203 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
204 .networks.Network.class,
205 new NetworkKey(new NetworkId("openroadm-topology"))))
206 .get().orElseThrow();
208 topologyUuid = new Uuid(UUID.nameUUIDFromBytes(
209 TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
211 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
212 tapiLink = new TapiLinkImpl(networkTransactionService);
213 LOG.info("TEST SETUP READY");
217 void convertNodeWhenNoStates() {
218 rawConvertNodeWhenBadStates(
219 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", null, null);
223 void convertNodeWhenBadStates1() {
224 rawConvertNodeWhenBadStates(
225 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", AdminStates.OutOfService, State.OutOfService);
229 void convertNodeWhenBadStates2() {
230 rawConvertNodeWhenBadStates(
231 "XPDR-A1-XPDR1", "XPDR1-NETWORK1", "XPDR1-CLIENT1", AdminStates.Maintenance, State.Degraded);
234 private void rawConvertNodeWhenBadStates(
235 String nodeId, String networkId, String clientId, AdminStates admState, State rawState) {
236 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
237 tapiFactory.convertNode(
238 changeTerminationPointState(tpdr100G, networkId, clientId , admState, rawState),
239 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
240 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
241 .equals(OpenroadmTpType.XPONDERNETWORK))
242 .map(tp -> tp.getTpId().getValue())
243 .collect(Collectors.toList()));
244 var dsrNodeNnOnep = tapiFactory
246 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(new Uuid(
247 UUID.nameUUIDFromBytes((nodeId + "+XPONDER").getBytes(Charset.forName("UTF-8"))).toString())))
248 .nonnullOwnedNodeEdgePoint();
249 OwnedNodeEdgePoint enepN = dsrNodeNnOnep.get(new OwnedNodeEdgePointKey(new Uuid(
250 UUID.nameUUIDFromBytes(String.join("+", nodeId, "eODU", clientId).getBytes(Charset.forName("UTF-8")))
252 OwnedNodeEdgePoint inepN = dsrNodeNnOnep.get(new OwnedNodeEdgePointKey(new Uuid(
253 UUID.nameUUIDFromBytes(String.join("+", nodeId, "iODU", networkId).getBytes(Charset.forName("UTF-8")))
255 if (admState == null) {
256 assertNull(enepN.getAdministrativeState(), "Administrative State should not be present");
257 assertNull(inepN.getAdministrativeState(), "Administrative State should not be present");
259 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
260 "Administrative State should be Locked");
261 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
262 "Administrative State should be Locked");
264 if (rawState == null) {
265 assertNull(enepN.getOperationalState(), "Operational State should not be present");
266 assertNull(inepN.getOperationalState(), "Operational State should not be present");
268 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(),
269 "Operational State should be Disabled");
270 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(),
271 "Operational State should be Disabled");
276 void convertNodeForTransponder100G() {
277 rawConvertNode(tpdr100G, "tpdr", "XPDR-A1-XPDR1");
281 void convertNodeForOtnMuxponder() {
282 rawConvertNode(otnMuxA, "mux", "SPDR-SA1-XPDR1");
286 void convertNodeForOtnSwitch() {
287 rawConvertNode(otnSwitch, "switch", "SPDR-SA1-XPDR2");
292 void convertNodeForRoadmWhenNoOtnMuxAttached() {
293 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
294 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
296 assertEquals(1, tapiFullFactory.getTapiNodes().size(), "Node list size should be 1");
297 assertEquals(0, tapiFullFactory.getTapiLinks().size(), "Link list size should be empty");
298 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
299 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
300 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
301 .getBytes(Charset.forName("UTF-8"))).toString());
302 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
306 void convertNodeForRoadmWhenRoadmNeighborAttached() {
307 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
308 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
309 tapiFullFactory.convertRoadmNode(roadmC, openroadmNet, "Full");
311 List<Link> rdmTordmLinkList = ortopoLinks.values().stream()
312 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ROADMTOROADM))
313 .collect(Collectors.toList());
314 tapiFullFactory.convertRdmToRdmLinks(rdmTordmLinkList);
316 assertEquals(2, tapiFullFactory.getTapiNodes().size(), "Node list size should be 2");
317 assertEquals(1, tapiFullFactory.getTapiLinks().size(), "Link list size should be 1");
319 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
320 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
322 for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : tapiNodes) {
323 if (node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
324 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
325 LOG.info("LOOP ROADM node found at rank {}, with Name {} and Uuid {}",
326 myInt, node.getName().toString(), node.getUuid());
330 Uuid roadmaNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
331 .getBytes(Charset.forName("UTF-8"))).toString());
332 LOG.info("ROADM node found at rank {} from getrank", getNodeRank("ROADM-A1", tapiNodes));
333 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmaNodeUuid, "roadm", "ROADM-A1");
335 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
336 = tapiFullFactory.getTapiLinks().values().stream()
337 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
338 .collect(Collectors.toList());
339 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
341 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-C1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
343 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
344 .getBytes(Charset.forName("UTF-8"))).toString());
345 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
346 .getBytes(Charset.forName("UTF-8"))).toString());
348 new Uuid(UUID.nameUUIDFromBytes(
349 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
350 .getBytes(Charset.forName("UTF-8"))).toString());
351 checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
352 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX");
356 void convertNodeForRoadmWhenOtnMuxAttached() {
357 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
358 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
359 List<String> networkPortListA = new ArrayList<>();
360 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
361 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
362 networkPortListA.add(tp.getTpId().getValue());
365 tapiFactory.convertNode(otnMuxA, networkPortListA);
366 tapiFullFactory.setTapiNodes(tapiFactory.getTapiNodes());
367 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
368 List<Link> xponderOutLinkList = ortopoLinks.values().stream()
369 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
370 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
371 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
372 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
373 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
374 .collect(Collectors.toList());
375 List<Link> xponderInLinkList = ortopoLinks.values().stream()
376 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
377 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
378 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
379 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
380 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
381 .collect(Collectors.toList());
382 xponderInLinkList.addAll(xponderOutLinkList);
383 tapiFullFactory.convertXpdrToRdmLinks(xponderInLinkList);
384 assertEquals(2, tapiFullFactory.getTapiNodes().size(),
385 "Node list size should be 2 (XPDR, DSR-ODU merged; ROADM)");
386 assertEquals(1, tapiFullFactory.getTapiLinks().size(),
387 "Link list size should be 1 : no more transitional link");
388 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
389 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
390 tapiFactory.getTapiNodes();
391 nodeMap.putAll(tapiFullFactory.getTapiNodes());
392 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
393 = nodeMap.values().stream()
394 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
395 .collect(Collectors.toList());
396 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
397 .getBytes(Charset.forName("UTF-8"))).toString());
398 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
400 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
402 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
404 LOG.info("ROADM-A1+PHOTONIC_MEDIA UUID is {}", node2Uuid);
405 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
406 .getBytes(Charset.forName("UTF-8"))).toString());
407 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRX")
408 .getBytes(Charset.forName("UTF-8"))).toString());
410 new Uuid(UUID.nameUUIDFromBytes(
411 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
412 .getBytes(Charset.forName("UTF-8"))).toString());
413 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
414 = tapiFullFactory.getTapiLinks().values().stream()
415 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
416 .collect(Collectors.toList());
417 checkXpdrRdmLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
418 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1");
421 private void rawConvertNode(Node node0, String dsrNodeType, String nodeId) {
422 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
423 tapiFactory.convertNode(
425 node0.augmentation(Node1.class).getTerminationPoint().values().stream()
426 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
427 .equals(OpenroadmTpType.XPONDERNETWORK))
428 .map(tp -> tp.getTpId().getValue())
429 .collect(Collectors.toList()));
430 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
431 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
432 //checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
433 // Uuid node9Uuid, String dsrNodeType, String nodeId) {
435 new Uuid(UUID.nameUUIDFromBytes((nodeId + "+XPONDER").getBytes(Charset.forName("UTF-8"))).toString());
437 tapiFactory.getTapiNodes().values().stream()
438 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
439 .findFirst().orElseThrow();
440 assertEquals(node9Uuid, node.getUuid(), "incorrect node uuid");
441 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
442 "incorrect node name");
443 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
444 "administrative state should be UNLOCKED");
445 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
446 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
447 assertThat("one value-name should be 'dsr/odu node name'",
448 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
449 assertEquals(4, node.getLayerProtocolName().size(), "dsr node should manage 4 protocol layers : dsr and odu"
450 + " DIGITALOTN, PHOTONICMEDIA");
451 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
452 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
453 List<OwnedNodeEdgePoint> inepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
454 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
455 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
456 .collect(Collectors.toList());
457 List<OwnedNodeEdgePoint> enepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
458 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint_N")))
459 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
460 .collect(Collectors.toList());
461 List<OwnedNodeEdgePoint> nepsC;
462 switch (dsrNodeType) {
464 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
465 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
466 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
467 .collect(Collectors.toList());
468 assertEquals(4, enepsN.size(), "Switch-DSR node should have 4 eNEPs network");
469 assertEquals(4, inepsN.size(), "Switch-DSR node should have 4 iNEPs network");
470 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
471 OwnedNodeEdgePoint nep1 = nepsC.get(2);
472 Uuid client4NepUuid = new Uuid(
473 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
475 checkNepClient100GSwitch(nep1, client4NepUuid, nodeId + "+DSR+XPDR2-CLIENT4", "NodeEdgePoint_C");
476 OwnedNodeEdgePoint enep2 = enepsN.get(2);
477 OwnedNodeEdgePoint inep2 = inepsN.get(3);
478 Uuid enetworkNepUuid = new Uuid(
479 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
481 Uuid inetworkNepUuid = new Uuid(
482 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
484 checkNepeODU4(enep2, enetworkNepUuid, nodeId + "+eODU+XPDR2-CLIENT4", "eNodeEdgePoint_N", false);
485 checkNepNetworkODU4(inep2, inetworkNepUuid, nodeId + "+iODU+XPDR2-NETWORK1", "iNodeEdgePoint_N", true);
486 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
487 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
488 .collect(Collectors.toList());
489 // keep trace of the previous test performed before the structure of the NRG was modified
490 // checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, enetworkNepUuid, node9Uuid);
491 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, inetworkNepUuid, node9Uuid);
494 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
495 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
496 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
497 .collect(Collectors.toList());
498 assertEquals(4, enepsN.size(), "Mux-DSR node should have 4 eNEP network");
499 assertEquals(1, inepsN.size(), "Mux-DSR node should have 1 iNEP network");
500 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
501 OwnedNodeEdgePoint nep3 = nepsC.get(2);
502 Uuid client3NepUuid = new Uuid(
503 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
505 checkNepClient10G(nep3, client3NepUuid, nodeId + "+DSR+XPDR1-CLIENT3", "NodeEdgePoint_C");
506 OwnedNodeEdgePoint enep4 = enepsN.get(3);
507 OwnedNodeEdgePoint inep4 = inepsN.get(0);
508 Uuid eclientNepUuid2 = new Uuid(
509 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
511 Uuid inetworkNepUuid2 = new Uuid(
512 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
514 checkNepeODU4(enep4, eclientNepUuid2, nodeId + "+eODU+XPDR1-CLIENT3", "eNodeEdgePoint_N", false);
515 checkNepNetworkODU4(inep4, inetworkNepUuid2, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
517 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
518 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
519 .collect(Collectors.toList());
520 // keep trace of the previous test performed before the structure of the NRG was modified
521 // checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, eclientNepUuid2, node9Uuid);
522 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, inetworkNepUuid2, node9Uuid);
525 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
526 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
527 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
528 .collect(Collectors.toList());
529 assertEquals(2, enepsN.size(), "Tpdr-DSR node should have 2 eNEPs network");
530 assertEquals(2, inepsN.size(), "Tpdr-DSR node should have 2 iNEPs network");
531 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
532 OwnedNodeEdgePoint nep5 = nepsC.get(0);
533 Uuid client1NepUuid = new Uuid(
534 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
536 checkNepClient100GTpdr(nep5, client1NepUuid, nodeId + "+DSR+XPDR1-CLIENT1", "100G-tpdr");
537 OwnedNodeEdgePoint enep6 = enepsN.get(0);
538 OwnedNodeEdgePoint inep6 = inepsN.get(1);
539 Uuid enetworkNepUuid3 = new Uuid(
540 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
542 Uuid inetworkNepUuid3 = new Uuid(
543 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
545 checkNepeODU4(enep6, enetworkNepUuid3, nodeId + "+eODU+XPDR1-CLIENT1", "eNodeEdgePoint_N", false);
546 checkNepNetworkODU4(inep6, inetworkNepUuid3, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
548 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
549 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
550 .collect(Collectors.toList());
551 // keep trace of the previous test performed before the structure of the NRG was modified
552 // checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, enetworkNepUuid3, node9Uuid);
553 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, inetworkNepUuid3, node9Uuid);
561 private void checkOtsiNode(
562 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
563 Uuid nodeUuid, String otsiNodeType, String nodeId) {
564 if (!node.getUuid().equals(nodeUuid)) {
565 LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName().toString(), nodeId);
566 LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid);
568 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
569 List<OwnedNodeEdgePoint> nepsI = null;
570 List<OwnedNodeEdgePoint> nepsE = null;
571 List<OwnedNodeEdgePoint> nepsP = null;
572 List<OwnedNodeEdgePoint> nepsOMS = null;
573 List<OwnedNodeEdgePoint> nepsOTS = null;
574 List<OwnedNodeEdgePoint> nepsPhot = null;
575 if (!otsiNodeType.equals("roadm")) {
576 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
577 "incorrect node name");
578 assertThat("one value-name should be 'dsr/odu node name'",
579 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
580 nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
581 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
582 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
583 .collect(Collectors.toList());
584 nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
585 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
586 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
587 .collect(Collectors.toList());
588 nepsP = node.nonnullOwnedNodeEdgePoint().values().stream()
589 .filter(n -> n.getName().containsKey(new NameKey("PhotMedNodeEdgePoint")))
590 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
591 .collect(Collectors.toList());
593 assertEquals(nodeId + "+PHOTONIC_MEDIA", node.getName().get(new NameKey("roadm node name")).getValue(),
594 "incorrect node name");
595 assertThat("one value-name should be 'dsr/odu node name'",
596 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
597 nepsOMS = node.nonnullOwnedNodeEdgePoint().values().stream()
598 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
599 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
600 .collect(Collectors.toList());
601 nepsOTS = node.nonnullOwnedNodeEdgePoint().values().stream()
602 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
603 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
604 .collect(Collectors.toList());
605 nepsPhot = node.nonnullOwnedNodeEdgePoint().values().stream()
606 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
607 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
608 .collect(Collectors.toList());
609 nepsPhot.addAll(node.nonnullOwnedNodeEdgePoint().values().stream()
610 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
611 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
612 .collect(Collectors.toList()));
614 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
615 "administrative state should be UNLOCKED");
616 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
617 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
618 assertEquals(1, node.getLayerProtocolName().size(),
619 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
620 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
621 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
623 switch (otsiNodeType) {
625 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
626 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
627 assertEquals(4, nepsP.size(), "Switch-OTSi node should have 4 photNEPs");
628 OwnedNodeEdgePoint nep1 = nepsI.get(1);
629 Uuid inepUuid = new Uuid(
630 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
632 checkNepOtsiNode(nep1, inepUuid, nodeId + "+iOTSi+XPDR2-NETWORK2", "iNodeEdgePoint", true);
633 OwnedNodeEdgePoint nep2 = nepsE.get(0);
634 Uuid enepUuid = new Uuid(
635 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
636 .getBytes(Charset.forName("UTF-8")))
638 checkNepOtsiNode(nep2, enepUuid, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2",
639 "eNodeEdgePoint", false);
640 OwnedNodeEdgePoint photNep = nepsP.get(1);
641 Uuid pnepUuid = new Uuid(
642 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2")
643 .getBytes(Charset.forName("UTF-8"))).toString());
644 checkNepOtsiNode(photNep, pnepUuid, nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2", "PhotMedNodeEdgePoint",
646 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
647 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
648 .collect(Collectors.toList());
649 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
652 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
653 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
654 assertEquals(1, nepsP.size(), "Mux-OTSi node should have 1 photNEPs");
655 OwnedNodeEdgePoint nep3 = nepsE.get(0);
656 Uuid enepUuid2 = new Uuid(
657 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
658 .getBytes(Charset.forName("UTF-8")))
660 checkNepOtsiNode(nep3, enepUuid2, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
661 "eNodeEdgePoint", false);
662 OwnedNodeEdgePoint nep4 = nepsI.get(0);
663 Uuid inepUuid2 = new Uuid(
664 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
666 checkNepOtsiNode(nep4, inepUuid2, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
667 OwnedNodeEdgePoint photNep1 = nepsP.get(0);
668 Uuid pnep1Uuid = new Uuid(
669 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
670 .getBytes(Charset.forName("UTF-8"))).toString());
671 checkNepOtsiNode(photNep1, pnep1Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
673 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
674 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
675 .collect(Collectors.toList());
676 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
679 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
680 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
681 assertEquals(2, nepsP.size(), "Tpdr-OTSi node should have 2 photNEPs");
682 OwnedNodeEdgePoint nep5 = nepsE.get(0);
683 Uuid enepUuid3 = new Uuid(
684 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
685 .getBytes(Charset.forName("UTF-8")))
687 checkNepOtsiNode(nep5, enepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
688 "eNodeEdgePoint", false);
689 OwnedNodeEdgePoint nep6 = nepsI.get(0);
690 Uuid inepUuid3 = new Uuid(
691 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
693 checkNepOtsiNode(nep6, inepUuid3, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
694 OwnedNodeEdgePoint photNep2 = nepsP.get(0);
695 Uuid pnep2Uuid = new Uuid(
696 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
697 .getBytes(Charset.forName("UTF-8"))).toString());
698 checkNepOtsiNode(photNep2, pnep2Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
700 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
701 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
702 .collect(Collectors.toList());
703 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
706 // Keep trace of MC NEP test to be restored after the new policy for creating NEP is applied
707 // assertEquals(0, nepsMc.size(), "MC NEP no more configured, Roadm node should have 0 MC NEPs");
708 // assertEquals(0, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs");
709 assertEquals(12, nepsPhot.size(), "Roadm node should have 12 PHOT_MEDIA NEPs (2x4 OTS +2x(OTS+OMS)");
711 OwnedNodeEdgePoint nep7 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
712 Uuid mcnepUuid3 = new Uuid(
713 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX").getBytes(Charset
714 .forName("UTF-8"))).toString());
715 checkNepOtsiRdmNode(nep7, mcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
716 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
717 OwnedNodeEdgePoint nep8 = nepsOTS.get(getRank("DEG1-TTP", nepsOTS));
718 Uuid otmcnepUuid3 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
719 .getBytes(Charset.forName("UTF-8"))).toString());
720 checkNepOtsiRdmNode(nep8, otmcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX",
721 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
722 OwnedNodeEdgePoint omsNep3 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
723 Uuid omsNep3Uuid = new Uuid(
724 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX")
725 .getBytes(Charset.forName("UTF-8"))).toString());
726 checkNepOtsiRdmNode(omsNep3, omsNep3Uuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
727 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
729 OwnedNodeEdgePoint nep10 = nepsOTS.get(getRank("SRG1-PP1", nepsOTS));
730 Uuid otsnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX")
731 .getBytes(Charset.forName("UTF-8"))).toString());
732 checkNepOtsiRdmNode(nep10, otsnepUuid4, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX",
733 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
734 OwnedNodeEdgePoint otsNep4 = nepsOTS.get(getRank("SRG1-PP3", nepsOTS));
735 Uuid otsNep4Uuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX")
736 .getBytes(Charset.forName("UTF-8"))).toString());
737 checkNepOtsiRdmNode(otsNep4, otsNep4Uuid, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX",
738 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
739 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
740 .sorted((nrg1, nrg2) -> nrg1.getName().entrySet().iterator().next().getValue().toString()
741 .compareTo(nrg2.getName().entrySet().iterator().next().getValue().toString()))
742 .collect(Collectors.toList());
743 LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4.toString());
744 List<Integer> nepNumber = new ArrayList<>(List.of(2, 4, 4));
745 checkNodeRuleGroupForRdm(nrgList4, nepNumber);
753 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
755 List.of(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE), LayerProtocolName.DSR,
756 false, nep, nepUuid, portName, nepName, false);
759 private void checkNepeODU4(
760 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
762 List.of(ODUTYPEODU0.VALUE, ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, ODUTYPEODU4.VALUE), LayerProtocolName.ODU,
763 true, nep, nepUuid, portName, nepName, withSip);
766 private void checkNepNetworkODU4(
767 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
769 List.of(ODUTYPEODU4.VALUE), LayerProtocolName.ODU, false,
770 nep, nepUuid, portName, nepName, withSip);
773 private void checkNodeRuleGroupForTpdrDSR(
774 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
775 assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
776 for (NodeRuleGroup nodeRuleGroup : nrgList) {
777 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
778 "each node-rule-group should contain 2 NEP for transponder DSR");
780 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
781 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
782 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
783 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
784 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
785 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
786 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
787 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
788 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
789 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
790 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
791 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
792 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
793 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
794 assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
795 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
796 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
797 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
798 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
799 "the rule type should be 'FORWARDING'");
802 private void checkNodeRuleGroupForMuxDSR(
803 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
804 assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
805 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
806 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
807 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
808 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
809 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
810 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
811 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
812 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
813 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
814 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
815 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
816 assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
817 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
818 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
819 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
820 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
821 "the rule type should be 'FORWARDING'");
824 private void checkNodeRuleGroupForSwitchDSR(
825 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
826 assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
827 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
828 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
829 assertEquals(8, nrgList.get(indNrg).getNodeEdgePoint().size(), "Switch-DSR nrg should contain 8 NEP");
830 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
831 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
832 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
833 .collect(Collectors.toList());
835 for (NodeEdgePoint nep : nrg) {
836 LOG.info("nep number {} UUID is {} ", xxxxx, nep.getNodeEdgePointUuid());
839 LOG.info("nep SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK1 UUID is {} ",
840 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))));
841 LOG.info("nep SPDR-SA1-XPDR2+DSR+XPDR2-CLIENT4 UUID is {} ",
842 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))));
843 assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
844 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
845 assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
846 "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
847 assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
848 "any item of the node-rule-group should have the same nodeUuid");
849 assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
850 "any item of the node-rule-group should have the same nodeUuid");
852 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
853 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
854 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
855 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
856 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
857 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
858 "the rule type should be 'FORWARDING'");
861 private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, List<Integer> nbNeps) {
862 assertEquals(3, nrgList.size(), "RDM infra node - OTS should contain 3 node rule groups");
864 for (NodeRuleGroup nrg : nrgList) {
865 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrg.getNodeEdgePoint().values());
866 assertEquals(nbNeps.get(index), nodeEdgePointList.size(),
867 "RDM infra node -rule-group should contain " + nbNeps.get(index) + " NEP");
868 List<Rule> ruleList = new ArrayList<>(nrg.nonnullRule().values());
869 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
870 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
871 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
872 "the rule type should be 'FORWARDING'");
873 if (nrg.getName().entrySet().iterator().next().getValue().toString().contains("DEG")) {
874 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
875 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
877 assertEquals(FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
878 "the forwarding rule should be 'CANNOTFORWARDACROSSGROUP'");
884 private void checkNodeRuleGroupForTpdrOTSi(
885 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
886 assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
887 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
888 assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
889 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
890 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
891 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
892 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
893 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
894 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
895 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
896 "any item of the node-rule-group should have the same nodeUuid");
897 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
898 "any item of the node-rule-group should have the same nodeUuid");
899 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
900 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
901 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
902 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
903 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
904 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
905 "the rule type should be 'FORWARDING'");
908 private void checkNodeRuleGroupForMuxOTSi(
909 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
910 assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
911 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
912 assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
913 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
914 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
915 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
916 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
917 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
918 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
919 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
920 "any item of the node-rule-group should have the same nodeUuid");
921 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
922 "any item of the node-rule-group should have the same nodeUuid");
923 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
924 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
925 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
926 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
927 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
928 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
929 "the rule type should be 'FORWARDING'");
932 private void checkNodeRuleGroupForSwitchOTSi(
933 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
934 assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
935 for (NodeRuleGroup nodeRuleGroup : nrgList) {
936 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
937 "each node-rule-group should contain 2 NEP for Switch-OTSi");
939 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
940 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
941 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
942 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
943 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
944 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
945 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
946 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
947 assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
948 "any item of the node-rule-group should have the same nodeUuid");
949 assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
950 "any item of the node-rule-group should have the same nodeUuid");
951 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
952 assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
953 assertEquals("forward", ruleList0.get(0).getLocalId(), "local-id of the rule should be 'forward'");
954 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
955 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
956 assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().stream().findFirst().orElseThrow(),
957 "the rule type should be 'FORWARDING'");
960 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
962 List.of(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
963 nep, nepUuid, portName, nepName, false);
966 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
968 List.of(DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
969 nep, nepUuid, portName, nepName, false);
972 private void checkNepOtsiNode(
973 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
975 List.of(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE), LayerProtocolName.PHOTONICMEDIA,
976 false, nep, nepUuid, portName, nepName, withSip);
979 private void checkNepOtsiRdmNode(
980 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
981 if (!nep.getUuid().equals(nepUuid)) {
982 LOG.info("ERRORUUIDNEP on Nep {}, expected {}", nep.getName(), portName);
984 rawCheckNep(nepName.contains("OMS")
985 ? List.of(PHOTONICLAYERQUALIFIEROMS.VALUE)
986 : nepName.contains("OTS") ? List.of(PHOTONICLAYERQUALIFIEROTS.VALUE) : null,
987 LayerProtocolName.PHOTONICMEDIA, false, nep, nepUuid, portName, nepName, withSip);
990 private void rawCheckNep(List<LAYERPROTOCOLQUALIFIER> lpqList, LayerProtocolName lpn, boolean anyInList,
991 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
992 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
993 Name name0 = nep.nonnullName().values().stream().findFirst().orElseThrow();
994 assertEquals(portName, name0.getValue(), "Value of nep port should be '" + portName + "'");
995 assertEquals(nepName, name0.getValueName(), "value-name of nep should be '" + nepName + "'");
996 if (lpqList != null) {
997 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
998 .map(entry -> entry.getLayerProtocolQualifier())
999 .collect(Collectors.toList());
1002 lpql.size() < lpqList.size(),
1003 //TODO lpqList.size() = 4 here -> check if this is the correct formula from an optical standpoint
1004 "eODU nep should support less than " + lpqList.size() + " kind of cep, it depends on client port");
1006 lpqList.stream().anyMatch(splc -> lpql.contains(splc)),
1007 "eODU nep should support 1 kind of cep");
1009 assertEquals(lpqList.size(), lpql.size(), "nep should support " + lpqList.size() + " kind of cep(s)");
1010 for (LAYERPROTOCOLQUALIFIER lpq: lpqList) {
1011 assertThat("nep should support " + lpq + " cep", lpql, hasItem(lpq));
1013 assertEquals(lpn, nep.getLayerProtocolName(), "nep should be of " + lpn.toString() + " protocol type");
1016 // CommonPartOfNep(OwnedNodeEdgePoint nep, boolean withSip)
1017 assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(), "link port direction should be DIRECTIONAL");
1018 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1019 "administrative state should be UNLOCKED");
1020 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1021 // assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1022 // "termination state should be TERMINATED BIDIRECTIONAL");
1023 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(), "life-cycle state should be INSTALLED");
1025 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "Given nep should support 1 SIP");
1027 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1028 // assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1029 // "termination direction should be BIDIRECTIONAL");
1030 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1031 "operational state of client nep should be ENABLED");
1032 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(),
1033 "link-port-role of client nep should be SYMMETRIC");
1036 private void checkOmsLink(
1037 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1038 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1039 assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1040 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1043 private void checkXpdrRdmLink(
1044 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1045 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1046 assertEquals(linkName, link.getName().get(new NameKey("XPDR-RDM link name")).getValue(),
1047 "bad name for the link");
1048 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1051 private void linkNepsCheck(
1052 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1053 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid) {
1054 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1056 LayerProtocolName.PHOTONICMEDIA.getName(),
1057 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1058 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1059 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1060 "otn tapi link should be BIDIRECTIONAL");
1061 var nodeEdgePointList = link.nonnullNodeEdgePoint().values().stream().collect(Collectors.toList());
1062 assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1063 var nep0 = nodeEdgePointList.get(0);
1064 var nep1 = nodeEdgePointList.get(1);
1065 assertEquals(topologyUuid, nep0.getTopologyUuid(),
1066 "topology uuid should be the same for the two termination point of the link");
1067 assertEquals(topologyUuid, nep1.getTopologyUuid(),
1068 "topology uuid should be the same for the two termination point of the link");
1069 String node1UuidVal = node1Uuid.getValue();
1070 String node2UuidVal = node2Uuid.getValue();
1071 assertThat("oms links should terminate on two distinct nodes",
1072 nep0.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1073 assertThat("oms links should terminate on two distinct nodes",
1074 nep1.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1075 String tp1UuidVal = tp1Uuid.getValue();
1076 String tp2UuidVal = tp2Uuid.getValue();
1077 assertThat("oms links should terminate on two distinct tps",
1078 nep0.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1079 assertThat("oms links should terminate on two distinct tps",
1080 nep1.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1083 private Node changeTerminationPointState(
1084 Node initialNode, String tpid, String tpid1, AdminStates admin, State oper) {
1085 var tpdr1Bldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1086 .Node1Builder(initialNode.augmentation(Node1.class));
1087 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1088 TerminationPointBuilder tpBldr = new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid))));
1089 tpBldr.addAugmentation(
1090 new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1091 .setAdministrativeState(admin)
1092 .setOperationalState(oper)
1094 tps.replace(tpBldr.key(), tpBldr.build());
1095 TerminationPointBuilder tpBldr1 =
1096 new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid1))));
1097 tpBldr1.addAugmentation(
1098 new TerminationPoint1Builder(tpBldr1.augmentation(TerminationPoint1.class))
1099 .setAdministrativeState(admin)
1100 .setOperationalState(oper)
1102 tps.replace(tpBldr1.key(), tpBldr1.build());
1103 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.setTerminationPoint(tps).build()).build();
1106 private int getRank(String searchedChar, List<OwnedNodeEdgePoint> onepList) {
1108 searchedChar, onepList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1111 private int getNodeRank(String searchedChar,
1112 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1114 searchedChar, nodeList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1117 private int rawRank(String searchedChar, List<Collection<Name>> nameCL) {
1118 int foundAtRank = 0;
1120 for (var nameC: nameCL) {
1121 for (Name name: nameC) {
1122 if (name.getValue().contains(searchedChar)) {
1124 //TODO should we really pursue once it is found ?
1129 LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
1133 private Integer nrgContainsClientAndNetwork(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid) {
1134 // 1 NRG should at least contain the NEP of interest in the NEP List
1135 Integer indexNrg = 0;
1136 for (NodeRuleGroup nrg : nrgList) {
1137 Boolean foundClient = false;
1138 Boolean foundNetwork = false;
1139 for (NodeEdgePoint nep : nrg.nonnullNodeEdgePoint().values()) {
1140 foundClient = foundClient || nep.getNodeEdgePointUuid().equals(clientNepUuid);
1141 foundNetwork = foundNetwork || nep.getNodeEdgePointUuid().equals(networkNepUuid);
1143 if (foundClient && foundNetwork) {