2 * Copyright © 2020 Orange, 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.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNull;
17 import static org.junit.jupiter.api.Assertions.assertTrue;
18 import static org.junit.jupiter.api.Assertions.fail;
20 import java.nio.charset.Charset;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.Iterator;
24 import java.util.List;
26 import java.util.UUID;
27 import java.util.concurrent.ExecutionException;
28 import java.util.stream.Collectors;
29 import org.eclipse.jdt.annotation.Nullable;
30 import org.junit.jupiter.api.BeforeAll;
31 import org.junit.jupiter.api.Test;
32 import org.opendaylight.mdsal.binding.api.DataBroker;
33 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
34 import org.opendaylight.transportpce.common.InstanceIdentifiers;
35 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
36 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
37 import org.opendaylight.transportpce.tapi.TapiStringConstants;
38 import org.opendaylight.transportpce.tapi.utils.TapiLink;
39 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
40 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
41 import org.opendaylight.transportpce.test.AbstractTest;
42 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1Builder;
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.OpenroadmTpType;
50 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
94 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
95 import org.opendaylight.yangtools.yang.common.Decimal64;
96 import org.opendaylight.yangtools.yang.common.Uint64;
97 import org.slf4j.Logger;
98 import org.slf4j.LoggerFactory;
101 public class ConvertORTopoToTapiTopoTest extends AbstractTest {
102 private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToTapiTopoTest.class);
104 private static Node otnMuxA;
105 private static Node otnMuxC;
106 private static Node otnSwitch;
107 private static Node tpdr100G;
108 private static Map<LinkKey,org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
109 .networks.network.Link> otnLinks;
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(
118 getDataStoreContextUtil(),
119 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE,
120 InstanceIdentifiers.OVERLAY_NETWORK_II);
121 TopologyDataUtils.writeTopologyFromFileToDatastore(
122 getDataStoreContextUtil(),
123 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE,
124 InstanceIdentifiers.OTN_NETWORK_II);
125 TopologyDataUtils.writePortmappingFromFileToDatastore(
126 getDataStoreContextUtil(),
127 TapiTopologyDataUtils.PORTMAPPING_FILE);
128 otnMuxA = dataBroker.newReadOnlyTransaction()
130 LogicalDatastoreType.CONFIGURATION,
132 InstanceIdentifier.create(Networks.class)
133 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
134 .networks.Network.class,
135 new NetworkKey(new NetworkId("otn-topology")))
136 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1"))))
137 .get().orElseThrow();
138 otnMuxC = dataBroker.newReadOnlyTransaction()
140 LogicalDatastoreType.CONFIGURATION,
142 InstanceIdentifier.create(Networks.class)
143 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
144 .networks.Network.class,
145 new NetworkKey(new NetworkId("otn-topology")))
146 .child(Node.class, new NodeKey(new NodeId("SPDR-SC1-XPDR1"))))
147 .get().orElseThrow();
148 otnSwitch = dataBroker.newReadOnlyTransaction()
150 LogicalDatastoreType.CONFIGURATION,
152 InstanceIdentifier.create(Networks.class)
153 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
154 .networks.Network.class,
155 new NetworkKey(new NetworkId("otn-topology")))
156 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2"))))
157 .get().orElseThrow();
158 tpdr100G = dataBroker.newReadOnlyTransaction()
160 LogicalDatastoreType.CONFIGURATION,
162 InstanceIdentifier.create(Networks.class)
163 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
164 .networks.Network.class,
165 new NetworkKey(new NetworkId("otn-topology")))
166 .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1"))))
167 .get().orElseThrow();
168 otnLinks = dataBroker.newReadOnlyTransaction()
170 LogicalDatastoreType.CONFIGURATION,
172 InstanceIdentifier.create(Networks.class)
173 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226
174 .networks.Network.class,
175 new NetworkKey(new NetworkId("otn-topology")))
176 .augmentation(Network1.class))
177 .get().orElseThrow().getLink();
178 topologyUuid = new Uuid(
179 UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8"))).toString());
180 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
181 tapiLink = new TapiLinkImpl(networkTransactionService);
182 LOG.info("TEST SETUP READY");
186 void convertNodeWhenNoStates() {
187 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", null, null);
188 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
189 tapiFactory.convertNode(tpdr,
190 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
191 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
192 .equals(OpenroadmTpType.XPONDERNETWORK))
193 .map(tp -> tp.getTpId().getValue())
194 .collect(Collectors.toList()));
195 OwnedNodeEdgePoint nepN = tapiFactory.getTapiNodes()
196 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
197 .topology.NodeKey(new Uuid(
198 UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString())))
199 .nonnullOwnedNodeEdgePoint()
200 .get(new OwnedNodeEdgePointKey(new Uuid(
201 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
203 assertNull(nepN.getAdministrativeState(), "Administrative State should not be present");
204 assertNull(nepN.getOperationalState(), "Operational State should not be present");
209 void convertNodeWhenBadStates1() {
211 changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.OutOfService, State.OutOfService);
212 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
213 tapiFactory.convertNode(tpdr,
214 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
215 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
216 .equals(OpenroadmTpType.XPONDERNETWORK))
217 .map(tp -> tp.getTpId().getValue())
218 .collect(Collectors.toList()));
219 OwnedNodeEdgePoint nepN = tapiFactory.getTapiNodes()
220 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
221 .topology.NodeKey(new Uuid(
222 UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString())))
223 .nonnullOwnedNodeEdgePoint()
224 .get(new OwnedNodeEdgePointKey(new Uuid(
225 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
227 assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
228 "Administrative State should be Locked");
229 assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
233 void convertNodeWhenBadStates2() {
234 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", AdminStates.Maintenance, State.Degraded);
235 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
236 tapiFactory.convertNode(tpdr,
237 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
238 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
239 .equals(OpenroadmTpType.XPONDERNETWORK))
240 .map(tp -> tp.getTpId().getValue())
241 .collect(Collectors.toList()));
242 OwnedNodeEdgePoint nepN = tapiFactory.getTapiNodes()
243 .get(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
244 .topology.NodeKey(new Uuid(
245 UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString())))
246 .nonnullOwnedNodeEdgePoint()
247 .get(new OwnedNodeEdgePointKey(new Uuid(
248 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
250 assertEquals(AdministrativeState.LOCKED, nepN.getAdministrativeState(),
251 "Administrative State should be Locked");
252 assertEquals(OperationalState.DISABLED, nepN.getOperationalState(), "Operational State should be Disabled");
256 void convertOtnLinkWhenNoState() {
258 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
259 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
260 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
261 .networks.network.Link link =
262 changeOtnLinkState(otnLinks.get(new LinkKey(
263 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))), null, null);
264 otnLinksAlt.replace(link.key(), link);
265 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
266 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
267 tapiFactory.convertNode(otnMuxA,
268 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
269 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
270 .equals(OpenroadmTpType.XPONDERNETWORK))
271 .map(tp -> tp.getTpId().getValue())
272 .collect(Collectors.toList()));
273 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
274 tapiFactory.convertNode(otnMuxC,
275 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
276 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
277 .equals(OpenroadmTpType.XPONDERNETWORK))
278 .map(tp -> tp.getTpId().getValue())
279 .collect(Collectors.toList()));
280 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
281 tapiAbsFactory.convertLinks(otnLinksAlt);
283 List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
284 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
285 .collect(Collectors.toList());
286 assertNull(tapiLinks.get(1).getAdministrativeState(), "Administrative State should not be present");
287 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
288 "Administrative state should be UNLOCKED");
289 assertNull(tapiLinks.get(1).getOperationalState(), "Operational State should not be present");
290 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
291 "Operational state should be ENABLED");
295 void convertOtnLinkWhenNoStateOnOppositeLink() {
297 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
298 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
299 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
300 .networks.network.Link link =
301 changeOtnLinkState(otnLinks.get(new LinkKey(
302 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))), null, null);
303 otnLinksAlt.replace(link.key(), link);
304 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
305 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
306 tapiFactory.convertNode(otnMuxA,
307 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
308 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
309 .equals(OpenroadmTpType.XPONDERNETWORK))
310 .map(tp -> tp.getTpId().getValue())
311 .collect(Collectors.toList()));
312 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
313 tapiFactory.convertNode(otnMuxC,
314 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
315 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
316 .equals(OpenroadmTpType.XPONDERNETWORK))
317 .map(tp -> tp.getTpId().getValue())
318 .collect(Collectors.toList()));
319 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
320 tapiAbsFactory.convertLinks(otnLinksAlt);
322 List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
323 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
324 .collect(Collectors.toList());
325 assertNull(tapiLinks.get(1).getAdministrativeState(), "Administrative State should not be present");
326 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
327 "Administrative state should be UNLOCKED");
328 assertNull(tapiLinks.get(1).getOperationalState(), "Operational State should not be present");
329 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
330 "Operational state should be ENABLED");
334 void convertOtnLinkWhenBadState1() {
336 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
337 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
338 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
339 .networks.network.Link link =
340 changeOtnLinkState(otnLinks.get(new LinkKey(
341 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
342 AdminStates.OutOfService, State.OutOfService);
343 otnLinksAlt.replace(link.key(), link);
344 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
345 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
346 tapiFactory.convertNode(otnMuxA,
347 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
348 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
349 .equals(OpenroadmTpType.XPONDERNETWORK))
350 .map(tp -> tp.getTpId().getValue())
351 .collect(Collectors.toList()));
352 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
353 tapiFactory.convertNode(otnMuxC,
354 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
355 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
356 .equals(OpenroadmTpType.XPONDERNETWORK))
357 .map(tp -> tp.getTpId().getValue())
358 .collect(Collectors.toList()));
359 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
360 tapiAbsFactory.convertLinks(otnLinksAlt);
361 List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
362 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
363 .collect(Collectors.toList());
364 LOG.info("TapiLinks are as follow : {}", tapiLinks);
365 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
366 "Administrative state should be LOCKED");
367 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
368 "Administrative state should be UNLOCKED");
369 assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
370 "Operational state should be DISABLED");
371 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
372 "Operational state should be ENABLED");
376 void convertOtnLinkWhenBadState2() {
378 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
379 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
380 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
381 .networks.network.Link link =
382 changeOtnLinkState(otnLinks.get(new LinkKey(
383 new LinkId("ODTU4-SPDR-SA1-XPDR1-XPDR1-NETWORK1toSPDR-SC1-XPDR1-XPDR1-NETWORK1"))),
384 AdminStates.Maintenance, State.Degraded);
385 otnLinksAlt.replace(link.key(), link);
386 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
387 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
388 tapiFactory.convertNode(otnMuxA,
389 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
390 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
391 .equals(OpenroadmTpType.XPONDERNETWORK))
392 .map(tp -> tp.getTpId().getValue())
393 .collect(Collectors.toList()));
394 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
395 tapiFactory.convertNode(otnMuxC,
396 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
397 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
398 .equals(OpenroadmTpType.XPONDERNETWORK))
399 .map(tp -> tp.getTpId().getValue())
400 .collect(Collectors.toList()));
401 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
402 tapiAbsFactory.convertLinks(otnLinksAlt);
403 List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
404 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
405 .collect(Collectors.toList());
406 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
407 "Administrative state should be LOCKED");
408 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
409 "Administrative state should be UNLOCKED");
410 assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
411 "Operational state should be DISABLED");
412 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
413 "Operational state should be ENABLED");
417 void convertOtnLinkWhenBadStateOnOppositeLink() {
419 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
420 .networks.network.Link> otnLinksAlt = new HashMap<>(otnLinks);
421 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
422 .networks.network.Link link =
423 changeOtnLinkState(otnLinks.get(new LinkKey(
424 new LinkId("ODTU4-SPDR-SC1-XPDR1-XPDR1-NETWORK1toSPDR-SA1-XPDR1-XPDR1-NETWORK1"))),
425 AdminStates.OutOfService, State.OutOfService);
426 otnLinksAlt.replace(link.key(), link);
427 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
428 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
429 tapiFactory.convertNode(otnMuxA,
430 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
431 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
432 .equals(OpenroadmTpType.XPONDERNETWORK))
433 .map(tp -> tp.getTpId().getValue())
434 .collect(Collectors.toList()));
435 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
436 tapiFactory.convertNode(otnMuxC,
437 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
438 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
439 .equals(OpenroadmTpType.XPONDERNETWORK))
440 .map(tp -> tp.getTpId().getValue())
441 .collect(Collectors.toList()));
442 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
443 tapiAbsFactory.convertLinks(otnLinksAlt);
445 List<Link> tapiLinks = tapiAbsFactory.getTapiLinks().values().stream()
446 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
447 .collect(Collectors.toList());
448 assertEquals(AdministrativeState.LOCKED, tapiLinks.get(1).getAdministrativeState(),
449 "Administrative state should be LOCKED");
450 assertEquals(AdministrativeState.UNLOCKED, tapiLinks.get(0).getAdministrativeState(),
451 "Administrative state should be UNLOCKED");
452 assertEquals(OperationalState.DISABLED, tapiLinks.get(1).getOperationalState(),
453 "Operational state should be DISABLED");
454 assertEquals(OperationalState.ENABLED, tapiLinks.get(0).getOperationalState(),
455 "Operational state should be ENABLED");
459 void convertNodeForTransponder100G() {
460 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
461 tapiFactory.convertNode(tpdr100G,
462 tpdr100G.augmentation(Node1.class).getTerminationPoint().values().stream()
463 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
464 .equals(OpenroadmTpType.XPONDERNETWORK))
465 .map(tp -> tp.getTpId().getValue())
466 .collect(Collectors.toList()));
467 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
468 tapiFactory.getTapiNodes().values().stream()
469 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
470 .collect(Collectors.toList());
472 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
473 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 (no more transitional links)");
475 checkDsrNode(getNode("SPDR-SA1", tapiNodes),
476 new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString()),
477 "tpdr", "XPDR-A1-XPDR1+XPONDER");
481 void convertNodeForOtnMuxponder() {
482 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
483 tapiFactory.convertNode(otnMuxA,
484 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
485 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
486 .equals(OpenroadmTpType.XPONDERNETWORK))
487 .map(tp -> tp.getTpId().getValue())
488 .collect(Collectors.toList()));
489 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
490 tapiFactory.getTapiNodes().values().stream()
491 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
492 .collect(Collectors.toList());
494 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR & ODU merged");
495 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0, no more transitional links");
496 checkDsrNode(getNode("SPDR-SA1", tapiNodes),
497 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString()),
498 "mux", "SPDR-SA1-XPDR1+XPONDER");
502 void convertNodeForOtnSwitch() {
503 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
504 tapiFactory.convertNode(otnSwitch,
505 otnSwitch.augmentation(Node1.class).getTerminationPoint().values().stream()
506 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
507 .equals(OpenroadmTpType.XPONDERNETWORK))
508 .map(tp -> tp.getTpId().getValue())
509 .collect(Collectors.toList()));
510 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
511 tapiFactory.getTapiNodes().values().stream()
512 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
513 .collect(Collectors.toList());
514 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR/ODU merged)");
515 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
516 checkDsrNode(getNode("SPDR-SA1", tapiNodes),
517 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8"))).toString()),
518 "switch", "SPDR-SA1-XPDR2+XPONDER");
522 void convertOtnLink() {
523 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
524 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
525 tapiFactory.convertNode(otnMuxA,
526 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
527 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
528 .equals(OpenroadmTpType.XPONDERNETWORK))
529 .map(tp -> tp.getTpId().getValue())
530 .collect(Collectors.toList()));
531 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
532 tapiFactory.convertNode(otnMuxC,
533 otnMuxC.augmentation(Node1.class).getTerminationPoint().values().stream()
534 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
535 .equals(OpenroadmTpType.XPONDERNETWORK))
536 .map(tp -> tp.getTpId().getValue())
537 .collect(Collectors.toList()));
538 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
540 tapiAbsFactory.convertLinks(otnLinks);
541 assertEquals(2, tapiAbsFactory.getTapiLinks().size(), "Link list size should be 2 : no transitional link");
543 Uuid node1Uuid = new Uuid(
544 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
545 Uuid node2Uuid = new Uuid(
546 UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
547 Uuid node3Uuid = new Uuid(
548 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
549 Uuid node4Uuid = new Uuid(
550 UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString());
551 Uuid tp1Uuid = new Uuid(
552 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
553 Uuid tp2Uuid = new Uuid(
554 UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8"))).toString());
555 Uuid tp3Uuid = new Uuid(
556 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
558 Uuid tp4Uuid = new Uuid(
559 UUID.nameUUIDFromBytes("SPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
561 Uuid link1Uuid = new Uuid(
562 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1"
563 .getBytes(Charset.forName("UTF-8")))
565 Uuid link2Uuid = new Uuid(
566 UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1"
567 .getBytes(Charset.forName("UTF-8")))
569 List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
570 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
571 .collect(Collectors.toList());
572 LOG.info("Node3 {}, Node4 = {},", node3Uuid, node4Uuid);
573 checkOtnLink(links.get(1), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, link1Uuid,
574 "SPDR-SA1-XPDR1+eODU+XPDR1-NETWORK1toSPDR-SC1-XPDR1+eODU+XPDR1-NETWORK1");
575 checkOtnLink(links.get(0), node3Uuid, node4Uuid, tp3Uuid, tp4Uuid, link2Uuid,
576 "SPDR-SA1-XPDR1+iOTSi+XPDR1-NETWORK1toSPDR-SC1-XPDR1+iOTSi+XPDR1-NETWORK1");
577 LOG.info("The link we check has name {}", links.get(0).getName());
581 void convertRoadmInfrastructureWhenNoXponderAttached() {
582 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
583 tapiAbsFactory.convertRoadmInfrastructure();
585 assertEquals(1, tapiAbsFactory.getTapiNodes().size(), "Node list size should be 1");
586 assertEquals(0, tapiAbsFactory.getTapiLinks().size(), "Link list size should be empty");
587 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
588 tapiAbsFactory.getTapiNodes().values().stream().collect(Collectors.toList());
589 Uuid photNodeUuid = new Uuid(
590 UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString());
591 checkOtsiNode(tapiNodes.get(0), photNodeUuid, "infra", "ROADM-infra");
595 void convertRoadmInfrastructureWhenOtnMuxAttached() {
596 ConvertORTopoToTapiTopo tapiAbsFactory = new ConvertORTopoToTapiTopo(topologyUuid, tapiLink);
597 ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topologyUuid);
598 tapiFactory.convertNode(otnMuxA,
599 otnMuxA.augmentation(Node1.class).getTerminationPoint().values().stream()
600 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType()
601 .equals(OpenroadmTpType.XPONDERNETWORK))
602 .map(tp -> tp.getTpId().getValue())
603 .collect(Collectors.toList()));
604 tapiAbsFactory.setTapiNodes(tapiFactory.getTapiNodes());
605 tapiAbsFactory.convertRoadmInfrastructure();
606 LOG.info("ERRORLINK List of link = {}", tapiAbsFactory.getTapiLinks());
607 assertEquals(2, tapiAbsFactory.getTapiNodes().size(), "Node list size should be 2");
608 assertEquals(1, tapiAbsFactory.getTapiLinks().size(), "Link list size should be 1");
610 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey,
611 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeMap =
612 tapiFactory.getTapiNodes();
613 nodeMap.putAll(tapiAbsFactory.getTapiNodes());
614 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes =
615 nodeMap.values().stream()
616 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
617 .collect(Collectors.toList());
619 getNode("ROADM", tapiNodes),
621 new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString()),
622 "infra", "ROADM-infra");
623 List<Link> links = tapiAbsFactory.getTapiLinks().values().stream()
624 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
625 .collect(Collectors.toList());
627 "SPDR-SA1-XPDR1+XPONDER--SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1 and ROADM-infra--NodeEdgePoint_1";
628 LOG.info("LinksCheck 0 = {} ", links.get(0).getName());
629 checkOmsLink(links.get(0),
631 new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8"))).toString()),
633 new Uuid(UUID.nameUUIDFromBytes("ROADM-infra".getBytes(Charset.forName("UTF-8"))).toString()),
636 UUID.nameUUIDFromBytes(
637 "SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1".getBytes(Charset.forName("UTF-8")))
640 new Uuid(UUID.nameUUIDFromBytes(("roadm node+nep+1").getBytes(Charset.forName("UTF-8"))).toString()),
642 new Uuid(UUID.nameUUIDFromBytes(str1.getBytes(Charset.forName("UTF-8"))).toString()),
646 private void checkDsrNode(
647 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
648 Uuid nodeUuid, String dsrNodeType, String nodeId) {
649 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
650 assertEquals(nodeId, node.getName().get(new NameKey("dsr/odu node name")).getValue(), "incorrect node name");
651 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
652 "administrative state should be UNLOCKED");
653 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
654 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
655 assertThat("one value-name should be 'dsr/odu node name'",
656 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
657 assertEquals(4, node.getLayerProtocolName().size(),
658 "dsr node should manage 4 protocol layers : dsr, odu, DIGITALOTN and photonic");
659 assertThat("dsr node should manage 3 protocol layers : dsr, odu and photonic",
660 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU,
661 LayerProtocolName.PHOTONICMEDIA));
662 List<OwnedNodeEdgePoint> nepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
663 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
664 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
665 .collect(Collectors.toList());
666 List<OwnedNodeEdgePoint> nepsC;
667 switch (dsrNodeType) {
669 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
670 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
671 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
672 .collect(Collectors.toList());
673 assertEquals(4, nepsN.size(), "Switch-DSR node should have 4 NEPs network");
674 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
675 OwnedNodeEdgePoint nep1 = nepsC.get(2);
676 Uuid client4NepUuid = new Uuid(
677 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR2-CLIENT4")
678 .getBytes(Charset.forName("UTF-8"))).toString());
679 checkNepClient100GSwitch(nep1, client4NepUuid, "XPDR2-CLIENT4", "NodeEdgePoint_C",
680 otnSwitch.getNodeId().getValue(), TapiStringConstants.DSR);
681 OwnedNodeEdgePoint nep2 = nepsN.get(3);
682 Uuid networkNepUuid = new Uuid(
683 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR2-NETWORK1")
684 .getBytes(Charset.forName("UTF-8"))).toString());
685 checkNepNetworkODU4(nep2, networkNepUuid, "XPDR2-NETWORK1", "iNodeEdgePoint_N",
686 otnSwitch.getNodeId().getValue(), TapiStringConstants.I_ODU);
687 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
688 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
689 .collect(Collectors.toList());
690 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, networkNepUuid, nodeUuid);
693 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
694 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
695 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
696 .collect(Collectors.toList());
697 assertEquals(1, nepsN.size(), "Mux-DSR node should have 1 NEP network");
698 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
699 OwnedNodeEdgePoint nep3 = nepsC.get(2);
700 Uuid client3NepUuid = new Uuid(
701 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT3")
702 .getBytes(Charset.forName("UTF-8"))).toString());
703 checkNepClient10G(nep3, client3NepUuid, "XPDR1-CLIENT3", "NodeEdgePoint_C",
704 otnMuxA.getNodeId().getValue(), TapiStringConstants.DSR);
706 OwnedNodeEdgePoint nep4 = nepsN.get(0);
707 Uuid networkNepUuid2 = new Uuid(
708 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
709 .getBytes(Charset.forName("UTF-8"))).toString());
710 checkNepNetworkODU4(nep4, networkNepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
711 otnMuxA.getNodeId().getValue(), TapiStringConstants.I_ODU);
712 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
713 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
714 .collect(Collectors.toList());
715 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, networkNepUuid2, nodeUuid);
718 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
719 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
720 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
721 .collect(Collectors.toList());
722 assertEquals(2, nepsN.size(), "Tpdr-DSR node should have 2 NEPs network");
723 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
724 OwnedNodeEdgePoint nep5 = nepsC.get(0);
725 Uuid client1NepUuid = new Uuid(
726 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+DSR+XPDR1-CLIENT1")
727 .getBytes(Charset.forName("UTF-8"))).toString());
728 checkNepClient100GTpdr(nep5, client1NepUuid, "XPDR1-CLIENT1", "100G-tpdr",
729 tpdr100G.getNodeId().getValue(), TapiStringConstants.DSR);
731 OwnedNodeEdgePoint nep6 = nepsN.get(1);
732 Uuid networkNepUuid3 = new Uuid(
733 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iODU+XPDR1-NETWORK1")
734 .getBytes(Charset.forName("UTF-8"))).toString());
735 checkNepNetworkODU4(nep6, networkNepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint_N",
736 tpdr100G.getNodeId().getValue(), TapiStringConstants.I_ODU);
737 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
738 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
739 .collect(Collectors.toList());
740 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, networkNepUuid3, nodeUuid);
748 private void checkOtsiNode(
749 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
750 Uuid nodeUuid, String otsiNodeType, String nodeId) {
751 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
752 assertEquals(nodeId, node.getName().get(new NameKey("otsi node name")).getValue(), "incorrect node name");
753 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
754 "administrative state should be UNLOCKED");
755 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
756 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
757 assertThat("one value-name should be 'dsr/odu node name'",
758 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("otsi node name")));
759 assertEquals(1, node.getLayerProtocolName().size(),
760 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
761 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
762 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
763 List<OwnedNodeEdgePoint> nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
764 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
765 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
766 .collect(Collectors.toList());
767 List<OwnedNodeEdgePoint> nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
768 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
769 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
770 .collect(Collectors.toList());
771 switch (otsiNodeType) {
773 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
774 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
775 OwnedNodeEdgePoint nep1 = nepsI.get(1);
776 Uuid inepUuid = new Uuid(
777 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR2-NETWORK2")
778 .getBytes(Charset.forName("UTF-8"))).toString());
779 checkNepOtsiNode(nep1, inepUuid, "XPDR2-NETWORK2", "iNodeEdgePoint",
780 otnSwitch.getNodeId().getValue(), TapiStringConstants.I_OTSI);
781 OwnedNodeEdgePoint nep2 = nepsE.get(0);
782 Uuid enepUuid = new Uuid(
783 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
784 .getBytes(Charset.forName("UTF-8"))).toString());
785 checkNepOtsiNode(nep2, enepUuid, "XPDR2-NETWORK2", "eNodeEdgePoint",
786 otnSwitch.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
787 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
788 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
789 .collect(Collectors.toList());
790 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
793 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
794 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
795 OwnedNodeEdgePoint nep3 = nepsE.get(0);
796 Uuid enepUuid2 = new Uuid(
797 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
798 .getBytes(Charset.forName("UTF-8"))).toString());
799 checkNepOtsiNode(nep3, enepUuid2, "XPDR1-NETWORK1", "eNodeEdgePoint",
800 otnMuxA.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
801 OwnedNodeEdgePoint nep4 = nepsI.get(0);
802 Uuid inepUuid2 = new Uuid(
803 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
804 .getBytes(Charset.forName("UTF-8"))).toString());
805 checkNepOtsiNode(nep4, inepUuid2, "XPDR1-NETWORK1", "iNodeEdgePoint",
806 otnMuxA.getNodeId().getValue(), TapiStringConstants.I_OTSI);
807 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
808 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
809 .collect(Collectors.toList());
810 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
813 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
814 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
815 OwnedNodeEdgePoint nep5 = nepsE.get(0);
816 Uuid enepUuid3 = new Uuid(
817 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
818 .getBytes(Charset.forName("UTF-8"))).toString());
819 checkNepOtsiNode(nep5, enepUuid3, "XPDR1-NETWORK1", "eNodeEdgePoint",
820 tpdr100G.getNodeId().getValue(), TapiStringConstants.PHTNC_MEDIA_OTS);
821 OwnedNodeEdgePoint nep6 = nepsI.get(0);
822 Uuid inepUuid3 = new Uuid(
823 UUID.nameUUIDFromBytes((nodeId.split("\\+")[0] + "+iOTSi+XPDR1-NETWORK1")
824 .getBytes(Charset.forName("UTF-8"))).toString());
825 checkNepOtsiNode(nep6, inepUuid3, "XPDR1-NETWORK1", "iNodeEdgePoint",
826 tpdr100G.getNodeId().getValue(), TapiStringConstants.I_OTSI);
827 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
828 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
829 .collect(Collectors.toList());
830 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
833 Iterator<OwnedNodeEdgePoint> nepIterator = node.nonnullOwnedNodeEdgePoint().values().iterator();
835 while (nepIterator.hasNext()) {
836 OwnedNodeEdgePoint nep = nepIterator.next();
837 Uuid nepUuid = new Uuid(
838 UUID.nameUUIDFromBytes((String.join("+", "roadm node", "nep", String.valueOf(count)))
839 .getBytes(Charset.forName("UTF-8"))).toString());
840 checkNepOtsiRdmNode(nep, nepUuid, new StringBuilder("NodeEdgePoint_").append(count).toString(),
841 "NodeEdgePoint name");
844 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
845 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
846 .collect(Collectors.toList());
847 checkNodeRuleGroupForRdmInfra(nrgList4, count - 1);
852 private void checkNepClient10G(
853 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
854 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
855 Name name = new ArrayList<>(nep.nonnullName().values()).get(0);
857 String.join("+", nodeId, extension, portName),
859 "value of client nep should be '" + portName + "'");
860 assertEquals(nepName, name.getValueName(),
861 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
862 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
863 .map(lpqi -> lpqi.getLayerProtocolQualifier())
864 .collect(Collectors.toList());
865 assertEquals(3, lpql.size(), "Client nep should support 3 kind of cep");
866 assertThat("client nep should support 3 kind of cep", lpql,
867 hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
868 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol ");
869 checkCommonPartOfNep(nep, false);
870 checkSIP(nep, portName, nodeId, extension);
873 private void checkNepNetworkODU4(
874 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
875 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
876 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
877 Name name = nameList.get(0);
878 assertEquals(String.join("+", nodeId, extension, portName), name.getValue(),
879 "value of network nep should be '" + portName + "'");
880 assertEquals(nepName, name.getValueName(),
881 "value-name of network nep for '" + portName + "' should be '" + nepName + "'");
882 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
883 .map(lpqi -> lpqi.getLayerProtocolQualifier())
884 .collect(Collectors.toList());
885 assertEquals(1, lpql.size(), "Network nep should support 1 kind of cep");
886 assertThat("network nep should support 1 kind of cep", lpql, hasItem(ODUTYPEODU4.VALUE));
887 assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "network nep should be of ODU protocol type");
888 checkCommonPartOfNep(nep, false);
889 checkSIP(nep, portName, nodeId, extension);
892 private void checkNodeRuleGroupForTpdrDSR(
893 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
894 assertEquals(4, nrgList.size(), "transponder DSR should contain 4 node rule group (2*DSR/I_ODU+2*E_ODU/I_ODU)");
895 for (NodeRuleGroup nodeRuleGroup : nrgList) {
896 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
897 "each node-rule-group should contain 2 NEP for transponder DSR");
899 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
900 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
901 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
902 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
903 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
904 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
905 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
906 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
907 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
908 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
909 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
910 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
911 assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
912 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
913 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
914 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
915 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().iterator().next(),
916 "the rule type should be 'FORWARDING'");
919 private void checkNodeRuleGroupForMuxDSR(
920 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
921 assertEquals(8, nrgList.size(), "muxponder DSR should contain 8 node rule group (4*DSR/I_ODU + 4*E_ODU/I_ODU)");
922 for (NodeRuleGroup nodeRuleGroup : nrgList) {
923 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
924 "each node-rule-group should contain 2 NEP for muxponder DSR");
926 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
927 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
928 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
929 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
930 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
931 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
932 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
933 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
934 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
935 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
936 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
937 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
938 assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
939 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
940 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
941 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
942 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().iterator().next(),
943 "the rule type should be 'FORWARDING'");
946 private void checkNodeRuleGroupForSwitchDSR(
947 List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid, Uuid nodeUuid) {
948 assertEquals(2, nrgList.size(), "Switch-DSR should contain 2 node rule groups (DSR/I_ODU + E_ODU/I_ODU)");
949 assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
950 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
951 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
952 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
953 .collect(Collectors.toList());
954 assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
955 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
956 assertEquals(clientNepUuid, nrg.get(5).getNodeEdgePointUuid(),
957 "in the sorted node-rule-group, nep number 6 should be XPDR2-CLIENT4");
958 assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
959 "any item of the node-rule-group should have the same nodeUuid");
960 assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
961 "any item of the node-rule-group should have the same nodeUuid");
963 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
964 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
965 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
966 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
967 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
968 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
969 "the rule type should be 'FORWARDING'");
972 private void checkNodeRuleGroupForRdmInfra(List<NodeRuleGroup> nrgList, int nbNeps) {
973 // if no XPDR is connected, no OTS is created and no NodeRuleGroup is created
974 assertTrue(nrgList.size() <= 1, "RDM infra node - OTSi should contain maximum one node rule groups");
975 // When a nrg is present it shall respect the following
976 if (nrgList.isEmpty()) {
980 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
981 assertEquals(nbNeps, nodeEdgePointList.size(),
982 "RDM infra node -rule-group should contain " + nbNeps + " NEP");
984 assertNull(nrgList.get(0).getNodeEdgePoint(), "RDM infra node -rule-group should contain no NEP");
986 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
987 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
988 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
989 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
990 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
991 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
992 "the rule type should be 'FORWARDING'");
995 private void checkNodeRuleGroupForTpdrOTSi(
996 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
997 assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
998 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
999 assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
1000 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1001 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1002 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1003 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1004 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1005 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1006 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1007 "any item of the node-rule-group should have the same nodeUuid");
1008 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1009 "any item of the node-rule-group should have the same nodeUuid");
1010 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1011 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1012 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1013 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1014 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1015 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
1016 "the rule type should be 'FORWARDING'");
1019 private void checkNodeRuleGroupForMuxOTSi(
1020 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
1021 assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
1022 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1023 assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
1024 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1025 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1026 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1027 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1028 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1029 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1030 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1031 "any item of the node-rule-group should have the same nodeUuid");
1032 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1033 "any item of the node-rule-group should have the same nodeUuid");
1034 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1035 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1036 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1037 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1038 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1039 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().iterator().next(),
1040 "the rule type should be 'FORWARDING'");
1043 private void checkNodeRuleGroupForSwitchOTSi(
1044 List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid, Uuid nodeUuid) {
1045 assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1046 for (NodeRuleGroup nodeRuleGroup : nrgList) {
1047 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1048 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1050 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1051 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1052 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1053 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1054 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1055 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1056 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1057 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1058 assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1059 "any item of the node-rule-group should have the same nodeUuid");
1060 assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1061 "any item of the node-rule-group should have the same nodeUuid");
1062 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1063 assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1064 assertEquals("forward", ruleList0.get(0).getLocalId(),"local-id of the rule should be 'forward'");
1065 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
1066 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1067 assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().iterator().next(),
1068 "the rule type should be 'FORWARDING'");
1071 private void checkNepClient100GSwitch(
1072 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
1073 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1074 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1075 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1076 "value of client nep should be '" + portName + "'");
1077 assertEquals(nepName, nameList.get(0).getValueName(),
1078 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
1079 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
1080 .map(lpqi -> lpqi.getLayerProtocolQualifier())
1081 .collect(Collectors.toList());
1082 assertEquals(2, lpql.size(), "Client nep should support 2 kind of cep");
1083 assertThat("client nep should support 2 kind of cep", lpql,
1084 hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
1085 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol");
1086 checkCommonPartOfNep(nep, false);
1087 checkSIP(nep, portName, nodeId, extension);
1090 private void checkNepClient100GTpdr(
1091 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
1092 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1093 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1094 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1095 "value of client nep should be '" + portName + "'");
1096 assertEquals(nepName, nameList.get(0).getValueName(),
1097 "value-name of client nep for '" + portName + "' should be 100G-tpdr'");
1098 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
1099 .map(lpqi -> lpqi.getLayerProtocolQualifier())
1100 .collect(Collectors.toList());
1101 assertEquals(1, lpql.size(), "Client nep should support 1 kind of cep");
1102 assertThat("client nep should support 2 kind of cep", lpql, hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
1103 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR(ETH) protocol");
1104 checkCommonPartOfNep(nep, false);
1105 checkSIP(nep, portName, nodeId, extension);
1108 private void checkNepOtsiNode(
1109 OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName, String nodeId, String extension) {
1110 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1111 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1112 assertEquals(String.join("+", nodeId, extension, portName), nameList.get(0).getValue(),
1113 "value of OTSi nep should be '" + portName + "'");
1114 assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1115 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
1116 .map(lpqi -> lpqi.getLayerProtocolQualifier())
1117 .collect(Collectors.toList());
1118 assertEquals(2, lpql.size(), "OTSi nep should support 2 kind of cep");
1119 assertThat("OTSi nep should support 2 kind of cep", lpql,
1120 hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
1121 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1122 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1123 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "OTSi nep should support one SIP");
1124 checkCommonPartOfNep(nep, false);
1125 checkSIP(nep, portName, nodeId, extension);
1128 private void checkSIP(OwnedNodeEdgePoint nep, String portName, String nodeId, String extension) {
1129 Uuid sipUuid = new Uuid(
1130 UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeId, extension, portName))
1131 .getBytes(Charset.forName("UTF-8")))
1135 nep.getMappedServiceInterfacePoint().get(new MappedServiceInterfacePointKey(sipUuid))
1136 .getServiceInterfacePointUuid(),
1137 "service-interface-point-uuid of network nep for '" + portName + "' should be '"
1138 + String.join("+", "SIP", portName) + "'");
1141 private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1142 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1143 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1144 assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
1145 assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1146 List<LAYERPROTOCOLQUALIFIER> lpql = nep.getSupportedCepLayerProtocolQualifierInstances().stream()
1147 .map(lpqi -> lpqi.getLayerProtocolQualifier())
1148 .collect(Collectors.toList());
1149 assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep");
1150 assertThat("OTSi nep should support OTS cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROTS.VALUE));
1151 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1152 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1153 assertEquals(0, nep.nonnullMappedServiceInterfacePoint().size(), "OTSi nep of RDM infra should support no SIP");
1154 checkCommonPartOfNep(nep, true);
1157 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean isRdm) {
1158 assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(),
1159 "link port direction should be DIRECTIONAL");
1160 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1161 "administrative state should be UNLOCKED");
1162 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1163 // assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1164 // "termination state should be TERMINATED BIDIRECTIONAL");
1165 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(),
1166 "life-cycle state should be INSTALLED");
1168 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "client nep should support 1 SIP");
1170 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1171 // assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1172 // "termination direction should be BIDIRECTIONAL");
1173 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1174 "operational state of client nep should be ENABLED");
1175 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(), "link-port-role of client nep should be SYMMETRIC");
1178 private void checkOtnLink(
1179 Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1180 assertEquals(linkName, link.getName().get(new NameKey("otn link name")).getValue(), "bad name for the link");
1181 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1182 assertEquals(CAPACITYUNITGBPS.VALUE, link.getAvailableCapacity().getTotalSize().getUnit(),
1183 "Available capacity unit should be MBPS");
1184 String prefix = linkName.split("-")[0];
1185 if ("OTU4".equals(prefix)) {
1186 assertEquals(Uint64.valueOf(0), link.getAvailableCapacity().getTotalSize().getValue(),
1187 "Available capacity -total size value should be 0");
1188 } else if ("ODTU4".equals(prefix)) {
1189 assertEquals(Uint64.valueOf(100000), link.getAvailableCapacity().getTotalSize().getValue(),
1190 "Available capacity -total size value should be 100 000");
1192 assertEquals(CAPACITYUNITGBPS.VALUE, link.getTotalPotentialCapacity().getTotalSize().getUnit(),
1193 "Total capacity unit should be GBPS");
1194 assertEquals(Decimal64.valueOf("100"), link.getTotalPotentialCapacity().getTotalSize().getValue(),
1195 "Total capacity -total size value should be 100");
1196 if ("OTU4".equals(prefix)) {
1198 LayerProtocolName.PHOTONICMEDIA.getName(),
1199 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1200 "otn link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1201 } else if ("ODTU4".equals(prefix)) {
1203 LayerProtocolName.ODU.getName(),
1204 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1205 "otn link should be between 2 nodes of protocol layers ODU");
1207 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1208 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1209 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1210 LOG.info("OUTPUT: Node1UUID = {}, Node2UU2D = {},", node1Uuid, node2Uuid);
1211 LOG.info("NEPLIST = {}", nodeEdgePointList);
1212 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1213 "topology uuid should be the same for the two termination point of the link");
1214 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1215 "topology uuid should be the same for the two termination point of the link");
1216 assertThat("otn links should terminate on two distinct nodes",
1217 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1218 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1219 assertThat("otn links should terminate on two distinct nodes",
1220 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1221 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1222 assertThat("otn links should terminate on two distinct tps",
1223 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1224 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1225 assertThat("otn links should terminate on two distinct tps",
1226 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1227 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1228 assertEquals(OperationalState.ENABLED, link.getOperationalState(), "operational state should be ENABLED");
1229 assertEquals(AdministrativeState.UNLOCKED, link.getAdministrativeState(),
1230 "administrative state should be UNLOCKED");
1233 private void checkOmsLink(
1234 Link link, Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1235 assertEquals(linkName, link.getName().get(new NameKey("OTS link name")).getValue(), "bad name for the link");
1236 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1238 LayerProtocolName.PHOTONICMEDIA.getName(),
1239 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1240 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1241 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(), "otn tapi link should be BIDIRECTIONAL");
1242 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1243 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1244 assertEquals(2, nodeEdgePointList.size(), "oms link should be between 2 neps");
1245 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1246 "topology uuid should be the same for the two termination point of the link");
1247 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1248 "topology uuid should be the same for the two termination point of the link");
1249 assertThat("oms links should terminate on two distinct nodes",
1250 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1251 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1252 assertThat("oms links should terminate on two distinct nodes",
1253 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1254 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1255 assertThat("oms links should terminate on two distinct tps",
1256 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1257 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1258 assertThat("oms links should terminate on two distinct tps",
1259 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1260 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1263 private Node changeTerminationPointState(Node initialNode, String tpid, AdminStates admin, State oper) {
1264 var tpdr1Bldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1265 .Node1Builder(initialNode.augmentation(Node1.class));
1266 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1267 TerminationPointBuilder tpBldr = new TerminationPointBuilder(tps.get(new TerminationPointKey(new TpId(tpid))));
1268 TerminationPoint1Builder tp1Bldr =
1269 new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1270 .setAdministrativeState(admin)
1271 .setOperationalState(oper);
1272 tpBldr.addAugmentation(tp1Bldr.build());
1273 tps.replace(tpBldr.key(), tpBldr.build());
1274 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.setTerminationPoint(tps).build()).build();
1277 private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1278 .networks.network.Link changeOtnLinkState(
1279 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1280 .networks.network.Link initiallink,
1283 var linkBldr = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
1284 .networks.network.LinkBuilder(initiallink);
1287 new Link1Builder(linkBldr.augmentation(Link1.class))
1288 .setAdministrativeState(admin)
1289 .setOperationalState(oper)
1294 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node getNode(
1295 String searchedChar,
1296 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1297 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node lastNode = null;
1298 for (var node : nodeList) {
1299 for (Name name : node.getName().values()) {
1300 if (name.getValue().contains(searchedChar)) {
1306 LOG.info("pattern '{}' not found in list of nodes", searchedChar);