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.anyOf;
11 import static org.hamcrest.CoreMatchers.containsString;
12 import static org.hamcrest.CoreMatchers.either;
13 import static org.hamcrest.CoreMatchers.hasItem;
14 import static org.hamcrest.CoreMatchers.hasItems;
15 import static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.junit.jupiter.api.Assertions.assertEquals;
18 import static org.junit.jupiter.api.Assertions.assertNull;
19 import static org.junit.jupiter.api.Assertions.assertTrue;
20 import static org.junit.jupiter.api.Assertions.fail;
22 import com.google.common.util.concurrent.FluentFuture;
23 import java.nio.charset.Charset;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
28 import java.util.Optional;
29 import java.util.UUID;
30 import java.util.concurrent.ExecutionException;
31 import java.util.stream.Collectors;
32 import org.eclipse.jdt.annotation.Nullable;
33 import org.junit.jupiter.api.BeforeAll;
34 import org.junit.jupiter.api.Test;
35 import org.opendaylight.mdsal.binding.api.DataBroker;
36 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
37 import org.opendaylight.transportpce.common.InstanceIdentifiers;
38 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
39 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
40 import org.opendaylight.transportpce.tapi.TapiStringConstants;
41 import org.opendaylight.transportpce.tapi.utils.TapiLink;
42 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
43 import org.opendaylight.transportpce.tapi.utils.TapiTopologyDataUtils;
44 import org.opendaylight.transportpce.test.AbstractTest;
45 import org.opendaylight.transportpce.test.utils.TopologyDataUtils;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1Builder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
66 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
67 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
68 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROMS;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
97 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
98 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
99 import org.slf4j.Logger;
100 import org.slf4j.LoggerFactory;
102 public class ConvertORTopoToFullTapiTopoTest extends AbstractTest {
103 private static final Logger LOG = LoggerFactory.getLogger(ConvertORTopoToFullTapiTopoTest.class);
105 private static Node otnMuxA;
106 private static Node otnSwitch;
107 private static Node tpdr100G;
108 private static Node roadmA;
109 private static Node roadmC;
110 private static Network openroadmNet;
111 private static Map<LinkKey, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
112 .networks.network.Link> ortopoLinks;
113 private static Uuid topologyUuid;
114 private static NetworkTransactionService networkTransactionService;
115 private static TapiLink tapiLink;
116 private static DataBroker dataBroker = getDataBroker();
119 static void setUp() throws InterruptedException, ExecutionException {
120 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
121 TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
122 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
123 TapiTopologyDataUtils.OPENROADM_NETWORK_FILE, InstanceIdentifiers.UNDERLAY_NETWORK_II);
124 TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
125 TapiTopologyDataUtils.OTN_TOPOLOGY_FILE, InstanceIdentifiers.OTN_NETWORK_II);
126 TopologyDataUtils.writePortmappingFromFileToDatastore(getDataStoreContextUtil(),
127 TapiTopologyDataUtils.PORTMAPPING_FILE);
129 KeyedInstanceIdentifier<Node, NodeKey> muxAIID = InstanceIdentifier.create(Networks.class)
130 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
131 .class, new NetworkKey(new NetworkId("otn-topology")))
132 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR1")));
133 FluentFuture<Optional<Node>> muxAFuture = dataBroker.newReadOnlyTransaction()
134 .read(LogicalDatastoreType.CONFIGURATION, muxAIID);
135 otnMuxA = muxAFuture.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();
143 KeyedInstanceIdentifier<Node, NodeKey> switchIID = InstanceIdentifier.create(Networks.class)
144 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
145 .class, new NetworkKey(new NetworkId("otn-topology")))
146 .child(Node.class, new NodeKey(new NodeId("SPDR-SA1-XPDR2")));
147 FluentFuture<Optional<Node>> switchFuture = dataBroker.newReadOnlyTransaction()
148 .read(LogicalDatastoreType.CONFIGURATION, switchIID);
149 otnSwitch = switchFuture.get().orElseThrow();
150 KeyedInstanceIdentifier<Node, NodeKey> roadmaIID = InstanceIdentifier.create(Networks.class)
151 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
152 .class, new NetworkKey(new NetworkId("openroadm-network")))
153 .child(Node.class, new NodeKey(new NodeId("ROADM-A1")));
154 FluentFuture<Optional<Node>> roadmaFuture = dataBroker.newReadOnlyTransaction()
155 .read(LogicalDatastoreType.CONFIGURATION, roadmaIID);
156 roadmA = roadmaFuture.get().orElseThrow();
157 KeyedInstanceIdentifier<Node, NodeKey> roadmcIID = InstanceIdentifier.create(Networks.class)
158 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
159 .class, new NetworkKey(new NetworkId("openroadm-network")))
160 .child(Node.class, new NodeKey(new NodeId("ROADM-C1")));
161 FluentFuture<Optional<Node>> roadmcFuture = dataBroker.newReadOnlyTransaction()
162 .read(LogicalDatastoreType.CONFIGURATION, roadmcIID);
163 roadmC = roadmcFuture.get().orElseThrow();
165 KeyedInstanceIdentifier<Node, NodeKey> tpdrIID = InstanceIdentifier.create(Networks.class)
166 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
167 .class, new NetworkKey(new NetworkId("otn-topology")))
168 .child(Node.class, new NodeKey(new NodeId("XPDR-A1-XPDR1")));
169 FluentFuture<Optional<Node>> tpdrFuture = dataBroker.newReadOnlyTransaction()
170 .read(LogicalDatastoreType.CONFIGURATION, tpdrIID);
171 tpdr100G = tpdrFuture.get().orElseThrow();
173 InstanceIdentifier<Network1> linksIID = InstanceIdentifier.create(Networks.class)
174 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
175 .class, new NetworkKey(new NetworkId("otn-topology")))
176 .augmentation(Network1.class);
177 FluentFuture<Optional<Network1>> linksFuture = dataBroker.newReadOnlyTransaction()
178 .read(LogicalDatastoreType.CONFIGURATION, linksIID);
179 linksFuture.get().orElseThrow().getLink();
181 InstanceIdentifier<Network1> links1IID = InstanceIdentifier.create(Networks.class)
182 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
183 .class, new NetworkKey(new NetworkId("openroadm-topology")))
184 .augmentation(Network1.class);
185 FluentFuture<Optional<Network1>> links1Future = dataBroker.newReadOnlyTransaction()
186 .read(LogicalDatastoreType.CONFIGURATION, links1IID);
187 ortopoLinks = links1Future.get().orElseThrow().getLink();
189 InstanceIdentifier<Network> ortopo1IID = InstanceIdentifier.create(Networks.class)
190 .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network
191 .class, new NetworkKey(new NetworkId("openroadm-topology")));
192 FluentFuture<Optional<Network>> ortopoFuture = dataBroker.newReadOnlyTransaction()
193 .read(LogicalDatastoreType.CONFIGURATION, ortopo1IID);
194 openroadmNet = ortopoFuture.get().orElseThrow();
196 topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
197 Charset.forName("UTF-8"))).toString());
198 networkTransactionService = new NetworkTransactionImpl(getDataBroker());
199 tapiLink = new TapiLinkImpl(networkTransactionService);
200 LOG.info("TEST SETUP READY");
204 void convertNodeWhenNoStates() {
205 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1", null, null);
206 List<String> networkPortList = new ArrayList<>();
207 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
208 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
209 networkPortList.add(tp.getTpId().getValue());
212 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
213 tapiFactory.convertNode(tpdr, networkPortList);
215 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
217 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
218 .getTapiNodes().get(new
219 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
220 Uuid enetworkNepUuid = new Uuid(
221 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
223 Uuid inetworkNepUuid = new Uuid(
224 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
226 OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
227 assertNull(enepN.getAdministrativeState(), "Administrative State should not be present");
228 assertNull(enepN.getOperationalState(), "Operational State should not be present");
230 OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
231 assertNull(inepN.getAdministrativeState(), "Administrative State should not be present");
232 assertNull(inepN.getOperationalState(), "Operational State should not be present");
236 void convertNodeWhenBadStates1() {
237 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
238 AdminStates.OutOfService, State.OutOfService);
239 List<String> networkPortList = new ArrayList<>();
240 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
241 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
242 networkPortList.add(tp.getTpId().getValue());
245 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
246 tapiFactory.convertNode(tpdr, networkPortList);
248 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
250 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
251 .getTapiNodes().get(new
252 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
253 Uuid enetworkNepUuid = new Uuid(
254 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
256 Uuid inetworkNepUuid = new Uuid(
257 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
259 OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
260 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
261 "Administrative State should be Locked");
262 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
264 OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
265 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
266 "Administrative State should be Locked");
267 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
271 void convertNodeWhenBadStates2() {
272 Node tpdr = changeTerminationPointState(tpdr100G, "XPDR1-NETWORK1", "XPDR1-CLIENT1",
273 AdminStates.Maintenance, State.Degraded);
274 List<String> networkPortList = new ArrayList<>();
275 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
276 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
277 networkPortList.add(tp.getTpId().getValue());
280 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
281 tapiFactory.convertNode(tpdr, networkPortList);
283 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
285 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode = tapiFactory
286 .getTapiNodes().get(new
287 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey(dsrNodeUuid));
288 Uuid enetworkNepUuid = new Uuid(
289 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
291 Uuid inetworkNepUuid = new Uuid(
292 UUID.nameUUIDFromBytes(("XPDR-A1-XPDR1+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
294 OwnedNodeEdgePoint enepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(enetworkNepUuid));
295 assertEquals(AdministrativeState.LOCKED, enepN.getAdministrativeState(),
296 "Administrative State should be Locked");
297 assertEquals(OperationalState.DISABLED, enepN.getOperationalState(), "Operational State should be Disabled");
299 OwnedNodeEdgePoint inepN = dsrNode.nonnullOwnedNodeEdgePoint().get(new OwnedNodeEdgePointKey(inetworkNepUuid));
300 assertEquals(AdministrativeState.LOCKED, inepN.getAdministrativeState(),
301 "Administrative State should be Locked");
302 assertEquals(OperationalState.DISABLED, inepN.getOperationalState(), "Operational State should be Disabled");
307 void convertNodeForTransponder100G() {
308 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
309 List<String> networkPortList = new ArrayList<>();
310 for (TerminationPoint tp : tpdr100G.augmentation(Node1.class).getTerminationPoint().values()) {
311 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
312 networkPortList.add(tp.getTpId().getValue());
315 tapiFactory.convertNode(tpdr100G, networkPortList);
316 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
317 = tapiFactory.getTapiNodes().values().stream()
318 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
319 .collect(Collectors.toList());
321 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
322 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
324 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("XPDR-A1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
326 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "tpdr", "XPDR-A1-XPDR1");
330 void convertNodeForOtnMuxponder() {
331 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
332 List<String> networkPortList = new ArrayList<>();
333 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
334 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
335 networkPortList.add(tp.getTpId().getValue());
338 tapiFactory.convertNode(otnMuxA, networkPortList);
339 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
340 = tapiFactory.getTapiNodes().values().stream()
341 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
342 .collect(Collectors.toList());
344 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
345 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
346 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
348 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "mux", "SPDR-SA1-XPDR1");
352 void convertNodeForOtnSwitch() {
353 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
354 List<String> networkPortList = new ArrayList<>();
355 for (TerminationPoint tp : otnSwitch.augmentation(Node1.class).getTerminationPoint().values()) {
356 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
357 networkPortList.add(tp.getTpId().getValue());
360 tapiFactory.convertNode(otnSwitch, networkPortList);
361 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
362 = tapiFactory.getTapiNodes().values().stream()
363 .sorted((n1, n2) -> n1.getUuid().getValue().compareTo(n2.getUuid().getValue()))
364 .collect(Collectors.toList());
366 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1 (DSR-ODU merged)");
367 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be 0 : no more transitional link");
369 Uuid dsrNodeUuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR2+XPONDER".getBytes(Charset.forName("UTF-8")))
371 checkDsrNode(tapiNodes.get(0), dsrNodeUuid, "switch", "SPDR-SA1-XPDR2");
375 void convertNodeForRoadmWhenNoOtnMuxAttached() {
376 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
377 tapiFactory.convertRoadmNode(roadmA, openroadmNet);
379 assertEquals(1, tapiFactory.getTapiNodes().size(), "Node list size should be 1");
380 assertEquals(0, tapiFactory.getTapiLinks().size(), "Link list size should be empty");
381 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
382 = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
383 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
384 .getBytes(Charset.forName("UTF-8"))).toString());
385 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
389 void convertNodeForRoadmWhenRoadmNeighborAttached() {
390 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
391 tapiFactory.convertRoadmNode(roadmA, openroadmNet);
392 tapiFactory.convertRoadmNode(roadmC, openroadmNet);
394 List<Link> rdmTordmLinkList = ortopoLinks.values().stream()
395 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ROADMTOROADM))
396 .collect(Collectors.toList());
397 tapiFactory.convertRdmToRdmLinks(rdmTordmLinkList);
399 assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2");
400 assertEquals(1, tapiFactory.getTapiLinks().size(), "Link list size should be 1");
402 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiNodes
403 = tapiFactory.getTapiNodes().values().stream().collect(Collectors.toList());
405 for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : tapiNodes) {
406 if (node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
407 && !node.getLayerProtocolName().contains(LayerProtocolName.DSR)) {
408 LOG.info("LOOP ROADM node found at rank {}, with Name {} and Uuid {}",
409 myInt, node.getName().toString(), node.getUuid());
413 Uuid roadmaNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
414 .getBytes(Charset.forName("UTF-8"))).toString());
415 LOG.info("ROADM node found at rank {} from getrank", getNodeRank("ROADM-A1", tapiNodes));
416 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmaNodeUuid, "roadm", "ROADM-A1");
418 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
419 = tapiFactory.getTapiLinks().values().stream()
420 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
421 .collect(Collectors.toList());
422 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
424 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-C1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
426 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
427 .getBytes(Charset.forName("UTF-8"))).toString());
428 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
429 .getBytes(Charset.forName("UTF-8"))).toString());
431 new Uuid(UUID.nameUUIDFromBytes(
432 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX"
433 .getBytes(Charset.forName("UTF-8"))).toString());
434 checkOmsLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
435 "ROADM-C1+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRXtoROADM-A1+PHOTONIC_MEDIA_OTS+DEG2-TTP-TXRX");
439 void convertNodeForRoadmWhenOtnMuxAttached() {
440 ConvertORTopoToTapiFullTopo tapiFactory = new ConvertORTopoToTapiFullTopo(topologyUuid, tapiLink);
441 List<String> networkPortListA = new ArrayList<>();
442 for (TerminationPoint tp : otnMuxA.augmentation(Node1.class).getTerminationPoint().values()) {
443 if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
444 networkPortListA.add(tp.getTpId().getValue());
447 tapiFactory.convertNode(otnMuxA, networkPortListA);
448 tapiFactory.convertRoadmNode(roadmA, openroadmNet);
449 List<Link> xponderOutLinkList = ortopoLinks.values().stream()
450 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDEROUTPUT))
451 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
452 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
453 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
454 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
455 .collect(Collectors.toList());
456 List<Link> xponderInLinkList = ortopoLinks.values().stream()
457 .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.XPONDERINPUT))
458 .filter(lk1 -> ((lk1.getSource().getSourceNode().equals(otnMuxA.getNodeId())
459 || lk1.getSource().getSourceNode().getValue().contains(roadmA.getNodeId().getValue()))
460 && (lk1.getDestination().getDestNode().equals(otnMuxA.getNodeId())
461 || lk1.getDestination().getDestNode().getValue().contains(roadmA.getNodeId().getValue()))))
462 .collect(Collectors.toList());
463 xponderInLinkList.addAll(xponderOutLinkList);
464 tapiFactory.convertXpdrToRdmLinks(xponderInLinkList);
465 assertEquals(2, tapiFactory.getTapiNodes().size(), "Node list size should be 2 (XPDR, DSR-ODU merged; ROADM)");
466 assertEquals(1, tapiFactory.getTapiLinks().size(), "Link list size should be 1 : no more transitional link");
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());
471 Uuid roadmNodeUuid = new Uuid(UUID.nameUUIDFromBytes((roadmA.getNodeId().getValue() + "+PHOTONIC_MEDIA")
472 .getBytes(Charset.forName("UTF-8"))).toString());
473 checkOtsiNode(tapiNodes.get(getNodeRank("ROADM-A1", tapiNodes)), roadmNodeUuid, "roadm", "ROADM-A1");
475 Uuid node1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+XPONDER".getBytes(Charset.forName("UTF-8")))
477 Uuid node2Uuid = new Uuid(UUID.nameUUIDFromBytes("ROADM-A1+PHOTONIC_MEDIA".getBytes(Charset.forName("UTF-8")))
479 LOG.info("ROADM-A1+PHOTONIC_MEDIA UUID is {}", node2Uuid);
480 Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes("SPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
481 .getBytes(Charset.forName("UTF-8"))).toString());
482 Uuid tp2Uuid = new Uuid(UUID.nameUUIDFromBytes(("ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRX")
483 .getBytes(Charset.forName("UTF-8"))).toString());
485 new Uuid(UUID.nameUUIDFromBytes(
486 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1"
487 .getBytes(Charset.forName("UTF-8"))).toString());
488 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> links
489 = tapiFactory.getTapiLinks().values().stream()
490 .sorted((l1, l2) -> l1.getUuid().getValue().compareTo(l2.getUuid().getValue()))
491 .collect(Collectors.toList());
492 checkXpdrRdmLink(links.get(0), node1Uuid, node2Uuid, tp1Uuid, tp2Uuid, linkUuid,
493 "ROADM-A1+PHOTONIC_MEDIA_OTS+SRG1-PP2-TXRXtoSPDR-SA1-XPDR1+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1");
496 private void checkDsrNode(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
497 Uuid node9Uuid, String dsrNodeType, String nodeId) {
498 assertEquals(node9Uuid, node.getUuid(), "incorrect node uuid");
499 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
500 "incorrect node name");
501 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
502 "administrative state should be UNLOCKED");
503 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
504 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
505 assertThat("one value-name should be 'dsr/odu node name'",
506 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
507 assertEquals(4, node.getLayerProtocolName().size(), "dsr node should manage 4 protocol layers : dsr and odu"
508 + " DIGITALOTN, PHOTONICMEDIA");
509 assertThat("dsr node should manage 2 protocol layers : dsr and odu",
510 node.getLayerProtocolName(), hasItems(LayerProtocolName.DSR, LayerProtocolName.ODU));
511 List<OwnedNodeEdgePoint> inepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
512 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint_N")))
513 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
514 .collect(Collectors.toList());
515 List<OwnedNodeEdgePoint> enepsN = node.nonnullOwnedNodeEdgePoint().values().stream()
516 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint_N")))
517 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
518 .collect(Collectors.toList());
519 List<OwnedNodeEdgePoint> nepsC;
520 switch (dsrNodeType) {
522 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
523 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
524 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
525 .collect(Collectors.toList());
526 assertEquals(4, enepsN.size(), "Switch-DSR node should have 4 eNEPs network");
527 assertEquals(4, inepsN.size(), "Switch-DSR node should have 4 iNEPs network");
528 assertEquals(4, nepsC.size(), "Switch-DSR node should have 4 NEPs client");
529 OwnedNodeEdgePoint nep1 = nepsC.get(2);
530 Uuid client4NepUuid = new Uuid(
531 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
533 checkNepClient100GSwitch(nep1, client4NepUuid, nodeId + "+DSR+XPDR2-CLIENT4", "NodeEdgePoint_C");
534 OwnedNodeEdgePoint enep2 = enepsN.get(2);
535 OwnedNodeEdgePoint inep2 = inepsN.get(3);
536 Uuid enetworkNepUuid = new Uuid(
537 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR2-CLIENT4").getBytes(Charset.forName("UTF-8")))
539 Uuid inetworkNepUuid = new Uuid(
540 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR2-NETWORK1").getBytes(Charset.forName("UTF-8")))
542 checkNepeODU4(enep2, enetworkNepUuid, nodeId + "+eODU+XPDR2-CLIENT4", "eNodeEdgePoint_N", false);
543 checkNepNetworkODU4(inep2, inetworkNepUuid, nodeId + "+iODU+XPDR2-NETWORK1", "iNodeEdgePoint_N", true);
544 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
545 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
546 .collect(Collectors.toList());
547 checkNodeRuleGroupForSwitchDSR(nrgList, client4NepUuid, enetworkNepUuid, node9Uuid);
550 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
551 .filter(n -> n.getName().containsKey(new NameKey("NodeEdgePoint_C")))
552 .sorted((nep3, nep4) -> nep3.getUuid().getValue().compareTo(nep4.getUuid().getValue()))
553 .collect(Collectors.toList());
554 assertEquals(4, enepsN.size(), "Mux-DSR node should have 4 eNEP network");
555 assertEquals(1, inepsN.size(), "Mux-DSR node should have 1 iNEP network");
556 assertEquals(4, nepsC.size(), "Mux-DSR node should have 4 NEPs client");
557 OwnedNodeEdgePoint nep3 = nepsC.get(2);
558 Uuid client3NepUuid = new Uuid(
559 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
561 checkNepClient10G(nep3, client3NepUuid, nodeId + "+DSR+XPDR1-CLIENT3", "NodeEdgePoint_C");
562 OwnedNodeEdgePoint enep4 = enepsN.get(3);
563 OwnedNodeEdgePoint inep4 = inepsN.get(0);
564 Uuid enetworkNepUuid2 = new Uuid(
565 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT3").getBytes(Charset.forName("UTF-8")))
567 Uuid inetworkNepUuid2 = new Uuid(
568 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
570 checkNepeODU4(enep4, enetworkNepUuid2, nodeId + "+eODU+XPDR1-CLIENT3", "eNodeEdgePoint_N", false);
571 checkNepNetworkODU4(inep4, inetworkNepUuid2, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
573 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
574 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
575 .collect(Collectors.toList());
576 checkNodeRuleGroupForMuxDSR(nrgList2, client3NepUuid, enetworkNepUuid2, node9Uuid);
579 nepsC = node.nonnullOwnedNodeEdgePoint().values().stream()
580 .filter(n -> n.getName().containsKey(new NameKey("100G-tpdr")))
581 .sorted((nep5, nep6) -> nep5.getUuid().getValue().compareTo(nep6.getUuid().getValue()))
582 .collect(Collectors.toList());
583 assertEquals(2, enepsN.size(), "Tpdr-DSR node should have 2 eNEPs network");
584 assertEquals(2, inepsN.size(), "Tpdr-DSR node should have 2 iNEPs network");
585 assertEquals(2, nepsC.size(), "Tpdr-DSR node should have 2 NEPs client");
586 OwnedNodeEdgePoint nep5 = nepsC.get(0);
587 Uuid client1NepUuid = new Uuid(
588 UUID.nameUUIDFromBytes((nodeId + "+DSR+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
590 checkNepClient100GTpdr(nep5, client1NepUuid, nodeId + "+DSR+XPDR1-CLIENT1", "100G-tpdr");
591 OwnedNodeEdgePoint enep6 = enepsN.get(0);
592 OwnedNodeEdgePoint inep6 = inepsN.get(1);
593 Uuid enetworkNepUuid3 = new Uuid(
594 UUID.nameUUIDFromBytes((nodeId + "+eODU+XPDR1-CLIENT1").getBytes(Charset.forName("UTF-8")))
596 Uuid inetworkNepUuid3 = new Uuid(
597 UUID.nameUUIDFromBytes((nodeId + "+iODU+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
599 checkNepeODU4(enep6, enetworkNepUuid3, nodeId + "+eODU+XPDR1-CLIENT1", "eNodeEdgePoint_N", false);
600 checkNepNetworkODU4(inep6, inetworkNepUuid3, nodeId + "+iODU+XPDR1-NETWORK1", "iNodeEdgePoint_N",
602 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
603 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
604 .collect(Collectors.toList());
605 checkNodeRuleGroupForTpdrDSR(nrgList3, client1NepUuid, enetworkNepUuid3, node9Uuid);
613 private void checkOtsiNode(
614 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node,
615 Uuid nodeUuid, String otsiNodeType, String nodeId) {
616 if (!node.getUuid().equals(nodeUuid)) {
617 LOG.info("ERRORUUID on Node.getNodeId {}, NodeId {}", node.getName().toString(), nodeId);
618 LOG.info("ERRORUUID TapiUuid {}, transmitted Node Uuid {}", node.getUuid(), nodeUuid);
620 assertEquals(nodeUuid, node.getUuid(), "incorrect node uuid");
621 List<OwnedNodeEdgePoint> nepsI = null;
622 List<OwnedNodeEdgePoint> nepsE = null;
623 List<OwnedNodeEdgePoint> nepsP = null;
624 List<OwnedNodeEdgePoint> nepsOMS = null;
625 List<OwnedNodeEdgePoint> nepsOTS = null;
626 List<OwnedNodeEdgePoint> nepsPhot = null;
627 if (!otsiNodeType.equals("roadm")) {
628 assertEquals(nodeId + "+XPONDER", node.getName().get(new NameKey("dsr/odu node name")).getValue(),
629 "incorrect node name");
630 assertThat("one value-name should be 'dsr/odu node name'",
631 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("dsr/odu node name")));
632 nepsI = node.nonnullOwnedNodeEdgePoint().values().stream()
633 .filter(n -> n.getName().containsKey(new NameKey("iNodeEdgePoint")))
634 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
635 .collect(Collectors.toList());
636 nepsE = node.nonnullOwnedNodeEdgePoint().values().stream()
637 .filter(n -> n.getName().containsKey(new NameKey("eNodeEdgePoint")))
638 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
639 .collect(Collectors.toList());
640 nepsP = node.nonnullOwnedNodeEdgePoint().values().stream()
641 .filter(n -> n.getName().containsKey(new NameKey("PhotMedNodeEdgePoint")))
642 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
643 .collect(Collectors.toList());
645 assertEquals(nodeId + "+PHOTONIC_MEDIA", node.getName().get(new NameKey("roadm node name")).getValue(),
646 "incorrect node name");
647 assertThat("one value-name should be 'dsr/odu node name'",
648 new ArrayList<>(node.nonnullName().keySet()), hasItem(new NameKey("roadm node name")));
649 nepsOMS = node.nonnullOwnedNodeEdgePoint().values().stream()
650 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
651 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
652 .collect(Collectors.toList());
653 nepsOTS = node.nonnullOwnedNodeEdgePoint().values().stream()
654 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
655 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
656 .collect(Collectors.toList());
657 nepsPhot = node.nonnullOwnedNodeEdgePoint().values().stream()
658 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OMSNodeEdgePoint")))
659 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
660 .collect(Collectors.toList());
661 nepsPhot.addAll(node.nonnullOwnedNodeEdgePoint().values().stream()
662 .filter(n -> n.getName().containsKey(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
663 .sorted((nep1, nep2) -> nep1.getUuid().getValue().compareTo(nep2.getUuid().getValue()))
664 .collect(Collectors.toList()));
666 assertEquals(AdministrativeState.UNLOCKED, node.getAdministrativeState(),
667 "administrative state should be UNLOCKED");
668 assertEquals(LifecycleState.INSTALLED, node.getLifecycleState(), "life-cycle state should be INSTALLED");
669 assertEquals(OperationalState.ENABLED, node.getOperationalState(), "operational state should be ENABLED");
670 assertEquals(1, node.getLayerProtocolName().size(),
671 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
672 assertEquals(LayerProtocolName.PHOTONICMEDIA, node.getLayerProtocolName().stream().findFirst().orElseThrow(),
673 "otsi node should manage a single protocol layer : PHOTONIC_MEDIA");
675 switch (otsiNodeType) {
677 assertEquals(4, nepsE.size(), "Switch-OTSi node should have 4 eNEPs");
678 assertEquals(4, nepsI.size(), "Switch-OTSi node should have 4 iNEPs");
679 assertEquals(4, nepsP.size(), "Switch-OTSi node should have 4 photNEPs");
680 OwnedNodeEdgePoint nep1 = nepsI.get(1);
681 Uuid inepUuid = new Uuid(
682 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR2-NETWORK2").getBytes(Charset.forName("UTF-8")))
684 checkNepOtsiNode(nep1, inepUuid, nodeId + "+iOTSi+XPDR2-NETWORK2", "iNodeEdgePoint", true);
685 OwnedNodeEdgePoint nep2 = nepsE.get(0);
686 Uuid enepUuid = new Uuid(
687 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2")
688 .getBytes(Charset.forName("UTF-8")))
690 checkNepOtsiNode(nep2, enepUuid, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR2-NETWORK2",
691 "eNodeEdgePoint", false);
692 OwnedNodeEdgePoint photNep = nepsP.get(1);
693 Uuid pnepUuid = new Uuid(
694 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2")
695 .getBytes(Charset.forName("UTF-8"))).toString());
696 checkNepOtsiNode(photNep, pnepUuid, nodeId + "+PHOTONIC_MEDIA+XPDR2-NETWORK2", "PhotMedNodeEdgePoint",
698 List<NodeRuleGroup> nrgList = node.nonnullNodeRuleGroup().values().stream()
699 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
700 .collect(Collectors.toList());
701 checkNodeRuleGroupForSwitchOTSi(nrgList, enepUuid, inepUuid, nodeUuid);
704 assertEquals(1, nepsE.size(), "Mux-OTSi node should have 1 eNEP");
705 assertEquals(1, nepsI.size(), "Mux-OTSi node should have 1 iNEPs");
706 assertEquals(1, nepsP.size(), "Mux-OTSi node should have 1 photNEPs");
707 OwnedNodeEdgePoint nep3 = nepsE.get(0);
708 Uuid enepUuid2 = new Uuid(
709 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
710 .getBytes(Charset.forName("UTF-8")))
712 checkNepOtsiNode(nep3, enepUuid2, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
713 "eNodeEdgePoint", false);
714 OwnedNodeEdgePoint nep4 = nepsI.get(0);
715 Uuid inepUuid2 = new Uuid(
716 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
718 checkNepOtsiNode(nep4, inepUuid2, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
719 OwnedNodeEdgePoint photNep1 = nepsP.get(0);
720 Uuid pnep1Uuid = new Uuid(
721 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
722 .getBytes(Charset.forName("UTF-8"))).toString());
723 checkNepOtsiNode(photNep1, pnep1Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
725 List<NodeRuleGroup> nrgList2 = node.nonnullNodeRuleGroup().values().stream()
726 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
727 .collect(Collectors.toList());
728 checkNodeRuleGroupForMuxOTSi(nrgList2, enepUuid2, inepUuid2, nodeUuid);
731 assertEquals(2, nepsE.size(), "Tpdr-OTSi node should have 2 eNEPs");
732 assertEquals(2, nepsI.size(), "Tpdr-OTSi node should have 2 iNEPs");
733 assertEquals(2, nepsP.size(), "Tpdr-OTSi node should have 2 photNEPs");
734 OwnedNodeEdgePoint nep5 = nepsE.get(0);
735 Uuid enepUuid3 = new Uuid(
736 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1")
737 .getBytes(Charset.forName("UTF-8")))
739 checkNepOtsiNode(nep5, enepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+XPDR1-NETWORK1",
740 "eNodeEdgePoint", false);
741 OwnedNodeEdgePoint nep6 = nepsI.get(0);
742 Uuid inepUuid3 = new Uuid(
743 UUID.nameUUIDFromBytes((nodeId + "+iOTSi+XPDR1-NETWORK1").getBytes(Charset.forName("UTF-8")))
745 checkNepOtsiNode(nep6, inepUuid3, nodeId + "+iOTSi+XPDR1-NETWORK1", "iNodeEdgePoint", true);
746 OwnedNodeEdgePoint photNep2 = nepsP.get(0);
747 Uuid pnep2Uuid = new Uuid(
748 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1")
749 .getBytes(Charset.forName("UTF-8"))).toString());
750 checkNepOtsiNode(photNep2, pnep2Uuid, nodeId + "+PHOTONIC_MEDIA+XPDR1-NETWORK1", "PhotMedNodeEdgePoint",
752 List<NodeRuleGroup> nrgList3 = node.nonnullNodeRuleGroup().values().stream()
753 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
754 .collect(Collectors.toList());
755 checkNodeRuleGroupForTpdrOTSi(nrgList3, enepUuid3, inepUuid3, nodeUuid);
758 // assertEquals(0, nepsMc.size(), "MC NEP no more configured, Roadm node should have 0 MC NEPs");
759 // assertEquals(0, nepsOtsimc.size(), "Roadm node should have 10 OTSiMC NEPs");
760 assertEquals(12, nepsPhot.size(), "Roadm node should have 12 PHOT_MEDIA NEPs (2x4 OTS +2x(OTS+OMS)");
762 OwnedNodeEdgePoint nep7 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
763 Uuid mcnepUuid3 = new Uuid(
764 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX").getBytes(Charset
765 .forName("UTF-8"))).toString());
766 checkNepOtsiRdmNode(nep7, mcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
767 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
768 OwnedNodeEdgePoint nep8 = nepsOTS.get(getRank("DEG1-TTP", nepsOTS));
769 Uuid otmcnepUuid3 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX")
770 .getBytes(Charset.forName("UTF-8"))).toString());
771 checkNepOtsiRdmNode(nep8, otmcnepUuid3, nodeId + "+PHOTONIC_MEDIA_OTS+DEG1-TTP-TXRX",
772 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
773 OwnedNodeEdgePoint omsNep3 = nepsOMS.get(getRank("DEG1-TTP", nepsOMS));
774 Uuid omsNep3Uuid = new Uuid(
775 UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX")
776 .getBytes(Charset.forName("UTF-8"))).toString());
777 checkNepOtsiRdmNode(omsNep3, omsNep3Uuid, nodeId + "+PHOTONIC_MEDIA_OMS+DEG1-TTP-TXRX",
778 "PHOTONIC_MEDIA_OMSNodeEdgePoint", false);
780 OwnedNodeEdgePoint nep10 = nepsOTS.get(getRank("SRG1-PP1", nepsOTS));
781 Uuid otsnepUuid4 = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX")
782 .getBytes(Charset.forName("UTF-8"))).toString());
783 checkNepOtsiRdmNode(nep10, otsnepUuid4, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP1-TXRX",
784 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
785 OwnedNodeEdgePoint otsNep4 = nepsOTS.get(getRank("SRG1-PP3", nepsOTS));
786 Uuid otsNep4Uuid = new Uuid(UUID.nameUUIDFromBytes((nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX")
787 .getBytes(Charset.forName("UTF-8"))).toString());
788 checkNepOtsiRdmNode(otsNep4, otsNep4Uuid, nodeId + "+PHOTONIC_MEDIA_OTS+SRG1-PP3-TXRX",
789 "PHOTONIC_MEDIA_OTSNodeEdgePoint", false);
790 List<NodeRuleGroup> nrgList4 = node.nonnullNodeRuleGroup().values().stream()
791 .sorted((nrg1, nrg2) -> nrg1.getUuid().getValue().compareTo(nrg2.getUuid().getValue()))
792 .collect(Collectors.toList());
793 checkNodeRuleGroupForRdm(nrgList4, 12);
801 private void checkNepClient10G(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
802 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
803 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
804 Name name = nameList.get(0);
805 assertEquals(portName, name.getValue(), "value of client nep should be '" + portName + "'");
806 assertEquals(nepName, name.getValueName(),
807 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
808 LOG.info("checkNEPClient10G-NEP {} has following supported CEP {}", nepName, nep
809 .getSupportedCepLayerProtocolQualifierInstances().toString());
810 assertEquals(3, nep.getSupportedCepLayerProtocolQualifierInstances()
811 .size(), "Client nep should support 3 kind of cep");
812 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
813 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
814 .getSupportedCepLayerProtocolQualifierInstances();
815 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
816 lpql.add(entry.getLayerProtocolQualifier());
818 assertEquals(3, lpql.size(), "Client nep should support 3 kind of cep");
819 assertThat("client nep should support 3 kind of cep",
820 lpql, hasItems(ODUTYPEODU2.VALUE, ODUTYPEODU2E.VALUE, DIGITALSIGNALTYPE10GigELAN.VALUE));
822 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
823 checkCommonPartOfNep(nep, false);
826 private void checkNepeODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
828 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
829 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
830 Name name = nameList.get(0);
831 assertEquals(portName, name.getValue(), "value of eODU nep should be '" + portName + "'");
832 assertEquals(nepName, name.getValueName(),
833 "value-name of eODU nep for '" + portName + "' should be '" + nepName + "'");
834 // TODO: depending on the type of node there is one type or another
835 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
836 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
837 .getSupportedCepLayerProtocolQualifierInstances();
838 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
839 lpql.add(entry.getLayerProtocolQualifier());
841 assertThat("eODU nep should support 1, 2 or 3 kind of cep, depending on client port",
842 lpql.size(), anyOf(is(1), is(2), is(3)));
844 lpql.stream().anyMatch(splc -> splc.equals(ODUTYPEODU0.VALUE)
845 || splc.equals(ODUTYPEODU2.VALUE) || splc.equals(ODUTYPEODU2E.VALUE)
846 || splc.equals(ODUTYPEODU4.VALUE)),
847 "eODU nep should support 1 kind of cep");
848 assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "eODU nep should be of ODU protocol type");
849 checkCommonPartOfNep(nep, withSip);
852 private void checkNepNetworkODU4(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
854 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
855 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
856 Name name = nameList.get(0);
857 assertEquals(portName, name.getValue(), "value of network nep should be '" + portName + "'");
858 assertEquals(nepName, name.getValueName(),
859 "value-name of network nep for '" + portName + "' should be '" + nepName + "'");
860 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
861 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
862 .getSupportedCepLayerProtocolQualifierInstances();
863 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
864 lpql.add(entry.getLayerProtocolQualifier());
866 assertEquals(1, lpql.size(), "Network nep should support 1 kind of cep");
867 assertThat("network nep should support 1 kind of cep", lpql, hasItem(ODUTYPEODU4.VALUE));
868 assertEquals(LayerProtocolName.ODU, nep.getLayerProtocolName(), "network nep should be of ODU protocol type");
869 checkCommonPartOfNep(nep, withSip);
872 private void checkNodeRuleGroupForTpdrDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
874 assertEquals(2, nrgList.size(), "transponder DSR should contain 2 node rule group");
875 for (NodeRuleGroup nodeRuleGroup : nrgList) {
876 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
877 "each node-rule-group should contain 2 NEP for transponder DSR");
879 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).nonnullNodeEdgePoint().values());
880 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
881 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
882 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
883 assertThat("node-rule-group nb 1 should be between nep-client1 and nep-network1",
884 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
885 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
886 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
887 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
888 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
889 "node-rule-group nb 1 should be between nep-client1 and nep-network1 of the same node");
890 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
891 assertEquals(1, rule.size(), "node-rule-group nb 1 should contain a single rule");
892 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
893 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
894 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
895 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
896 "the rule type should be 'FORWARDING'");
899 private void checkNodeRuleGroupForMuxDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
901 assertEquals(4, nrgList.size(), "muxponder DSR should contain 4 node rule group");
902 for (NodeRuleGroup nodeRuleGroup : nrgList) {
903 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
904 "each node-rule-group should contain 2 NEP for muxponder DSR");
906 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(1).nonnullNodeEdgePoint().values());
907 assertThat("node-rule-group nb 2 should be between nep-client4 and nep-network1",
908 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
909 either(containsString(networkNepUuid.getValue())).or(containsString(clientNepUuid.getValue())));
910 assertEquals(nodeEdgePointList.get(0).getNodeUuid(), nodeUuid,
911 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
912 assertEquals(nodeEdgePointList.get(1).getNodeUuid(), nodeUuid,
913 "node-rule-group nb 2 should be between nep-client4 and nep-network1 of the same node");
914 List<Rule> rule = new ArrayList<>(nrgList.get(1).nonnullRule().values());
915 assertEquals(1, rule.size(), "node-rule-group nb 2 should contain a single rule");
916 assertEquals("forward", rule.get(0).getLocalId(), "local-id of the rule should be 'forward'");
917 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, rule.get(0).getForwardingRule(),
918 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
919 assertEquals(RuleType.FORWARDING, rule.get(0).getRuleType().stream().findFirst().orElseThrow(),
920 "the rule type should be 'FORWARDING'");
923 private void checkNodeRuleGroupForSwitchDSR(List<NodeRuleGroup> nrgList, Uuid clientNepUuid, Uuid networkNepUuid,
925 assertEquals(1, nrgList.size(), "Switch-DSR should contain a single node rule group");
926 assertEquals(8, nrgList.get(0).getNodeEdgePoint().size(), "Switch-DSR node-rule-group should contain 8 NEP");
927 List<NodeEdgePoint> nrg = nrgList.get(0).nonnullNodeEdgePoint().values().stream()
928 .sorted((nrg1, nrg2) -> nrg1.getNodeEdgePointUuid().getValue()
929 .compareTo(nrg2.getNodeEdgePointUuid().getValue()))
930 .collect(Collectors.toList());
931 assertEquals(networkNepUuid, nrg.get(6).getNodeEdgePointUuid(),
932 "in the sorted node-rule-group, nep number 7 should be XPDR2-NETWORK1");
933 assertEquals(clientNepUuid, nrg.get(3).getNodeEdgePointUuid(),
934 "in the sorted node-rule-group, nep number 4 should be XPDR2-CLIENT4");
935 assertEquals(nodeUuid, nrg.get(4).getNodeUuid(),
936 "any item of the node-rule-group should have the same nodeUuid");
937 assertEquals(nodeUuid, nrg.get(3).getNodeUuid(),
938 "any item of the node-rule-group should have the same nodeUuid");
940 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
941 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
942 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
943 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
944 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
945 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
946 "the rule type should be 'FORWARDING'");
949 private void checkNodeRuleGroupForRdm(List<NodeRuleGroup> nrgList, int nbNeps) {
950 assertEquals(1, nrgList.size(), "RDM infra node - OTSi should contain a single node rule groups");
952 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
953 assertEquals(nbNeps, nodeEdgePointList.size(),
954 "RDM infra node -rule-group should contain " + nbNeps + " NEP");
956 assertNull(nrgList.get(0).getNodeEdgePoint(), "RDM infra node -rule-group should contain no NEP");
958 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
959 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
960 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
961 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
962 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
963 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
964 "the rule type should be 'FORWARDING'");
967 private void checkNodeRuleGroupForTpdrOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
969 assertEquals(2, nrgList.size(), "Tpdr-OTSi should contain two node rule groups");
970 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
971 assertEquals(2, nodeEdgePointList.size(), "Tpdr-OTSi node-rule-group should contain 2 NEP");
972 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
973 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
974 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
975 assertThat("Tpdr-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
976 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
977 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
978 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
979 "any item of the node-rule-group should have the same nodeUuid");
980 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
981 "any item of the node-rule-group should have the same nodeUuid");
982 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
983 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
984 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
985 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
986 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
987 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
988 "the rule type should be 'FORWARDING'");
991 private void checkNodeRuleGroupForMuxOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
993 assertEquals(1, nrgList.size(), "Mux-OTSi should contain a single node rule group");
994 List<NodeEdgePoint> nodeEdgePointList = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
995 assertEquals(2, nodeEdgePointList.size(), "Mux-OTSi node-rule-group should contain 2 NEP");
996 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
997 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
998 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
999 assertThat("Mux-OTSi node-rule-group should be between eNEP and iNEP of XPDR1-NETWORK1",
1000 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1001 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1002 assertEquals(nodeUuid, nodeEdgePointList.get(0).getNodeUuid(),
1003 "any item of the node-rule-group should have the same nodeUuid");
1004 assertEquals(nodeUuid, nodeEdgePointList.get(1).getNodeUuid(),
1005 "any item of the node-rule-group should have the same nodeUuid");
1006 List<Rule> ruleList = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1007 assertEquals(1, ruleList.size(), "node-rule-group should contain a single rule");
1008 assertEquals("forward", ruleList.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1009 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList.get(0).getForwardingRule(),
1010 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1011 assertEquals(RuleType.FORWARDING, ruleList.get(0).getRuleType().stream().findFirst().orElseThrow(),
1012 "the rule type should be 'FORWARDING'");
1015 private void checkNodeRuleGroupForSwitchOTSi(List<NodeRuleGroup> nrgList, Uuid enepUuid, Uuid inepUuid,
1017 assertEquals(4, nrgList.size(), "Switch-OTSi should contain 4 node rule group");
1018 for (NodeRuleGroup nodeRuleGroup : nrgList) {
1019 assertEquals(2, nodeRuleGroup.getNodeEdgePoint().size(),
1020 "each node-rule-group should contain 2 NEP for Switch-OTSi");
1022 List<NodeEdgePoint> nodeEdgePointList1 = new ArrayList<>(nrgList.get(3).nonnullNodeEdgePoint().values());
1023 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1024 nodeEdgePointList1.get(0).getNodeEdgePointUuid().getValue(),
1025 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1026 assertThat("Switch-OTSi node-rule-group nb 4 should be between eNEP and iNEP of XPDR2-NETWORK2",
1027 nodeEdgePointList1.get(1).getNodeEdgePointUuid().getValue(),
1028 either(containsString(enepUuid.getValue())).or(containsString(inepUuid.getValue())));
1029 List<NodeEdgePoint> nodeEdgePointList0 = new ArrayList<>(nrgList.get(0).getNodeEdgePoint().values());
1030 assertEquals(nodeUuid, nodeEdgePointList0.get(0).getNodeUuid(),
1031 "any item of the node-rule-group should have the same nodeUuid");
1032 assertEquals(nodeUuid, nodeEdgePointList0.get(1).getNodeUuid(),
1033 "any item of the node-rule-group should have the same nodeUuid");
1034 List<Rule> ruleList0 = new ArrayList<>(nrgList.get(0).nonnullRule().values());
1035 assertEquals(1, ruleList0.size(), "node-rule-group should contain a single rule");
1036 assertEquals("forward", ruleList0.get(0).getLocalId(), "local-id of the rule should be 'forward'");
1037 assertEquals(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, ruleList0.get(0).getForwardingRule(),
1038 "the forwarding rule should be 'MAYFORWARDACROSSGROUP'");
1039 assertEquals(RuleType.FORWARDING, ruleList0.get(0).getRuleType().stream().findFirst().orElseThrow(),
1040 "the rule type should be 'FORWARDING'");
1043 private void checkNepClient100GSwitch(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1044 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1045 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1046 assertEquals(portName, nameList.get(0).getValue(),
1047 "value of client nep should be '" + portName + "'");
1048 assertEquals(nepName, nameList.get(0).getValueName(),
1049 "value-name of client nep for '" + portName + "' should be '" + nepName + "'");
1050 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1051 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1052 .getSupportedCepLayerProtocolQualifierInstances();
1053 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1054 lpql.add(entry.getLayerProtocolQualifier());
1056 LOG.info("checkNEPClient100G-NEP {} has following supported CEP {}", nepName, nep
1057 .getSupportedCepLayerProtocolQualifierInstances().toString());
1058 assertEquals(2, lpql.size(), "Client nep should support 2 kind of cep");
1059 assertThat("client nep should support 2 kind of cep", lpql,
1060 hasItems(ODUTYPEODU4.VALUE, DIGITALSIGNALTYPE100GigE.VALUE));
1061 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
1062 checkCommonPartOfNep(nep, false);
1065 private void checkNepClient100GTpdr(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName) {
1066 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1067 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1068 assertEquals(portName, nameList.get(0).getValue(), "value of client nep should be '" + portName + "'");
1069 assertEquals(nepName, nameList.get(0).getValueName(),
1070 "value-name of client nep for '" + portName + "' should be 100G-tpdr'");
1071 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1072 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1073 .getSupportedCepLayerProtocolQualifierInstances();
1074 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1075 lpql.add(entry.getLayerProtocolQualifier());
1077 assertEquals(1, lpql.size(), "Client nep should support 1 kind of cep");
1078 assertThat("client nep should support 2 kind of cep", lpql, hasItems(DIGITALSIGNALTYPE100GigE.VALUE));
1079 assertEquals(LayerProtocolName.DSR, nep.getLayerProtocolName(), "client nep should be of DSR protocol type");
1080 checkCommonPartOfNep(nep, false);
1083 private void checkNepOtsiNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1085 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1086 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1087 assertEquals(portName, nameList.get(0).getValue(), "value of OTSi nep should be '" + portName + "'");
1088 assertEquals(nepName, nameList.get(0).getValueName(), "value-name of OTSi nep should be '" + nepName + "'");
1089 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1090 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1091 .getSupportedCepLayerProtocolQualifierInstances();
1092 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1093 lpql.add(entry.getLayerProtocolQualifier());
1095 assertEquals(2, lpql.size(), "OTSi nep should support 2 kind of cep");
1096 assertThat("OTSi nep should support 2 kind of cep",
1097 lpql, hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE, PHOTONICLAYERQUALIFIEROTSi.VALUE));
1098 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1099 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1100 checkCommonPartOfNep(nep, withSip);
1103 private void checkNepOtsiRdmNode(OwnedNodeEdgePoint nep, Uuid nepUuid, String portName, String nepName,
1105 if (!nep.getUuid().equals(nepUuid)) {
1106 LOG.info("ERRORUUIDNEP on Nep {}, expected {}", nep.getName().toString(), portName);
1108 assertEquals(nepUuid, nep.getUuid(), "bad uuid for " + portName);
1109 List<Name> nameList = new ArrayList<>(nep.nonnullName().values());
1110 assertEquals(portName, nameList.get(0).getValue(),
1111 "value of OTSi nep should be '" + portName + "'");
1112 assertEquals(nepName, nameList.get(0).getValueName(),
1113 "value-name of OTSi nep should be '" + nepName + "'");
1114 List<LAYERPROTOCOLQUALIFIER> lpql = new ArrayList<>();
1115 List<SupportedCepLayerProtocolQualifierInstances> lsclpqi = nep
1116 .getSupportedCepLayerProtocolQualifierInstances();
1117 for (SupportedCepLayerProtocolQualifierInstances entry : lsclpqi) {
1118 lpql.add(entry.getLayerProtocolQualifier());
1120 if (nepName.contains("OMS")) {
1121 assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep");
1122 assertThat("OTSi nep should support 1 kind of cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROMS.VALUE));
1123 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1124 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1125 } else if (nepName.contains("OTS")) {
1126 assertEquals(1, lpql.size(), "OTSi nep of RDM infra node should support only 1 kind of cep");
1127 assertThat("OTSi nep should support 1 kind of cep", lpql, hasItems(PHOTONICLAYERQUALIFIEROTS.VALUE));
1128 assertEquals(LayerProtocolName.PHOTONICMEDIA, nep.getLayerProtocolName(),
1129 "OTSi nep should be of PHOTONIC_MEDIA protocol type");
1131 checkCommonPartOfNep(nep, withSip);
1134 private void checkCommonPartOfNep(OwnedNodeEdgePoint nep, boolean withSip) {
1135 assertEquals(Direction.BIDIRECTIONAL, nep.getDirection(), "link port direction should be DIRECTIONAL");
1136 assertEquals(AdministrativeState.UNLOCKED, nep.getAdministrativeState(),
1137 "administrative state should be UNLOCKED");
1138 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1139 // assertEquals(TerminationState.TERMINATEDBIDIRECTIONAL, nep.getTerminationState(),
1140 // "termination state should be TERMINATED BIDIRECTIONAL");
1141 assertEquals(LifecycleState.INSTALLED, nep.getLifecycleState(), "life-cycle state should be INSTALLED");
1143 assertEquals(1, nep.getMappedServiceInterfacePoint().size(), "Given nep should support 1 SIP");
1145 // TODO: convert this test since terminationState is migrated to CEP attribute in TAPI 2.4
1146 // assertEquals(TerminationDirection.BIDIRECTIONAL, nep.getTerminationDirection(),
1147 // "termination direction should be BIDIRECTIONAL");
1148 assertEquals(OperationalState.ENABLED, nep.getOperationalState(),
1149 "operational state of client nep should be ENABLED");
1150 assertEquals(PortRole.SYMMETRIC, nep.getLinkPortRole(),
1151 "link-port-role of client nep should be SYMMETRIC");
1154 private void checkOmsLink(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link,
1155 Uuid node1Uuid, Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1156 assertEquals(linkName, link.getName().get(new NameKey("OMS link name")).getValue(), "bad name for the link");
1157 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1159 LayerProtocolName.PHOTONICMEDIA.getName(),
1160 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1161 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1162 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),"otn tapi link should be BIDIRECTIONAL");
1163 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1164 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1165 assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1166 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1167 "topology uuid should be the same for the two termination point of the link");
1168 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1169 "topology uuid should be the same for the two termination point of the link");
1170 assertThat("oms links should terminate on two distinct nodes",
1171 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1172 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1173 assertThat("oms links should terminate on two distinct nodes",
1174 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1175 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1176 assertThat("oms links should terminate on two distinct tps",
1177 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1178 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1179 assertThat("oms links should terminate on two distinct tps",
1180 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1181 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1184 private void checkXpdrRdmLink(
1185 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link, Uuid node1Uuid,
1186 Uuid node2Uuid, Uuid tp1Uuid, Uuid tp2Uuid, Uuid linkUuid, String linkName) {
1187 assertEquals(linkName, link.getName().get(new NameKey("XPDR-RDM link name")).getValue(),
1188 "bad name for the link");
1189 assertEquals(linkUuid, link.getUuid(), "bad uuid for link");
1191 LayerProtocolName.PHOTONICMEDIA.getName(),
1192 link.getLayerProtocolName().stream().findFirst().orElseThrow().getName(),
1193 "oms link should be between 2 nodes of protocol layers PHOTONIC_MEDIA");
1194 assertEquals(ForwardingDirection.BIDIRECTIONAL, link.getDirection(),
1195 "otn tapi link should be BIDIRECTIONAL");
1196 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1197 .link.NodeEdgePoint> nodeEdgePointList = new ArrayList<>(link.nonnullNodeEdgePoint().values());
1198 assertEquals(2 , nodeEdgePointList.size(), "oms link should be between 2 neps");
1199 assertEquals(topologyUuid, nodeEdgePointList.get(0).getTopologyUuid(),
1200 "topology uuid should be the same for the two termination point of the link");
1201 assertEquals(topologyUuid, nodeEdgePointList.get(1).getTopologyUuid(),
1202 "topology uuid should be the same for the two termination point of the link");
1203 assertThat("oms links should terminate on two distinct nodes",
1204 nodeEdgePointList.get(0).getNodeUuid().getValue(),
1205 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1206 assertThat("oms links should terminate on two distinct nodes",
1207 nodeEdgePointList.get(1).getNodeUuid().getValue(),
1208 either(containsString(node1Uuid.getValue())).or(containsString(node2Uuid.getValue())));
1209 assertThat("oms links should terminate on two distinct tps",
1210 nodeEdgePointList.get(0).getNodeEdgePointUuid().getValue(),
1211 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1212 assertThat("oms links should terminate on two distinct tps",
1213 nodeEdgePointList.get(1).getNodeEdgePointUuid().getValue(),
1214 either(containsString(tp1Uuid.getValue())).or(containsString(tp2Uuid.getValue())));
1217 private Node changeTerminationPointState(Node initialNode, String tpid, String tpid1, AdminStates admin,
1219 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder tpdr1Bldr
1220 = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder(
1221 initialNode.augmentation(Node1.class));
1222 Map<TerminationPointKey, TerminationPoint> tps = new HashMap<>(tpdr1Bldr.getTerminationPoint());
1223 TerminationPointBuilder tpBldr = new TerminationPointBuilder(
1224 tps.get(new TerminationPointKey(new TpId(tpid))));
1225 tpBldr.addAugmentation(new TerminationPoint1Builder(tpBldr.augmentation(TerminationPoint1.class))
1226 .setAdministrativeState(admin)
1227 .setOperationalState(oper)
1229 tps.replace(tpBldr.key(), tpBldr.build());
1230 TerminationPointBuilder tpBldr1 = new TerminationPointBuilder(
1231 tps.get(new TerminationPointKey(new TpId(tpid1))));
1232 tpBldr1.addAugmentation(new TerminationPoint1Builder(tpBldr1.augmentation(TerminationPoint1.class))
1233 .setAdministrativeState(admin)
1234 .setOperationalState(oper)
1236 tps.replace(tpBldr1.key(), tpBldr1.build());
1237 tpdr1Bldr.setTerminationPoint(tps);
1238 return new NodeBuilder(initialNode).addAugmentation(tpdr1Bldr.build()).build();
1241 private int getRank(String searchedChar, List<OwnedNodeEdgePoint> onepList) {
1242 int foundAtRank = 0;
1244 for (OwnedNodeEdgePoint onep: onepList) {
1245 for (Map.Entry<NameKey, Name> entry: onep.getName().entrySet()) {
1246 if (entry.getValue().getValue().contains(searchedChar)) {
1252 LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);
1256 private int getNodeRank(String searchedChar,
1257 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodeList) {
1258 int foundAtRank = 0;
1260 for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node: nodeList) {
1261 for (Map.Entry<NameKey, Name> entry: node.getName().entrySet()) {
1262 if (entry.getValue().getValue().contains(searchedChar)) {
1268 LOG.info("searched Char {} found at rank {}", searchedChar, foundAtRank);