2 * Copyright © 2018 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.gnpy;
11 import java.math.BigDecimal;
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.List;
16 import java.util.concurrent.ExecutionException;
17 import java.util.stream.IntStream;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
21 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
22 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
23 import org.opendaylight.transportpce.common.NetworkUtils;
24 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
25 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
26 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
27 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.OperationalBuilder;
28 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Edfa;
29 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.EdfaBuilder;
30 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.FiberRoadmBuilder;
31 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Transceiver;
32 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.TransceiverBuilder;
33 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.Params;
34 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.ParamsBuilder;
35 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Fiber;
36 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.FiberBuilder;
37 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Roadm;
38 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.RoadmBuilder;
39 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.Location;
40 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.LocationBuilder;
41 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Connections;
42 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ConnectionsBuilder;
43 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Elements;
44 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ElementsBuilder;
45 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.Metadata;
46 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.MetadataBuilder;
47 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.RouteIncludeEro;
48 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeHopType;
49 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeNodeId;
50 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TePathDisjointness;
51 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeTpId;
52 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidth;
53 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidthBuilder;
54 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.Type;
55 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.NumUnnumHopBuilder;
56 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num.unnum.hop.NumUnnumHop;
57 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraints;
58 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraintsBuilder;
59 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlot;
60 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlotBuilder;
61 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjects;
62 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjectsBuilder;
63 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExclude;
64 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeBuilder;
65 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequest;
66 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequestBuilder;
67 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.Synchronization;
68 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.SynchronizationBuilder;
69 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.Svec;
70 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.SvecBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.rev181130.Node1;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.OMSAttributes;
79 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
80 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA;
83 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
84 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
85 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
86 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
87 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
88 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
89 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
90 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
91 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
92 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
93 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
94 import org.slf4j.Logger;
95 import org.slf4j.LoggerFactory;
98 * Class to create the topology corresponding to GNPy requirements.
100 * @author Ahmed Triki ( ahmed.triki@orange.com )
104 public class ExtractTopoDataStoreImpl {
105 private static final Logger LOG = LoggerFactory.getLogger(ExtractTopoDataStoreImpl.class);
106 private final DataBroker dataBroker;
107 private List<Elements> elements = new ArrayList<>();
108 private List<Connections> connections = new ArrayList<>();
109 private List<PathRequest> pathRequest = new ArrayList<>();
110 private List<Synchronization> synchronization = new ArrayList<>();
111 private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
112 private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
113 private Map<String, String> mapLinkFiber = new HashMap<String, String>();
114 private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
115 private static int convertKmM = 1000;
118 * Construct the ExtractTopoDataStoreImpl.
120 @SuppressWarnings("unchecked")
121 public ExtractTopoDataStoreImpl(final DataBroker dataBroker, PathComputationRequestInput input, AToZDirection atoz,
123 this.dataBroker = dataBroker;
124 Map<String, List<?>> map = extractTopo();
125 if (map.containsKey("Elements")) {
126 elements = (List<Elements>) map.get("Elements");
130 if (map.containsKey("Elements")) {
131 connections = (List<Connections>) map.get("Connections");
135 pathRequest = extractPathRequest(input, atoz, requestId);
136 synchronization = extractSynchronization(requestId);
139 public ExtractTopoDataStoreImpl(final DataBroker dataBroker, PathComputationRequestInput input, ZToADirection ztoa,
141 this.dataBroker = dataBroker;
142 Map<String, List<?>> map = extractTopo();
143 if (map.containsKey("Elements")) {
144 elements = (List<Elements>) map.get("Elements");
148 if (map.containsKey("Elements")) {
149 connections = (List<Connections>) map.get("Connections");
153 pathRequest = extractPathRequest(input, ztoa, requestId);
154 synchronization = extractSynchronization(requestId);
158 * extract the topology: all the elements have ipAddress as uid and maintain
159 * a mapping structure to map between the nodeId and the ipAddress (uid)
162 public Map<String, List<?>> extractTopo() {
163 Map<String, List<?>> map = new HashMap<String, List<?>>();
164 // Define the elements
165 List<Elements> topoElements = new ArrayList<>();
166 // Define the connections
167 List<Connections> topoConnections = new ArrayList<>();
168 // Define the instance identifier of the OpenRoadm topology
169 InstanceIdentifier<Network> insIdOpenRoadmTopo = InstanceIdentifier
170 .builder(Networks.class)
171 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
172 // Define the instance identifier of the OpenRoadm network
173 InstanceIdentifier<Network> insIdrOpenRoadmNet = InstanceIdentifier
174 .builder(Networks.class)
175 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))).build();
176 ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
177 // Read the data broker
179 // Initialize the reading of the data broker
180 // read the configuration part of the data broker that concerns
181 // the openRoadm topology and get all the nodes
182 java.util.Optional<Network> openRoadmTopo = readOnlyTransaction
183 .read(LogicalDatastoreType.CONFIGURATION, insIdOpenRoadmTopo).get().toJavaUtil();
184 java.util.Optional<Network> openRoadmNet = readOnlyTransaction
185 .read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get().toJavaUtil();
186 if (openRoadmNet.isPresent()) {
187 List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
188 if (openRoadmTopo.isPresent()) {
189 List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
190 List<String> nodesList = new ArrayList<>();
191 // Create the list of nodes
192 if (!openRoadmTopoNodeList.isEmpty()) {
194 for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
195 // Retrieve the supporting node and the type of the
196 // node in openRoadm network
197 List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
198 for (SupportingNode supportingNode : supportingNodeList) {
199 String nodeRef = supportingNode.getNodeRef().getValue();
200 IpAddress ipAddress = null;
201 // Retrieve the mapping between the openRoadm
202 // topology and openRoadm network
203 mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
204 Node1 openRoadmNetNode1 = null;
205 for (Node openRoadmNetNode : openRoadmNetNodeList) {
206 if (openRoadmNetNode.getNodeId().getValue().equals(nodeRef)) {
207 openRoadmNetNode1 = openRoadmNetNode.augmentation(Node1.class);
208 ipAddress = openRoadmNetNode1.getIp();
209 mapNodeRefIp.put(nodeRef, ipAddress);
213 if (openRoadmNetNode1.getNodeType().getName().equals("ROADM")) {
214 if (!nodesList.contains(nodeRef)) {
215 Elements element = addElementsRoadm(2, 0, nodeRef, openRoadmNetNode1.getShelf(),
216 -20, ipAddress.getIpv4Address().getValue().toString());
217 topoElements.add(element);
218 nodesList.add(nodeRef);
220 } else if (openRoadmNetNode1.getNodeType().getName().equals("XPONDER")) {
221 if (!nodesList.contains(nodeRef)) {
222 Elements element = addElementsTransceiver(2, 0, nodeRef,
223 openRoadmNetNode1.getShelf(),
224 ipAddress.getIpv4Address().getValue().toString());
225 topoElements.add(element);
226 nodesList.add(nodeRef);
229 LOG.warn("the type is not implemented");
234 LOG.warn("no nodes in the network");
237 // Create the list of connections
238 Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
239 List<Link> linksList = nw1.getLink();
240 // 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
241 // 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
242 int[] externalLink = {4,5,6};
245 if (!linksList.isEmpty()) {
246 LOG.warn("The link list is not empty");
247 for (Link link : linksList) {
248 Link1 link1 = link.augmentation(Link1.class);
249 int linkType = link1.getLinkType().getIntValue();
250 if (IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
251 // Verify if the node is a ROADM
252 String srcId = mapDisgNodeRefNode.get(link.getSource().getSourceNode().getValue());
253 IpAddress srcIp = mapNodeRefIp.get(srcId);
254 String destId = null;
255 IpAddress destIp = null;
256 // Add the links between amplifiers
257 OMSAttributes omsAttributes = link1.getOMSAttributes();
258 if (omsAttributes != null) {
259 if (omsAttributes.getAmplifiedLink() != null) {
260 List<AmplifiedLink> amplifiedLinkList = omsAttributes.getAmplifiedLink()
262 if (!amplifiedLinkList.isEmpty()) {
263 for (AmplifiedLink amplifiedLink : amplifiedLinkList) {
264 Elements element1 = null;
265 if (amplifiedLink.getSectionElement()
266 .getSectionElement() instanceof Ila) {
267 Ila ila = (Ila) amplifiedLink.getSectionElement()
268 .getSectionElement();
269 String nodeId = ila.getNodeId().getValue();
270 IpAddress ipEdfa = new IpAddress(
271 new Ipv4Address("1.1.1." + nbEDFA));
273 mapDisgNodeRefNode.put(nodeId, nodeId);
274 mapNodeRefIp.put(nodeId, ipEdfa);
275 element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
276 ila.getGain().getValue(), ila.getTilt().getValue(),
277 ila.getOutVoaAtt().getValue(), "std_medium_gain",
278 ipEdfa.getIpv4Address().getValue().toString());
279 } else if (amplifiedLink.getSectionElement()
280 .getSectionElement() instanceof Span) {
281 // Create the location
282 Span span = (Span) amplifiedLink.getSectionElement()
283 .getSectionElement();
284 String clfi = span.getSpan().getClfi();
285 IpAddress ipFiber = new IpAddress(
286 new Ipv4Address("2.2.2." + idFiber));
287 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
288 mapFiberIp.put(clfi, ipFiber);
290 element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
291 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
294 if (element1 != null) {
295 topoElements.add(element1);
296 destId = element1.getUid();
299 if (srcId != destId) {
300 Connections connection = createNewConnection(srcId, srcIp,
302 topoConnections.add(connection);
309 } else if (omsAttributes.getSpan() != null) {
310 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
311 .networks.network.link.oms.attributes.@Nullable Span span
312 = omsAttributes.getSpan();
314 String clfi = span.getClfi();
315 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
316 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
317 mapFiberIp.put(clfi, ipFiber);
320 double attIn = span.getSpanlossCurrent().getValue().doubleValue();
321 double lossCoef = 0.2;
324 String typeVariety = "SSMF";
327 // Compute the length of the link
328 List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
329 for (LinkConcatenation linkConcatenation : linkConcatenationList) {
330 double srlgLength = linkConcatenation.getSRLGLength();
331 //convert to kilometer
332 length += srlgLength / convertKmM;
335 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
336 ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn,
337 connOut, typeVariety);
339 topoElements.add(element1);
341 destId = element1.getUid();
343 if (srcId != destId) {
344 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
345 topoConnections.add(connection);
351 String clfi = "Fiber" + idFiber;
352 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
353 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
354 mapFiberIp.put(clfi, ipFiber);
356 // Create a new element
357 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
358 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
359 topoElements.add(element1);
361 destId = element1.getUid();
363 if (srcId != destId) {
364 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
365 topoConnections.add(connection);
371 LOG.warn("The oms attributes is null!");
374 destId = mapDisgNodeRefNode.get(link.getDestination().getDestNode().getValue());
375 destIp = mapNodeRefIp.get(destId);
376 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
377 topoConnections.add(connection);
381 LOG.warn("no links in the network");
384 LOG.warn("No nodes in the selected network ...");
387 } catch (InterruptedException | ExecutionException e) {
388 LOG.error("Error reading the topology", e);
389 readOnlyTransaction.close();
391 readOnlyTransaction.close();
392 map.put("Elements", topoElements);
393 map.put("Connections", topoConnections);
398 * Create the pathRequest
400 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, AToZDirection atoz, Long requestId) {
402 List<AToZ> listAtoZ = atoz.getAToZ();
403 int atozSize = listAtoZ.size();
404 // Create the path request
405 List<PathRequest> pathRequestList = new ArrayList<>();
407 // 1.1 Create explicitRouteObjects
408 // 1.1.1. create RouteObjectIncludeExclude list
409 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
410 IpAddress ipAddressCurrent = null;
411 Long index = (long) 0;
412 for (int i = 0; i < atozSize; i++) {
413 String nodeId = null;
414 if (listAtoZ.get(i).getResource()
415 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
416 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
417 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
418 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
419 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listAtoZ
420 .get(i).getResource().getResource();
421 nodeId = node.getNodeId();
422 if (nodeId != null) {
423 String nodeRef = mapDisgNodeRefNode.get(nodeId);
424 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
425 for (Elements element : elements) {
426 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
427 if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
428 ipAddressCurrent = ipAddress;
429 // Fill in routeObjectIncludeExcludes
430 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
431 ipAddress, 1, index);
432 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
439 LOG.warn("node ID is null");
441 //TODO else if termination point not implemented in this version
442 } else if (listAtoZ.get(i).getResource()
443 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
444 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
445 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
446 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
447 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listAtoZ
448 .get(i).getResource().getResource();
449 String clfi = mapLinkFiber.get(link.getLinkId());
450 IpAddress fiberIp = mapFiberIp.get(clfi);
452 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
454 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
459 // Create ExplicitRouteObjects
460 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
461 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
463 // 1. Create the path request element 1
465 String sourceNode = input.getServiceAEnd().getNodeId();
466 String destNode = input.getServiceZEnd().getNodeId();
468 // 1.2 Create a path constraints
469 Long rate = atoz.getRate();
470 // Create EffectiveFreqSlot
471 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
472 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
473 effectiveFreqSlot.add(effectiveFreqSlot1);
474 // Create Te-Bandwidth
475 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
476 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
477 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
478 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
479 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
480 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
481 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
482 .setExplicitRouteObjects(explicitRouteObjects).build();
483 pathRequestList.add(pathRequest1);
484 return pathRequestList;
487 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, ZToADirection ztoa, Long requestId) {
489 List<ZToA> listZToA = ztoa.getZToA();
490 int ztoaSize = listZToA.size();
491 // Create the path request
492 List<PathRequest> servicePathRequest = new ArrayList<>();
494 // 1.1 Create explicitRouteObjects
495 // 1.1.1. create RouteObjectIncludeExclude list
496 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
497 IpAddress ipAddressCurrent = null;
498 Long index = (long) 0;
499 for (int i = 0; i < ztoaSize; i++) {
500 String nodeId = null;
501 if (listZToA.get(i).getResource()
502 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
503 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
504 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
505 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
506 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listZToA.get(i)
507 .getResource().getResource();
508 nodeId = node.getNodeId();
509 if (nodeId != null) {
510 String nodeRef = mapDisgNodeRefNode.get(nodeId);
511 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
512 for (Elements element : elements) {
513 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
514 if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
515 ipAddressCurrent = ipAddress;
516 // Fill in routeObjectIncludeExcludes
517 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
518 ipAddress, 1, index);
519 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
526 LOG.warn("node ID is null");
528 //TODO else if termination point not implemented in this version
529 } else if (listZToA.get(i).getResource()
530 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
531 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
532 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
533 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
534 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listZToA.get(i)
535 .getResource().getResource();
536 String clfi = mapLinkFiber.get(link.getLinkId());
537 IpAddress fiberIp = mapFiberIp.get(clfi);
539 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
541 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
546 // Create ExplicitRouteObjects
547 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
548 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
550 // 1. Create the path request element 1
552 String sourceNode = input.getServiceZEnd().getNodeId();
553 String destNode = input.getServiceAEnd().getNodeId();
555 // 1.2 Create a path constraints
556 Long rate = ztoa.getRate();
557 // Create EffectiveFreqSlot
558 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
559 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
560 effectiveFreqSlot.add(effectiveFreqSlot1);
561 // Create Te-Bandwidth
562 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
563 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
564 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
565 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
566 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
567 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
568 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
569 .setExplicitRouteObjects(explicitRouteObjects).build();
570 servicePathRequest.add(pathRequest1);
571 return servicePathRequest;
575 * Create the synchronization
577 public List<Synchronization> extractSynchronization(Long requestId) {
578 // Create RequestIdNumber
579 List<Long> requestIdNumber = new ArrayList<>();
580 requestIdNumber.add(0, new Long(0));
581 // Create a synchronization
582 Svec svec = new SvecBuilder().setRelaxable(true).setDisjointness(new TePathDisjointness(true, true, false))
583 .setRequestIdNumber(requestIdNumber).build();
584 List<Synchronization> synchro = new ArrayList<>();
585 Synchronization synchronization1 = new SynchronizationBuilder().setSynchronizationId(new Long(0)).setSvec(svec)
587 synchro.add(synchronization1);
592 * Method to add Fiber
594 private Elements addElementsFiber(double latitude, double longitude, String region, String city, String clfi,
595 double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
596 // Create an amplifier after the roadm
597 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
598 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
599 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
601 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
602 Fiber fiber = new FiberBuilder().setLength(new BigDecimal(length)).setLengthUnits(Km.class)
603 .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
604 .setConOut(new BigDecimal(connOut)).build();
605 Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
606 Elements element1 = new ElementsBuilder().setUid(clfi)
607 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
608 .setTypeVariety(typeVariety).setMetadata(metadata1)
609 .setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
616 private Elements addElementsEdfa(double latitude, double longitude, String region, String city,
617 BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
618 // Create an amplifier after the roadm
619 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
620 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
621 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
623 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
624 Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
625 .setOutVoa(outVoa).build();
626 Edfa edfa = new EdfaBuilder()
627 .setOperational(operational).build();
628 Elements element1 = new ElementsBuilder().setUid(uidEdfa)
629 // Choose an ip address
630 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
631 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
636 * Method to add ROADM
638 private Elements addElementsRoadm(double latitude, double longitude, String region, String city,
639 double targetPchOutDb, String uidRoadm) {
641 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
642 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
643 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
645 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
647 Roadm roadm = new RoadmBuilder().setTargetPchOutDb(new BigDecimal(targetPchOutDb)).build();
648 Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
649 Elements element1 = new ElementsBuilder().setUid(uidRoadm)
650 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
651 .setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
656 * Method to add Transceiver
658 private Elements addElementsTransceiver(double latitude, double longitude, String region, String city,
660 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
661 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
662 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
664 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
665 Transceiver transceiver = new TransceiverBuilder().build();
666 Elements element1 = new ElementsBuilder().setUid(uidTrans)
667 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
668 .setMetadata(metadata1).setElementType(transceiver).build();
673 * Add routeObjectIncludeExclude
675 private RouteObjectIncludeExclude addRouteObjectIncludeExclude(IpAddress ipAddress, long teTpValue, long index) {
676 TeNodeId teNodeId = new TeNodeId(ipAddress);
677 TeTpId teTpId = new TeTpId(teTpValue);
678 NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num
679 .unnum.hop.NumUnnumHopBuilder()
680 .setNodeId(teNodeId.getIpv4Address().getValue().toString()).setLinkTpId(teTpId.getUint32().toString())
681 .setHopType(TeHopType.STRICT).build();
682 Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
683 // Create routeObjectIncludeExclude element 1
684 RouteObjectIncludeExclude routeObjectIncludeExclude1 = new RouteObjectIncludeExcludeBuilder().setIndex(index)
685 .setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
686 return routeObjectIncludeExclude1;
689 private Connections createNewConnection(String srcId, IpAddress srcIp, String destId, IpAddress destIp) {
690 String fromNode = srcId;
691 String toNode = destId;
693 fromNode = srcIp.getIpv4Address().getValue().toString();
695 if (destIp != null) {
696 toNode = destIp.getIpv4Address().getValue().toString();
698 Connections connection1 = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
699 return (connection1);
702 public List<Elements> getElements() {
706 public void setElements(List<Elements> elements) {
707 this.elements = elements;
710 public List<Connections> getConnections() {
714 public void setConnections(List<Connections> connections) {
715 this.connections = connections;
718 public List<PathRequest> getPathRequest() {
722 public void setPathRequest(List<PathRequest> pathRequest) {
723 this.pathRequest = pathRequest;
726 public List<Synchronization> getSynchronization() {
727 return synchronization;
730 public void setSynchronization(List<Synchronization> synchronization) {
731 this.synchronization = synchronization;
734 public List<PathRequest> createEmptyPathRequest(PathComputationRequestInput input, AToZDirection atoz) {
735 // Create the path request
736 List<PathRequest> pathRequestList = new ArrayList<>();
738 // 1. Create the path request element 1
740 String sourceNode = input.getServiceAEnd().getNodeId();
741 String destNode = input.getServiceZEnd().getNodeId();
743 // 1.2 Create a path constraints
744 Long rate = atoz.getRate();
746 // Create EffectiveFreqSlot
747 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
748 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
749 effectiveFreqSlot.add(effectiveFreqSlot1);
751 // Create Te-Bandwidth
752 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
753 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
754 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
755 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
756 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(new Long(0))
757 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
758 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
760 pathRequestList.add(pathRequest1);
761 return pathRequestList;