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 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
219 tapiFactory.convertNode(
220 changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1", null, null),
221 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
222 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
223 .equals(OpenroadmTpType.XPONDERNETWORK))
224 .map(tp -> tp.getTpId().getValue())
225 .collect(Collectors.toList()));
226 var dsrNodeOoNep = tapiFactory
228 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
229 .topology.NodeKey(new Uuid(
230 UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
232 .nonnullOwnedNodeEdgePoint();
233 OwnedNodeEdgePoint enepN = dsrNodeOoNep.get(new OwnedNodeEdgePointKey(new Uuid(
234 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
236 assertNull(enepN.getAdministrativeState(), "Administrative State should not be present");
237 assertNull(enepN.getOperationalState(), "Operational State should not be present");
238 OwnedNodeEdgePoint inepN = dsrNodeOoNep.get(new OwnedNodeEdgePointKey(new Uuid(
239 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
241 assertNull(inepN.getAdministrativeState(), "Administrative State should not be present");
242 assertNull(inepN.getOperationalState(), "Operational State should not be present");
246 void convertNodeWhenBadStates1() {
247 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
248 AdminStates.OutOfService, State.OutOfService);
249 List<String> networkPortList = new ArrayList<>();
250 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
251 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
252 networkPortList.add(tp.getTpId().getValue());
255 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
256 tapiFactory.convertNode(tpdr, networkPortList);
258 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
260 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
261 .getTapiNodes().get(new
262 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
263 Uuid enetworkNepUuid = new Uuid(
264 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
266 Uuid inetworkNepUuid = new Uuid(
267 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
269 OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
270 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
271 "Administrative State should be Locked");
272 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
274 OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
275 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
276 "Administrative State should be Locked");
277 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
281 void convertNodeWhenBadStates2() {
282 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
283 AdminStates.Maintenance, State.Degraded);
284 List<String> networkPortList = new ArrayList<>();
285 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
286 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
287 networkPortList.add(tp.getTpId().getValue());
290 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
291 tapiFactory.convertNode(tpdr, networkPortList);
293 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
295 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
296 .getTapiNodes().get(new
297 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
298 Uuid enetworkNepUuid = new Uuid(
299 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
301 Uuid inetworkNepUuid = new Uuid(
302 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
304 OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
305 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
306 "Administrative State should be Locked");
307 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
309 OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
310 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
311 "Administrative State should be Locked");
312 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
317 void convertNodeForTransponder100G() {
318 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
319 List<String> networkPortList = new ArrayList<>();
320 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
321 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
322 networkPortList.add(tp.getTpId().getValue());
325 tapiFactory.convertNode(tpdr100G, networkPortList);
326 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
327 = tapiFactory.getTapiNodes().values().stream()
328 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
329 .collect(Collectors.toList());
331 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
332 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
334 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
336 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1");
340 void convertNodeForOtnMuxponder() {
341 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
342 List<String> networkPortList = new ArrayList<>();
343 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
344 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
345 networkPortList.add(tp.getTpId().getValue());
348 tapiFactory.convertNode(otnMuxA, networkPortList);
349 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
350 = tapiFactory.getTapiNodes().values().stream()
351 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
352 .collect(Collectors.toList());
354 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
355 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
356 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
358 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1");
362 void convertNodeForOtnSwitch() {
363 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
364 List<String> networkPortList = new ArrayList<>();
365 for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
366 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
367 networkPortList.add(tp.getTpId().getValue());
370 tapiFactory.convertNode(otnSwitch, networkPortList);
371 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
372 = tapiFactory.getTapiNodes().values().stream()
373 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
374 .collect(Collectors.toList());
376 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
377 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
379 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8")))
381 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "switch", "SPDR-SA1-XPDR2");
385 void convertNodeForRoadmWhenNoOtnMuxAttached() {
386 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
387 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
389 assertEquals(1, tapiFullFactory.getTapiNodes().size(), "Node list size should be 1");
390 assertEquals(0, tapiFullFactory.getTapiLinks().size(), "Link list size should be empty");
391 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
392 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
393 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
394 .getBytes(Charset.forName("UTF-8"))).toString());
395 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
399 void convertNodeForRoadmWhenRoadmNeighborAttached() {
400 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
401 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
402 tapiFullFactory.convertRoadmNode(roadmC, openroadmNet, "Full");
404 List<Link> rdmTordmLinkList = ortopoLinks.values().stream()
405 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ROADMTOROADM))
406 .collect(Collectors.toList());
407 tapiFullFactory.convertRdmToRdmLinks(rdmTordmLinkList);
409 assertEquals(2, tapiFullFactory.getTapiNodes().size(), "Node list size should be 2");
410 assertEquals(1, tapiFullFactory.getTapiLinks().size(), "Link list size should be 1");
412 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
413 = tapiFullFactory.getTapiNodes().values().stream().collect(Collectors.toList());
415 for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : tapiNodes) {
416 if (node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
417 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
418 LOG.info("LOOP ROADM node found at rank {}, with Name {} and Uuid {}",
419 myInt, node.getName().toString(), node.getUuid());
423 Uuid roadmaNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
424 .getBytes(Charset.forName("UTF-8"))).toString());
425 LOG.info("ROADM node found at rank {} from getrank", getNodeRank("ROADM-A1", tapiNodes));
426 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmaNodeUuid, "roadm", "ROADM-A1");
428 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
429 = tapiFullFactory.getTapiLinks().values().stream()
430 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
431 .collect(Collectors.toList());
432 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
434 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-C1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
436 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
437 .getBytes(Charset.forName("UTF-8"))).toString());
438 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
439 .getBytes(Charset.forName("UTF-8"))).toString());
441 new Uuid(UUID.nameUUIDFromBytes(
442 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
443 .getBytes(Charset.forName("UTF-8"))).toString());
444 checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
445 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX");
449 void convertNodeForRoadmWhenOtnMuxAttached() {
450 ConvertORTopoToTapiFullTopo tapiFullFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
451 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
452 List<String> networkPortListA = new ArrayList<>();
453 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
454 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
455 networkPortListA.add(tp.getTpId().getValue());
458 tapiFactory.convertNode(otnMuxA, networkPortListA);
459 tapiFullFactory.setTapiNodes(tapiFactory.getTapiNodes());
460 tapiFullFactory.convertRoadmNode(roadmA, openroadmNet, "Full");
461 List<Link> xponderOutLinkList = ortopoLinks.values().stream()
462 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
463 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
464 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
465 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
466 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
467 .collect(Collectors.toList());
468 List<Link> xponderInLinkList = ortopoLinks.values().stream()
469 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
470 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
471 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
472 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
473 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
474 .collect(Collectors.toList());
475 xponderInLinkList.addAll(xponderOutLinkList);
476 tapiFullFactory.convertXpdrToRdmLinks(xponderInLinkList);
477 assertEquals(2, tapiFullFactory.getTapiNodes().size(),
478 "Node list size should be 2 (XPDR, DSR-ODU merged; ROADM)");
479 assertEquals(1, tapiFullFactory.getTapiLinks().size(),
480 "Link list size should be 1 : no more transitional link");
481 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
482 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
483 tapiFactory.getTapiNodes();
484 nodeMap.putAll(tapiFullFactory.getTapiNodes());
485 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
486 = nodeMap.values().stream()
487 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
488 .collect(Collectors.toList());
489 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
490 .getBytes(Charset.forName("UTF-8"))).toString());
491 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
493 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
495 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
497 LOG.info("ROADM-A1+PHOTONIC_MEDIA UUID is {}", node2Uuid);
498 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
499 .getBytes(Charset.forName("UTF-8"))).toString());
500 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRX")
501 .getBytes(Charset.forName("UTF-8"))).toString());
503 new Uuid(UUID.nameUUIDFromBytes(
504 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
505 .getBytes(Charset.forName("UTF-8"))).toString());
506 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
507 = tapiFullFactory.getTapiLinks().values().stream()
508 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
509 .collect(Collectors.toList());
510 checkXpdrRdmLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
511 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1");
514 private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
515 Uuid node9Uuid, String dsrNodeType, String nodeId) {
516 assertEquals(node9Uuid, node.getUuid(), "incorrect node uuid");
517 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
518 "incorrect node name");
519 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
520 "administrative state should be UNLOCKED");
521 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
522 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
523 assertThat("one value-name should be 'dsr/odu node name'",
524 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
525 assertEquals(4, node.getLayerProtocolName().size(), "dsr node should manage 4 protocol layers : dsr and odu"
526 + " DIGITALOTN, PHOTONICMEDIA");
527 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
528 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
529 List<OwnedNodeEdgePoint> inepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
530 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
531 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
532 .collect(Collectors.toList());
533 List<OwnedNodeEdgePoint> enepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
534 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint_N")))
535 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
536 .collect(Collectors.toList());
537 List<OwnedNodeEdgePoint> nepsC;
538 switch (dsrNodeType) {
540 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
541 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
542 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
543 .collect(Collectors.toList());
544 assertEquals(4, enepsN.size(), "Switch-DSR node should have 4 eNEPs network");
545 assertEquals(4, inepsN.size(), "Switch-DSR node should have 4 iNEPs network");
546 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
547 OwnedNodeEdgePoint nep1 = nepsC.get(2);
548 Uuid client4NepUuid = new Uuid(
549 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
551 checkNepClient100GSwitch(nep1, client4NepUuid, nodeId + "+DSR+XPDR2-CLIENT4", "NodeEdgePoint_C");
552 OwnedNodeEdgePoint enep2 = enepsN.get(2);
553 OwnedNodeEdgePoint inep2 = inepsN.get(3);
554 Uuid enetworkNepUuid = new Uuid(
555 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
557 Uuid inetworkNepUuid = new Uuid(
558 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
560 checkNepeODU4(enep2, enetworkNepUuid, nodeId + "+eODU+XPDR2-CLIENT4", "eNodeEdgePoint_N", false);
561 checkNepNetworkODU4(inep2, inetworkNepUuid, nodeId + "+iODU+XPDR2-NETWORK1", "iNodeEdgePoint_N", true);
562 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
563 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
564 .collect(Collectors.toList());
565 // keep trace of the previous test performed before the structure of the NRG was modified
566 // checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, enetworkNepUuid, node9Uuid);
567 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, inetworkNepUuid, node9Uuid);
570 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
571 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
572 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
573 .collect(Collectors.toList());
574 assertEquals(4, enepsN.size(), "Mux-DSR node should have 4 eNEP network");
575 assertEquals(1, inepsN.size(), "Mux-DSR node should have 1 iNEP network");
576 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
577 OwnedNodeEdgePoint nep3 = nepsC.get(2);
578 Uuid client3NepUuid = new Uuid(
579 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
581 checkNepClient10G(nep3, client3NepUuid, nodeId + "+DSR+XPDR1-CLIENT3", "NodeEdgePoint_C");
582 OwnedNodeEdgePoint enep4 = enepsN.get(3);
583 OwnedNodeEdgePoint inep4 = inepsN.get(0);
584 Uuid eclientNepUuid2 = new Uuid(
585 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
587 Uuid inetworkNepUuid2 = new Uuid(
588 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
590 checkNepeODU4(enep4, eclientNepUuid2, nodeId + "+eODU+XPDR1-CLIENT3", "eNodeEdgePoint_N", false);
591 checkNepNetworkODU4(inep4, inetworkNepUuid2, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
593 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
594 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
595 .collect(Collectors.toList());
596 // keep trace of the previous test performed before the structure of the NRG was modified
597 // checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, eclientNepUuid2, node9Uuid);
598 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, inetworkNepUuid2, node9Uuid);
601 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
602 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
603 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
604 .collect(Collectors.toList());
605 assertEquals(2, enepsN.size(), "Tpdr-DSR node should have 2 eNEPs network");
606 assertEquals(2, inepsN.size(), "Tpdr-DSR node should have 2 iNEPs network");
607 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
608 OwnedNodeEdgePoint nep5 = nepsC.get(0);
609 Uuid client1NepUuid = new Uuid(
610 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
612 checkNepClient100GTpdr(nep5, client1NepUuid, nodeId + "+DSR+XPDR1-CLIENT1", "100G-tpdr");
613 OwnedNodeEdgePoint enep6 = enepsN.get(0);
614 OwnedNodeEdgePoint inep6 = inepsN.get(1);
615 Uuid enetworkNepUuid3 = new Uuid(
616 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
618 Uuid inetworkNepUuid3 = new Uuid(
619 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
621 checkNepeODU4(enep6, enetworkNepUuid3, nodeId + "+eODU+XPDR1-CLIENT1", "eNodeEdgePoint_N", false);
622 checkNepNetworkODU4(inep6, inetworkNepUuid3, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
624 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
625 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
626 .collect(Collectors.toList());
627 // keep trace of the previous test performed before the structure of the NRG was modified
628 // checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, enetworkNepUuid3, node9Uuid);
629 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, inetworkNepUuid3, node9Uuid);
637 private void checkOtsiNode(
638 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
639 Uuid nodeUuid, String otsiNodeType, String nodeId) {
640 if (!node.getUuid().equals(nodeUuid)) {
641 LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName().toString(), nodeId);
642 LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid);
644 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
645 List<OwnedNodeEdgePoint> nepsI = null;
646 List<OwnedNodeEdgePoint> nepsE = null;
647 List<OwnedNodeEdgePoint> nepsP = null;
648 List<OwnedNodeEdgePoint> nepsOMS = null;
649 List<OwnedNodeEdgePoint> nepsOTS = null;
650 List<OwnedNodeEdgePoint> nepsPhot = null;
651 if (!otsiNodeType.equals("roadm")) {
652 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
653 "incorrect node name");
654 assertThat("one value-name should be 'dsr/odu node name'",
655 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
656 nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
657 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
658 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
659 .collect(Collectors.toList());
660 nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
661 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
662 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
663 .collect(Collectors.toList());
664 nepsP = node.nonnullOwnedNodeEdgePoint().values().stream()
665 .filter(n -> n.getName().containsKey(new NameKey("PhotMedNodeEdgePoint")))
666 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
667 .collect(Collectors.toList());
669 assertEquals(nodeId + "+PHOTONIC_MEDIA", node.getName().get(new NameKey("roadm node name")).getValue(),
670 "incorrect node name");
671 assertThat("one value-name should be 'dsr/odu node name'",
672 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
673 nepsOMS = node.nonnullOwnedNodeEdgePoint().values().stream()
674 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
675 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
676 .collect(Collectors.toList());
677 nepsOTS = node.nonnullOwnedNodeEdgePoint().values().stream()
678 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
679 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
680 .collect(Collectors.toList());
681 nepsPhot = node.nonnullOwnedNodeEdgePoint().values().stream()
682 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
683 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
684 .collect(Collectors.toList());
685 nepsPhot.addAll(node.nonnullOwnedNodeEdgePoint().values().stream()
686 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
687 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
688 .collect(Collectors.toList()));
690 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
691 "administrative state should be UNLOCKED");
692 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
693 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
694 assertEquals(1, node.getLayerProtocolName().size(),
695 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
696 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
697 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
699 switch (otsiNodeType) {
701 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
702 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
703 assertEquals(4, nepsP.size(), "Switch-OTSi node should have 4 photNEPs");
704 OwnedNodeEdgePoint nep1 = nepsI.get(1);
705 Uuid inepUuid = new Uuid(
706 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
708 checkNepOtsiNode(nep1, inepUuid, nodeId + "+iOTSi+XPDR2-NETWORK2", "iNodeEdgePoint", true);
709 OwnedNodeEdgePoint nep2 = nepsE.get(0);
710 Uuid enepUuid = new Uuid(
711 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
712 .getBytes(Charset.forName("UTF-8")))
714 checkNepOtsiNode(nep2, enepUuid, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2",
715 "eNodeEdgePoint", false);
716 OwnedNodeEdgePoint photNep = nepsP.get(1);
717 Uuid pnepUuid = new Uuid(
718 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2")
719 .getBytes(Charset.forName("UTF-8"))).toString());
720 checkNepOtsiNode(photNep, pnepUuid, nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2", "PhotMedNodeEdgePoint",
722 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
723 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
724 .collect(Collectors.toList());
725 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
728 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
729 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
730 assertEquals(1, nepsP.size(), "Mux-OTSi node should have 1 photNEPs");
731 OwnedNodeEdgePoint nep3 = nepsE.get(0);
732 Uuid enepUuid2 = new Uuid(
733 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
734 .getBytes(Charset.forName("UTF-8")))
736 checkNepOtsiNode(nep3, enepUuid2, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
737 "eNodeEdgePoint", false);
738 OwnedNodeEdgePoint nep4 = nepsI.get(0);
739 Uuid inepUuid2 = new Uuid(
740 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
742 checkNepOtsiNode(nep4, inepUuid2, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
743 OwnedNodeEdgePoint photNep1 = nepsP.get(0);
744 Uuid pnep1Uuid = new Uuid(
745 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
746 .getBytes(Charset.forName("UTF-8"))).toString());
747 checkNepOtsiNode(photNep1, pnep1Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
749 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
750 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
751 .collect(Collectors.toList());
752 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
755 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
756 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
757 assertEquals(2, nepsP.size(), "Tpdr-OTSi node should have 2 photNEPs");
758 OwnedNodeEdgePoint nep5 = nepsE.get(0);
759 Uuid enepUuid3 = new Uuid(
760 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
761 .getBytes(Charset.forName("UTF-8")))
763 checkNepOtsiNode(nep5, enepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
764 "eNodeEdgePoint", false);
765 OwnedNodeEdgePoint nep6 = nepsI.get(0);
766 Uuid inepUuid3 = new Uuid(
767 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
769 checkNepOtsiNode(nep6, inepUuid3, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
770 OwnedNodeEdgePoint photNep2 = nepsP.get(0);
771 Uuid pnep2Uuid = new Uuid(
772 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
773 .getBytes(Charset.forName("UTF-8"))).toString());
774 checkNepOtsiNode(photNep2, pnep2Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
776 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
777 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
778 .collect(Collectors.toList());
779 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
782 // Keep trace of MC NEP test to be restored after the new policy for creating NEP is applied
783 // assertEquals(0, nepsMc.size(), "MC NEP no more configured, Roadm node should have 0 MC NEPs");
784 // assertEquals(0, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs");
785 assertEquals(12, nepsPhot.size(), "Roadm node should have 12 PHOT_MEDIA NEPs (2x4 OTS +2x(OTS+OMS)");
787 OwnedNodeEdgePoint nep7 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
788 Uuid mcnepUuid3 = new Uuid(
789 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX").getBytes(Charset
790 .forName("UTF-8"))).toString());
791 checkNepOtsiRdmNode(nep7, mcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
792 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
793 OwnedNodeEdgePoint nep8 = nepsOTS.get(getRank("DEG1-TTP", nepsOTS));
794 Uuid otmcnepUuid3 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
795 .getBytes(Charset.forName("UTF-8"))).toString());
796 checkNepOtsiRdmNode(nep8, otmcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX",
797 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
798 OwnedNodeEdgePoint omsNep3 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
799 Uuid omsNep3Uuid = new Uuid(
800 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX")
801 .getBytes(Charset.forName("UTF-8"))).toString());
802 checkNepOtsiRdmNode(omsNep3, omsNep3Uuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
803 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
805 OwnedNodeEdgePoint nep10 = nepsOTS.get(getRank("SRG1-PP1", nepsOTS));
806 Uuid otsnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX")
807 .getBytes(Charset.forName("UTF-8"))).toString());
808 checkNepOtsiRdmNode(nep10, otsnepUuid4, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX",
809 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
810 OwnedNodeEdgePoint otsNep4 = nepsOTS.get(getRank("SRG1-PP3", nepsOTS));
811 Uuid otsNep4Uuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX")
812 .getBytes(Charset.forName("UTF-8"))).toString());
813 checkNepOtsiRdmNode(otsNep4, otsNep4Uuid, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX",
814 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
815 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
816 .sorted((nrg1, nrg2) -> nrg1.getName().entrySet().iterator().next().getValue().toString()
817 .compareTo(nrg2.getName().entrySet().iterator().next().getValue().toString()))
818 .collect(Collectors.toList());
819 LOG.info("NODERULEGROUP List nrgLIst4 is as follows {}", nrgList4.toString());
820 List<Integer> nepNumber = new ArrayList<>(List.of(2, 4, 4));
821 checkNodeRuleGroupForRdm(nrgList4, nepNumber);
829 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
831 List.of(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE), LayerProtocolName.DSR,
832 false, nep, nepUuid, portName, nepName, false);
835 private void checkNepeODU4(
836 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
838 List.of(ODUTYPEODU0.VALUE, ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, ODUTYPEODU4.VALUE), LayerProtocolName.ODU,
839 true, nep, nepUuid, portName, nepName, withSip);
842 private void checkNepNetworkODU4(
843 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
845 List.of(ODUTYPEODU4.VALUE), LayerProtocolName.ODU, false,
846 nep, nepUuid, portName, nepName, withSip);
849 private void checkNodeRuleGroupForTpdrDSR(
850 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
851 assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
852 for (NodeRuleGroup nodeRuleGroup : nrgList) {
853 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
854 "each node-rule-group should contain 2 NEP for transponder DSR");
856 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
857 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
858 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
859 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
860 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
861 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
862 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
863 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
864 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
865 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
866 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
867 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
868 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
869 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
870 assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
871 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
872 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
873 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
874 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
875 "the rule type should be 'FORWARDING'");
878 private void checkNodeRuleGroupForMuxDSR(
879 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
880 assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
881 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
882 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
883 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(indNrg).nonnullNodeEdgePoint().values());
884 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
885 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
886 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
887 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
888 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
889 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
890 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
891 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
892 assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
893 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
894 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
895 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
896 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
897 "the rule type should be 'FORWARDING'");
900 private void checkNodeRuleGroupForSwitchDSR(
901 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
902 assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule group (DSR-I_ODU/I-ODU-E_ODU)");
903 Integer indNrg = nrgContainsClientAndNetwork(nrgList, clientNepUuid, networkNepUuid);
904 assertNotNull("One node-rule-group shall contains client and network Neps", indNrg);
905 assertEquals(8, nrgList.get(indNrg).getNodeEdgePoint().size(), "Switch-DSR nrg should contain 8 NEP");
906 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
907 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
908 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
909 .collect(Collectors.toList());
911 for (NodeEdgePoint nep : nrg) {
912 LOG.info("nep number {} UUID is {} ", xxxxx, nep.getNodeEdgePointUuid());
915 LOG.info("nep SPDR-SA1-XPDR2+iODU+XPDR2-NETWORK1 UUID is {} ",
916 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8"))));
917 LOG.info("nep SPDR-SA1-XPDR2+DSR+XPDR2-CLIENT4 UUID is {} ",
918 UUID.nameUUIDFromBytes(("SPDR-SA1-XPDR2" + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8"))));
919 assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
920 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
921 assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
922 "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
923 assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
924 "any item of the node-rule-group should have the same nodeUuid");
925 assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
926 "any item of the node-rule-group should have the same nodeUuid");
928 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
929 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
930 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
931 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
932 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
933 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
934 "the rule type should be 'FORWARDING'");
937 private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, List<Integer> nbNeps) {
938 assertEquals(3, nrgList.size(), "RDM infra node - OTS should contain 3 node rule groups");
940 for (NodeRuleGroup nrg : nrgList) {
941 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrg.getNodeEdgePoint().values());
942 assertEquals(nbNeps.get(index), nodeEdgePointList.size(),
943 "RDM infra node -rule-group should contain " + nbNeps.get(index) + " NEP");
944 List<Rule> ruleList = new ArrayList<>(nrg.nonnullRule().values());
945 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
946 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
947 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
948 "the rule type should be 'FORWARDING'");
949 if (nrg.getName().entrySet().iterator().next().getValue().toString().contains("DEG")) {
950 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
951 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
953 assertEquals(FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
954 "the forwarding rule should be 'CANNOTFORWARDACROSSGROUP'");
960 private void checkNodeRuleGroupForTpdrOTSi(
961 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
962 assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
963 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
964 assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
965 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
966 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
967 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
968 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
969 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
970 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
971 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
972 "any item of the node-rule-group should have the same nodeUuid");
973 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
974 "any item of the node-rule-group should have the same nodeUuid");
975 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
976 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
977 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
978 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
979 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
980 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
981 "the rule type should be 'FORWARDING'");
984 private void checkNodeRuleGroupForMuxOTSi(
985 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
986 assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
987 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
988 assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
989 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
990 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
991 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
992 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
993 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
994 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
995 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
996 "any item of the node-rule-group should have the same nodeUuid");
997 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
998 "any item of the node-rule-group should have the same nodeUuid");
999 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1000 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1001 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1002 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1003 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1004 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
1005 "the rule type should be 'FORWARDING'");
1008 private void checkNodeRuleGroupForSwitchOTSi(
1009 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
1010 assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1011 for (NodeRuleGroup nodeRuleGroup : nrgList) {
1012 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1013 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1015 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1016 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1017 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1018 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1019 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1020 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1021 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1022 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1023 assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1024 "any item of the node-rule-group should have the same nodeUuid");
1025 assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1026 "any item of the node-rule-group should have the same nodeUuid");
1027 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1028 assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1029 assertEquals("forward", ruleList0.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1030 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
1031 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1032 assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().stream().findFirst().orElseThrow(),
1033 "the rule type should be 'FORWARDING'");
1036 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1038 List.of(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
1039 nep, nepUuid, portName, nepName, false);
1042 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1044 List.of(DIGITALSIGNALTYPE100GigE.VALUE), LayerProtocolName.DSR, false,
1045 nep, nepUuid, portName, nepName, false);
1048 private void checkNepOtsiNode(
1049 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
1051 List.of(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE), LayerProtocolName.PHOTONICMEDIA,
1052 false, nep, nepUuid, portName, nepName, withSip);
1055 private void checkNepOtsiRdmNode(
1056 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
1057 if (!nep.getUuid().equals(nepUuid)) {
1058 LOG.info("ERRORUUIDNEP on Nep {}, expected {}", nep.getName(), portName);
1060 rawCheckNep(nepName.contains("OMS")
1061 ? List.of(PHOTONICLAYERQUALIFIEROMS.VALUE)
1062 : nepName.contains("OTS") ? List.of(PHOTONICLAYERQUALIFIEROTS.VALUE) : null,
1063 LayerProtocolName.PHOTONICMEDIA, false, nep, nepUuid, portName, nepName, withSip);
1066 private void rawCheckNep(List<LAYERPROTOCOLQUALIFIER> lpqList, LayerProtocolName lpn, boolean anyInList,
1067 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, boolean withSip) {
1068 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1069 Name name0 = nep.nonnullName().values().stream().findFirst().orElseThrow();
1070 assertEquals(portName, name0.getValue(), "Value of nep port should be '" + portName + "'");
1071 assertEquals(nepName, name0.getValueName(), "value-name of nep should be '" + nepName + "'");
1072 if (lpqList != null) {
1073 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
1074 .map(entry -> entry.getLayerProtocolQualifier())
1075 .collect(Collectors.toList());
1078 lpql.size() < lpqList.size(),
1079 //TODO lpqList.size() = 4 here -> check if this is the correct formula from an optical standpoint
1080 "eODU nep should support less than " + lpqList.size() + " kind of cep, depending on client port");
1082 lpqList.stream().anyMatch(splc -> lpql.contains(splc)),
1083 "eODU nep should support 1 kind of cep");
1085 assertEquals(lpqList.size(), lpql.size(), "nep should support " + lpqList.size() + " kind of cep(s)");
1086 for (LAYERPROTOCOLQUALIFIER lpq: lpqList) {
1087 assertThat("nep should support " + lpq + " cep", lpql, hasItem(lpq));
1089 assertEquals(lpn, nep.getLayerProtocolName(), "nep should be of " + lpn.toString() + " protocol type");
1092 // CommonPartOfNep(OwnedNodeEdgePoint nep, boolean withSip)
1093 assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(), "link port direction should be DIRECTIONAL");
1094 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1095 "administrative state should be UNLOCKED");
1096 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1097 // assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1098 // "termination state should be TERMINATED BIDIRECTIONAL");
1099 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(), "life-cycle state should be INSTALLED");
1101 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "Given nep should support 1 SIP");
1103 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1104 // assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1105 // "termination direction should be BIDIRECTIONAL");
1106 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1107 "operational state of client nep should be ENABLED");
1108 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(),
1109 "link-port-role of client nep should be SYMMETRIC");
1112 private void checkOmsLink(
1113 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1114 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1115 assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1116 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1119 private void checkXpdrRdmLink(
1120 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1121 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1122 assertEquals(linkName, link.getName().get(new NameKey("XPDR-RDM link name")).getValue(),
1123 "bad name for the link");
1124 linkNepsCheck(link, node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid);
1127 private void linkNepsCheck(
1128 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1129 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid) {
1130 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1132 LayerProtocolName.PHOTONICMEDIA.getName(),
1133 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1134 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1135 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1136 "otn tapi link should be BIDIRECTIONAL");
1137 var nodeEdgePointList = link.nonnullNodeEdgePoint().values().stream().collect(Collectors.toList());
1138 assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1139 var nep0 = nodeEdgePointList.get(0);
1140 var nep1 = nodeEdgePointList.get(1);
1141 assertEquals(topologyUuid, nep0.getTopologyUuid(),
1142 "topology uuid should be the same for the two termination point of the link");
1143 assertEquals(topologyUuid, nep1.getTopologyUuid(),
1144 "topology uuid should be the same for the two termination point of the link");
1145 String node1UuidVal = node1Uuid.getValue();
1146 String node2UuidVal = node2Uuid.getValue();
1147 assertThat("oms links should terminate on two distinct nodes",
1148 nep0.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1149 assertThat("oms links should terminate on two distinct nodes",
1150 nep1.getNodeUuid().getValue(), either(containsString(node1UuidVal)).or(containsString(node2UuidVal)));
1151 String tp1UuidVal = tp1Uuid.getValue();
1152 String tp2UuidVal = tp2Uuid.getValue();
1153 assertThat("oms links should terminate on two distinct tps",
1154 nep0.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1155 assertThat("oms links should terminate on two distinct tps",
1156 nep1.getNodeEdgePointUuid().getValue(), either(containsString(tp1UuidVal)).or(containsString(tp2UuidVal)));
1159 private Node changeTerminationPointState(
1160 Node initialNode, String tpid, String tpid1, AdminStates admin, State oper) {
1161 var tpdr1Bldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1162 .Node1Builder(initialNode.augmentation(Node1.class));
1163 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1164 TerminationPointBuilder tpBldr = new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid))));
1165 tpBldr.addAugmentation(
1166 new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1167 .setAdministrativeState(admin)
1168 .setOperationalState(oper)
1170 tps.replace(tpBldr.key(), tpBldr.build());
1171 TerminationPointBuilder tpBldr1 =
1172 new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid1))));
1173 tpBldr1.addAugmentation(
1174 new TerminationPoint1Builder(tpBldr1.augmentation(TerminationPoint1.class))
1175 .setAdministrativeState(admin)
1176 .setOperationalState(oper)
1178 tps.replace(tpBldr1.key(), tpBldr1.build());
1179 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.setTerminationPoint(tps).build()).build();
1182 private int getRank(String searchedChar, List<OwnedNodeEdgePoint> onepList) {
1184 searchedChar, onepList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1187 private int getNodeRank(String searchedChar,
1188 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1190 searchedChar, nodeList.stream().map(entry -> entry.getName().values()).collect(Collectors.toList()));
1193 private int rawRank(String searchedChar, List<Collection<Name>> nameCL) {
1194 int foundAtRank = 0;
1196 for (var nameC: nameCL) {
1197 for (Name name: nameC) {
1198 if (name.getValue().contains(searchedChar)) {
1200 //TODO should we really pursue once it is found ?
1205 LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
1209 private Integer nrgContainsClientAndNetwork(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid) {
1210 // 1 NRG should at least contain the NEP of interest in the NEP List
1211 Integer indexNrg = 0;
1212 for (NodeRuleGroup nrg : nrgList) {
1213 Boolean foundClient = false;
1214 Boolean foundNetwork = false;
1215 for (NodeEdgePoint nep : nrg.nonnullNodeEdgePoint().values()) {
1216 foundClient = foundClient || nep.getNodeEdgePointUuid().equals(clientNepUuid);
1217 foundNetwork = foundNetwork || nep.getNodeEdgePointUuid().equals(networkNepUuid);
1219 if (foundClient && foundNetwork) {