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
9 package org.opendaylight.transportpce.pce.utils;
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
15 import org.opendaylight.transportpce.common.NetworkUtils;
16 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1Builder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.link.OMSAttributesBuilder;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.link.oms.attributes.SpanBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.DegreeAttributes;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.DegreeAttributesBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.SrgAttributes;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.SrgAttributesBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.CpAttributesBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.CtpAttributesBuilder;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.PpAttributesBuilder;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.RxTtpAttributesBuilder;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.TxTtpAttributesBuilder;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.XpdrClientAttributesBuilder;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.XpdrNetworkAttributesBuilder;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.networks.network.node.termination.point.XpdrPortAttributesBuilder;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmLinkType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.OpenroadmTpType;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.termination.point.TpSupportedInterfaces;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.termination.point.TpSupportedInterfacesBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.networks.network.node.termination.point.XpdrTpPortConnectionAttributesBuilder;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GEODU4;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If10GEODU2e;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If1GEODU0;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4;
48 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
49 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
50 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeBuilder;
51 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.NodeKey;
52 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
53 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNodeBuilder;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNodeKey;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1Builder;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkBuilder;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.link.DestinationBuilder;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.link.SourceBuilder;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
64 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointBuilder;
65 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPointKey;
66 import org.opendaylight.yangtools.yang.binding.Augmentation;
67 import org.opendaylight.yangtools.yang.common.Uint32;
69 public final class NodeUtils {
71 private static final String LINK_ID_FORMAT = "%1$s-%2$sto%3$s-%4$s";
73 public static LinkBuilder createLinkBuilder(
74 String srcNode, String destNode, String srcTp, String destTp, Link1Builder link1Builder) {
75 SourceBuilder ietfSrcLinkBldr =
76 new SourceBuilder().setSourceNode(new NodeId(srcNode)).setSourceTp(new TpId(srcTp));
77 //create destination link
78 DestinationBuilder ietfDestLinkBldr =
79 new DestinationBuilder().setDestNode(new NodeId(destNode)).setDestTp(new TpId(destTp));
80 LinkId linkId = new LinkId(String.format(LINK_ID_FORMAT, srcNode, srcTp, destNode, destTp));
82 LinkId oppositeLinkId = new LinkId("OpenROADM-3-2-DEG1-to-OpenROADM-3-1-DEG1");
84 Augmentation<Link> aug11 = new org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210
87 .setOMSAttributes(new OMSAttributesBuilder()
88 .setSpan(new SpanBuilder().build())
91 return new LinkBuilder()
92 .setSource(ietfSrcLinkBldr.build())
93 .setDestination(ietfDestLinkBldr.build())
95 .addAugmentation(aug11)
96 .withKey(new LinkKey(linkId))
97 .addAugmentation(link1Builder.setOppositeLink(oppositeLinkId).build());
100 public static LinkBuilder createRoadmToRoadm(String srcNode, String destNode, String srcTp, String destTp) {
101 Link1Builder link1Builder = new Link1Builder()
102 .setLinkLatency(Uint32.valueOf(30))
103 .setLinkType(OpenroadmLinkType.ROADMTOROADM)
104 .setAdministrativeState(AdminStates.InService)
105 .setOperationalState(State.InService);
106 return createLinkBuilder(srcNode, destNode, srcTp, destTp, link1Builder);
110 public static Map<SupportingNodeKey, SupportingNode> geSupportingNodes() {
111 Map<SupportingNodeKey, SupportingNode> supportingNodes1 = new HashMap<>();
112 SupportingNode supportingNode1 = new SupportingNodeBuilder()
113 .setNodeRef(new NodeId("node 1"))
114 .setNetworkRef(new NetworkId(NetworkUtils.CLLI_NETWORK_ID))
117 .put(supportingNode1.key(),supportingNode1);
119 SupportingNode supportingNode2 = new SupportingNodeBuilder()
120 .setNodeRef(new NodeId("node 2"))
121 .setNetworkRef(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))
124 .put(supportingNode2.key(),supportingNode2);
125 return supportingNodes1;
128 public static NodeBuilder getNodeBuilder(Map<SupportingNodeKey,SupportingNode> supportingNodes1) {
132 TerminationPointBuilder xpdrTpBldr = new TerminationPointBuilder()
133 .withKey(new TerminationPointKey(new TpId("xpdr")));
134 TerminationPoint1Builder tp1Bldr = new TerminationPoint1Builder();
135 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder tp11Bldr =
136 new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder()
137 .setAdministrativeState(AdminStates.InService)
138 .setOperationalState(State.InService);
140 tp1Bldr.setTpType(OpenroadmTpType.XPONDERNETWORK);
141 xpdrTpBldr.addAugmentation(tp1Bldr.build());
142 xpdrTpBldr.addAugmentation(tp11Bldr.build());
143 TerminationPoint xpdr = xpdrTpBldr.build();
144 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1 =
145 new Node1Builder().setTerminationPoint(Map.of(xpdr.key(),xpdr)).build();
146 Node1 node11 = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Node1Builder()
147 .setAdministrativeState(AdminStates.InService)
148 .setOperationalState(State.InService).build();
149 return new NodeBuilder()
150 .setNodeId(new NodeId("node 1"))
151 .withKey(new NodeKey(new NodeId("node 1")))
152 .addAugmentation(node1)
153 .addAugmentation(node11)
154 .setSupportingNode(supportingNodes1);
159 public static List<SupportingNode> getOTNSupportingNodes() {
160 List<SupportingNode> supportingNodes1 = new ArrayList<>();
162 .add(new SupportingNodeBuilder()
163 .setNodeRef(new NodeId("node 1"))
164 .setNetworkRef(new NetworkId(NetworkUtils.CLLI_NETWORK_ID))
168 .add(new SupportingNodeBuilder()
169 .setNodeRef(new NodeId("node 2"))
170 .setNetworkRef(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))
172 return supportingNodes1;
175 public static NodeBuilder getOTNNodeBuilder(Map<SupportingNodeKey,SupportingNode> supportingNodes1,
176 OpenroadmTpType openroadmTpType) {
178 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder
179 tp1Bldr = getTerminationPoint1Builder(openroadmTpType);
180 TerminationPointBuilder xpdrTpBldr = getTerminationPointBuilder(openroadmTpType);
182 .addAugmentation(tp1Bldr.build());
184 xpdrTpBldr.addAugmentation(createAnother2TerminationPoint(openroadmTpType).build());
185 xpdrTpBldr.addAugmentation(createAnotherTerminationPoint(openroadmTpType).build());
187 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1 node1 = getNode1();
188 TerminationPoint xpdr = xpdrTpBldr.build();
189 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1Rev180226 =
191 .setTerminationPoint(Map.of(xpdr.key(),xpdr))
195 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 nodeIetf =
196 new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
198 .setTerminationPoint(Map.of(xpdr.key(),xpdr))
201 return new NodeBuilder()
202 .setNodeId(new NodeId("node_test"))
203 .withKey(new NodeKey(new NodeId("node 1")))
204 .addAugmentation(node1Rev180226)
205 .addAugmentation(node1)
206 .addAugmentation(nodeIetf)
207 .setSupportingNode(supportingNodes1);
210 public static NodeBuilder getOTNNodeBuilderEmpty(Map<SupportingNodeKey,SupportingNode> supportingNodes1,
211 OpenroadmTpType openroadmTpType) {
213 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder tp1Bldr =
214 getTerminationPoint1Builder(openroadmTpType);
215 TerminationPointBuilder xpdrTpBldr = getTerminationPointBuilder(openroadmTpType);
216 xpdrTpBldr.addAugmentation(tp1Bldr.build());
217 xpdrTpBldr.addAugmentation(createAnotherTerminationPoint(openroadmTpType).build());
219 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1 node1 = getNode1Empty();
220 TerminationPoint xpdr = xpdrTpBldr.build();
221 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 node1Rev180226 =
223 .setTerminationPoint(Map.of(xpdr.key(),xpdr))
225 return new NodeBuilder()
226 .setNodeId(new NodeId("node_test"))
227 .withKey(new NodeKey(new NodeId("node 1")))
228 .addAugmentation(node1Rev180226)
229 .addAugmentation(node1)
230 .setSupportingNode(supportingNodes1);
233 private static org.opendaylight
234 .yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1 getNode1() {
235 return new org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1Builder()
236 .setSrgAttributes(getSrgAttributes())
237 .setDegreeAttributes(getDegAttributes())
241 private static org.opendaylight
242 .yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1 getNode1Empty() {
243 return new org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1Builder()
244 .setSrgAttributes(getEmptySrgAttributes())
245 .setDegreeAttributes(getEmptyDegAttributes())
249 private static DegreeAttributes getDegAttributes() {
250 return (new DegreeAttributesBuilder())
251 .setAvailFreqMaps(GridUtils.initFreqMaps4FixedGrid2Available())
255 private static SrgAttributes getSrgAttributes() {
256 return new SrgAttributesBuilder().setAvailFreqMaps(GridUtils.initFreqMaps4FixedGrid2Available()).build();
259 private static DegreeAttributes getEmptyDegAttributes() {
260 return (new DegreeAttributesBuilder())
261 .setAvailFreqMaps(Map.of())
265 private static SrgAttributes getEmptySrgAttributes() {
266 return new SrgAttributesBuilder().setAvailFreqMaps(Map.of()).build();
269 private static TerminationPointBuilder getTerminationPointBuilder(OpenroadmTpType openroadmTpType) {
270 return new TerminationPointBuilder()
271 .setTpId(new TpId("2"))
272 .addAugmentation(createOTNTerminationPoint(openroadmTpType).build());
275 private static org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder
276 getTerminationPoint1Builder(OpenroadmTpType openroadmTpType) {
278 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.TerminationPoint1Builder()
279 .setTpType(openroadmTpType);
283 private static org.opendaylight.yang.gen
284 .v1.http.org.openroadm.network.topology.rev211210.TerminationPoint1Builder createAnotherTerminationPoint(
285 OpenroadmTpType openroadmTpType
287 return new org.opendaylight
288 .yang.gen.v1.http.org.openroadm.network.topology.rev211210.TerminationPoint1Builder()
289 .setCtpAttributes((new CtpAttributesBuilder()).build())
290 .setCpAttributes((new CpAttributesBuilder()).build())
291 .setTxTtpAttributes((new TxTtpAttributesBuilder()).setUsedWavelengths(Map.of()).build())
292 .setRxTtpAttributes((new RxTtpAttributesBuilder()).setUsedWavelengths(Map.of()).build())
293 .setPpAttributes((new PpAttributesBuilder()).setUsedWavelength(Map.of()).build())
294 .setXpdrClientAttributes((new XpdrClientAttributesBuilder()).build())
295 .setXpdrPortAttributes((new XpdrPortAttributesBuilder()).build())
296 .setXpdrNetworkAttributes(new XpdrNetworkAttributesBuilder()
297 .setTailEquipmentId("destNode" + "--" + "destTp").build());
300 private static org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
301 .TerminationPoint1Builder createOTNTerminationPoint(OpenroadmTpType openroadmTpType) {
303 SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder()
304 .setIfCapType(IfOCHOTU4ODU4.class)
307 SupportedInterfaceCapability supIfCapa1 = new SupportedInterfaceCapabilityBuilder()
308 .setIfCapType(If100GEODU4.class)
310 SupportedInterfaceCapability supIfCapa2 = new SupportedInterfaceCapabilityBuilder()
311 .setIfCapType(If10GEODU2e.class)
313 SupportedInterfaceCapability supIfCapa3 = new SupportedInterfaceCapabilityBuilder()
314 .setIfCapType(If1GEODU0.class)
317 Map<SupportedInterfaceCapabilityKey,SupportedInterfaceCapability> supIfCapaList = new HashMap<>();
318 supIfCapaList.put(supIfCapa.key(),supIfCapa);
319 supIfCapaList.put(supIfCapa1.key(),supIfCapa1);
320 supIfCapaList.put(supIfCapa2.key(),supIfCapa2);
321 supIfCapaList.put(supIfCapa3.key(),supIfCapa3);
323 TpSupportedInterfaces tpSupIf = new TpSupportedInterfacesBuilder()
324 .setSupportedInterfaceCapability(supIfCapaList)
327 XpdrTpPortConnectionAttributesBuilder xtpcaBldr = new XpdrTpPortConnectionAttributesBuilder();
329 return new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210
330 .TerminationPoint1Builder()
331 .setTpSupportedInterfaces(tpSupIf)
332 .setXpdrTpPortConnectionAttributes(xtpcaBldr.build());
335 private static org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210
336 .TerminationPoint1Builder createAnother2TerminationPoint(OpenroadmTpType openroadmTpType) {
337 return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210
338 .TerminationPoint1Builder()
339 .setOperationalState(State.InService)
340 .setAdministrativeState(AdminStates.InService)
341 .setTpType(openroadmTpType);
344 private NodeUtils() {
345 throw new IllegalStateException("Utility class");