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.mdsal.common.api.LogicalDatastoreType;
21 import org.opendaylight.transportpce.common.NetworkUtils;
22 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
23 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
24 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
25 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
26 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.OperationalBuilder;
27 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Edfa;
28 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.EdfaBuilder;
29 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.FiberRoadmBuilder;
30 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Transceiver;
31 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.TransceiverBuilder;
32 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.Params;
33 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.ParamsBuilder;
34 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Fiber;
35 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.FiberBuilder;
36 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Roadm;
37 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.RoadmBuilder;
38 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.Location;
39 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.LocationBuilder;
40 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Connections;
41 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ConnectionsBuilder;
42 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Elements;
43 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ElementsBuilder;
44 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.Metadata;
45 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.MetadataBuilder;
46 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.RouteIncludeEro;
47 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeHopType;
48 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeNodeId;
49 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TePathDisjointness;
50 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeTpId;
51 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidth;
52 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidthBuilder;
53 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.Type;
54 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.NumUnnumHopBuilder;
55 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num.unnum.hop.NumUnnumHop;
56 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraints;
57 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraintsBuilder;
58 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlot;
59 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlotBuilder;
60 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjects;
61 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjectsBuilder;
62 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExclude;
63 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeBuilder;
64 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequest;
65 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequestBuilder;
66 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.Synchronization;
67 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.SynchronizationBuilder;
68 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.Svec;
69 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.SvecBuilder;
70 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.rev181130.Node1;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.OMSAttributes;
78 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
79 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
80 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA;
82 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
83 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
84 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
85 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
86 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
87 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
88 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
89 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
90 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
91 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
92 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
93 import org.slf4j.Logger;
94 import org.slf4j.LoggerFactory;
97 * Class to create the topology corresponding to GNPy requirements.
99 * @author Ahmed Triki ( ahmed.triki@orange.com )
103 public class ExtractTopoDataStoreImpl {
104 private static final Logger LOG = LoggerFactory.getLogger(ExtractTopoDataStoreImpl.class);
105 private final NetworkTransactionService networkTransactionService;
106 private List<Elements> elements = new ArrayList<>();
107 private List<Connections> connections = new ArrayList<>();
108 private List<PathRequest> pathRequest = new ArrayList<>();
109 private List<Synchronization> synchronization = new ArrayList<>();
110 private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
111 private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
112 private Map<String, String> mapLinkFiber = new HashMap<String, String>();
113 private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
114 private static int convertKmM = 1000;
117 * Construct the ExtractTopoDataStoreImpl.
119 @SuppressWarnings("unchecked")
120 public ExtractTopoDataStoreImpl(final NetworkTransactionService networkTransactionService,
121 PathComputationRequestInput input,AToZDirection atoz, Long requestId) {
122 this.networkTransactionService = networkTransactionService;
123 Map<String, List<?>> map = extractTopo();
124 if (map.containsKey("Elements")) {
125 elements = (List<Elements>) map.get("Elements");
129 if (map.containsKey("Connections")) {
130 connections = (List<Connections>) map.get("Connections");
135 pathRequest = extractPathRequest(input, atoz, requestId);
136 synchronization = extractSynchronization(requestId);
139 public ExtractTopoDataStoreImpl(final NetworkTransactionService networkTransactionService,
140 PathComputationRequestInput input, ZToADirection ztoa, Long requestId) {
141 this.networkTransactionService = networkTransactionService;
142 Map<String, List<?>> map = extractTopo();
143 if (map.containsKey("Elements")) {
144 elements = (List<Elements>) map.get("Elements");
148 if (map.containsKey("Connections")) {
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 // Read the data broker
178 // Initialize the reading of the networkTransactionService
179 // read the configuration part of the data broker that concerns
180 // the openRoadm topology and get all the nodes
181 java.util.Optional<Network> openRoadmTopo = this.networkTransactionService
182 .read(LogicalDatastoreType.CONFIGURATION, insIdOpenRoadmTopo).get();
183 java.util.Optional<Network> openRoadmNet = this.networkTransactionService
184 .read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get();
185 if (openRoadmNet.isPresent()) {
186 List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
187 if (openRoadmTopo.isPresent()) {
188 List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
189 List<String> nodesList = new ArrayList<>();
190 // Create the list of nodes
191 if (!openRoadmTopoNodeList.isEmpty()) {
193 for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
194 // Retrieve the supporting node and the type of the
195 // node in openRoadm network
196 List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
197 for (SupportingNode supportingNode : supportingNodeList) {
198 String nodeRef = supportingNode.getNodeRef().getValue();
199 IpAddress ipAddress = null;
200 // Retrieve the mapping between the openRoadm
201 // topology and openRoadm network
202 mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
203 Node1 openRoadmNetNode1 = null;
204 for (Node openRoadmNetNode : openRoadmNetNodeList) {
205 if (openRoadmNetNode.getNodeId().getValue().equals(nodeRef)) {
206 openRoadmNetNode1 = openRoadmNetNode.augmentation(Node1.class);
207 ipAddress = openRoadmNetNode1.getIp();
208 mapNodeRefIp.put(nodeRef, ipAddress);
212 if (openRoadmNetNode1.getNodeType().getName().equals("ROADM")) {
213 if (!nodesList.contains(nodeRef)) {
214 Elements element = addElementsRoadm(2, 0, nodeRef, openRoadmNetNode1.getShelf(),
215 -20, ipAddress.getIpv4Address().getValue().toString());
216 topoElements.add(element);
217 nodesList.add(nodeRef);
219 } else if (openRoadmNetNode1.getNodeType().getName().equals("XPONDER")) {
220 if (!nodesList.contains(nodeRef)) {
221 Elements element = addElementsTransceiver(2, 0, nodeRef,
222 openRoadmNetNode1.getShelf(),
223 ipAddress.getIpv4Address().getValue().toString());
224 topoElements.add(element);
225 nodesList.add(nodeRef);
228 LOG.warn("the type is not implemented");
233 LOG.warn("no nodes in the network");
236 // Create the list of connections
237 Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
238 List<Link> linksList = nw1.getLink();
239 // 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
240 // 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
241 int[] externalLink = {4,5,6};
244 if (!linksList.isEmpty()) {
245 LOG.debug("The link list is not empty");
246 for (Link link : linksList) {
247 Link1 link1 = link.augmentation(Link1.class);
248 int linkType = link1.getLinkType().getIntValue();
249 if (IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
250 // Verify if the node is a ROADM
251 String srcId = mapDisgNodeRefNode.get(link.getSource().getSourceNode().getValue());
252 IpAddress srcIp = mapNodeRefIp.get(srcId);
253 String destId = null;
254 IpAddress destIp = null;
255 // Add the links between amplifiers
256 OMSAttributes omsAttributes = link1.getOMSAttributes();
257 if (omsAttributes != null) {
258 if (omsAttributes.getAmplifiedLink() != null) {
259 List<AmplifiedLink> amplifiedLinkList = omsAttributes.getAmplifiedLink()
261 if (!amplifiedLinkList.isEmpty()) {
262 for (AmplifiedLink amplifiedLink : amplifiedLinkList) {
263 Elements element1 = null;
264 if (amplifiedLink.getSectionElement()
265 .getSectionElement() instanceof Ila) {
266 Ila ila = (Ila) amplifiedLink.getSectionElement()
267 .getSectionElement();
268 String nodeId = ila.getNodeId().getValue();
269 IpAddress ipEdfa = new IpAddress(
270 new Ipv4Address("1.1.1." + nbEDFA));
272 mapDisgNodeRefNode.put(nodeId, nodeId);
273 mapNodeRefIp.put(nodeId, ipEdfa);
274 element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
275 ila.getGain().getValue(), ila.getTilt().getValue(),
276 ila.getOutVoaAtt().getValue(), "std_medium_gain",
277 ipEdfa.getIpv4Address().getValue().toString());
278 } else if (amplifiedLink.getSectionElement()
279 .getSectionElement() instanceof Span) {
280 // Create the location
281 Span span = (Span) amplifiedLink.getSectionElement()
282 .getSectionElement();
283 String clfi = span.getSpan().getClfi();
284 IpAddress ipFiber = new IpAddress(
285 new Ipv4Address("2.2.2." + idFiber));
286 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
287 mapFiberIp.put(clfi, ipFiber);
289 element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
290 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
293 if (element1 != null) {
294 topoElements.add(element1);
295 destId = element1.getUid();
298 if (!destId.equals(srcId)) {
299 Connections connection = createNewConnection(srcId, srcIp,
301 topoConnections.add(connection);
308 } else if (omsAttributes.getSpan() != null) {
309 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
310 .networks.network.link.oms.attributes.@Nullable Span span
311 = omsAttributes.getSpan();
313 String clfi = span.getClfi();
314 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
315 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
316 mapFiberIp.put(clfi, ipFiber);
322 String typeVariety = "SSMF";
325 // Compute the length of the link
326 List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
327 for (LinkConcatenation linkConcatenation : linkConcatenationList) {
328 double srlgLength = linkConcatenation.getSRLGLength();
329 //convert to kilometer
330 length += srlgLength / convertKmM;
332 double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
334 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
335 ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn,
336 connOut, typeVariety);
338 topoElements.add(element1);
340 destId = element1.getUid();
342 if (!destId.equals(srcId)) {
343 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
344 topoConnections.add(connection);
350 String clfi = "Fiber" + idFiber;
351 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
352 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
353 mapFiberIp.put(clfi, ipFiber);
355 // Create a new element
356 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
357 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
358 topoElements.add(element1);
360 destId = element1.getUid();
362 if (!destId.equals(srcId)) {
363 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
364 topoConnections.add(connection);
370 LOG.warn("The oms attributes is null!");
373 destId = mapDisgNodeRefNode.get(link.getDestination().getDestNode().getValue());
374 destIp = mapNodeRefIp.get(destId);
375 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
376 topoConnections.add(connection);
380 LOG.warn("no links in the network");
383 LOG.warn("No nodes in the selected network ...");
386 } catch (InterruptedException | ExecutionException e) {
387 LOG.error("Error reading the topology", e);
388 this.networkTransactionService.close();
390 this.networkTransactionService.close();
391 map.put("Elements", topoElements);
392 map.put("Connections", topoConnections);
397 * Create the pathRequest
399 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, AToZDirection atoz, Long requestId) {
401 List<AToZ> listAtoZ = atoz.getAToZ();
402 int atozSize = listAtoZ.size();
403 // Create the path request
404 List<PathRequest> pathRequestList = new ArrayList<>();
406 // 1.1 Create explicitRouteObjects
407 // 1.1.1. create RouteObjectIncludeExclude list
408 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
409 IpAddress ipAddressCurrent = null;
410 Long index = (long) 0;
411 for (int i = 0; i < atozSize; i++) {
412 String nodeId = null;
413 if (listAtoZ.get(i).getResource()
414 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
415 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
416 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
417 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
418 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listAtoZ
419 .get(i).getResource().getResource();
420 nodeId = node.getNodeId();
421 if (nodeId != null) {
422 String nodeRef = mapDisgNodeRefNode.get(nodeId);
423 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
424 for (Elements element : elements) {
425 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
426 if ((ipAddressCurrent == null) || (!ipAddress.equals(ipAddressCurrent))) {
427 ipAddressCurrent = ipAddress;
428 // Fill in routeObjectIncludeExcludes
429 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
430 ipAddress, 1, index);
431 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
438 LOG.warn("node ID is null");
440 //TODO else if termination point not implemented in this version
441 } else if (listAtoZ.get(i).getResource()
442 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
443 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
444 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
445 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
446 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listAtoZ
447 .get(i).getResource().getResource();
448 String clfi = mapLinkFiber.get(link.getLinkId());
449 IpAddress fiberIp = mapFiberIp.get(clfi);
451 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
453 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
458 // Create ExplicitRouteObjects
459 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
460 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
462 // 1. Create the path request element 1
464 String sourceNode = input.getServiceAEnd().getNodeId();
465 String destNode = input.getServiceZEnd().getNodeId();
467 // 1.2 Create a path constraints
468 Long rate = atoz.getRate();
469 // Create EffectiveFreqSlot
470 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
471 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
472 effectiveFreqSlot.add(effectiveFreqSlot1);
473 // Create Te-Bandwidth
474 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
475 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
476 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
477 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
478 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
479 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
480 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
481 .setExplicitRouteObjects(explicitRouteObjects).build();
482 pathRequestList.add(pathRequest1);
483 return pathRequestList;
486 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, ZToADirection ztoa, Long requestId) {
488 List<ZToA> listZToA = ztoa.getZToA();
489 int ztoaSize = listZToA.size();
490 // Create the path request
491 List<PathRequest> servicePathRequest = new ArrayList<>();
493 // 1.1 Create explicitRouteObjects
494 // 1.1.1. create RouteObjectIncludeExclude list
495 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
496 IpAddress ipAddressCurrent = null;
497 Long index = (long) 0;
498 for (int i = 0; i < ztoaSize; i++) {
499 String nodeId = null;
500 if (listZToA.get(i).getResource()
501 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
502 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
503 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
504 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
505 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listZToA.get(i)
506 .getResource().getResource();
507 nodeId = node.getNodeId();
508 if (nodeId != null) {
509 String nodeRef = mapDisgNodeRefNode.get(nodeId);
510 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
511 for (Elements element : elements) {
512 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
513 if ((ipAddressCurrent == null) || (!ipAddress.equals(ipAddressCurrent))) {
514 ipAddressCurrent = ipAddress;
515 // Fill in routeObjectIncludeExcludes
516 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
517 ipAddress, 1, index);
518 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
525 LOG.warn("node ID is null");
527 //TODO else if termination point not implemented in this version
528 } else if (listZToA.get(i).getResource()
529 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
530 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
531 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
532 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
533 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listZToA.get(i)
534 .getResource().getResource();
535 String clfi = mapLinkFiber.get(link.getLinkId());
536 IpAddress fiberIp = mapFiberIp.get(clfi);
538 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
540 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
545 // Create ExplicitRouteObjects
546 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
547 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
549 // 1. Create the path request element 1
551 String sourceNode = input.getServiceZEnd().getNodeId();
552 String destNode = input.getServiceAEnd().getNodeId();
554 // 1.2 Create a path constraints
555 Long rate = ztoa.getRate();
556 // Create EffectiveFreqSlot
557 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
558 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
559 effectiveFreqSlot.add(effectiveFreqSlot1);
560 // Create Te-Bandwidth
561 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
562 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
563 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
564 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
565 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
566 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
567 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
568 .setExplicitRouteObjects(explicitRouteObjects).build();
569 servicePathRequest.add(pathRequest1);
570 return servicePathRequest;
574 * Create the synchronization
576 public List<Synchronization> extractSynchronization(Long requestId) {
577 // Create RequestIdNumber
578 List<Long> requestIdNumber = new ArrayList<>();
579 requestIdNumber.add(requestId);
580 // Create a synchronization
581 Svec svec = new SvecBuilder().setRelaxable(true).setDisjointness(new TePathDisjointness(true, true, false))
582 .setRequestIdNumber(requestIdNumber).build();
583 List<Synchronization> synchro = new ArrayList<>();
584 Synchronization synchronization1 = new SynchronizationBuilder().setSynchronizationId(new Long(0)).setSvec(svec)
586 synchro.add(synchronization1);
591 * Method to add Fiber
593 private Elements addElementsFiber(double latitude, double longitude, String region, String city, String clfi,
594 double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
595 // Create an amplifier after the roadm
596 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
597 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
598 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
600 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
601 Fiber fiber = new FiberBuilder().setLength(new BigDecimal(length)).setLengthUnits(Km.class)
602 .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
603 .setConOut(new BigDecimal(connOut)).build();
604 Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
605 Elements element1 = new ElementsBuilder().setUid(clfi)
606 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
607 .setTypeVariety(typeVariety).setMetadata(metadata1)
608 .setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
615 private Elements addElementsEdfa(double latitude, double longitude, String region, String city,
616 BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
617 // Create an amplifier after the roadm
618 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
619 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
620 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
622 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
623 Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
624 .setOutVoa(outVoa).build();
625 Edfa edfa = new EdfaBuilder()
626 .setOperational(operational).build();
627 Elements element1 = new ElementsBuilder().setUid(uidEdfa)
628 // Choose an ip address
629 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
630 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
635 * Method to add ROADM
637 private Elements addElementsRoadm(double latitude, double longitude, String region, String city,
638 double targetPchOutDb, String uidRoadm) {
640 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
641 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
642 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
644 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
646 Roadm roadm = new RoadmBuilder().setTargetPchOutDb(new BigDecimal(targetPchOutDb)).build();
647 Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
648 Elements element1 = new ElementsBuilder().setUid(uidRoadm)
649 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
650 .setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
655 * Method to add Transceiver
657 private Elements addElementsTransceiver(double latitude, double longitude, String region, String city,
659 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
660 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
661 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
663 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
664 Transceiver transceiver = new TransceiverBuilder().build();
665 Elements element1 = new ElementsBuilder().setUid(uidTrans)
666 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
667 .setMetadata(metadata1).setElementType(transceiver).build();
672 * Add routeObjectIncludeExclude
674 private RouteObjectIncludeExclude addRouteObjectIncludeExclude(IpAddress ipAddress, long teTpValue, long index) {
675 TeNodeId teNodeId = new TeNodeId(ipAddress);
676 TeTpId teTpId = new TeTpId(teTpValue);
677 NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num
678 .unnum.hop.NumUnnumHopBuilder()
679 .setNodeId(teNodeId.getIpv4Address().getValue().toString()).setLinkTpId(teTpId.getUint32().toString())
680 .setHopType(TeHopType.STRICT).build();
681 Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
682 // Create routeObjectIncludeExclude element 1
683 RouteObjectIncludeExclude routeObjectIncludeExclude1 = new RouteObjectIncludeExcludeBuilder().setIndex(index)
684 .setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
685 return routeObjectIncludeExclude1;
688 private Connections createNewConnection(String srcId, IpAddress srcIp, String destId, IpAddress destIp) {
689 String fromNode = srcId;
690 String toNode = destId;
692 fromNode = srcIp.getIpv4Address().getValue().toString();
694 if (destIp != null) {
695 toNode = destIp.getIpv4Address().getValue().toString();
697 Connections connection1 = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
698 return (connection1);
701 public List<Elements> getElements() {
705 public void setElements(List<Elements> elements) {
706 this.elements = elements;
709 public List<Connections> getConnections() {
713 public void setConnections(List<Connections> connections) {
714 this.connections = connections;
717 public List<PathRequest> getPathRequest() {
721 public void setPathRequest(List<PathRequest> pathRequest) {
722 this.pathRequest = pathRequest;
725 public List<Synchronization> getSynchronization() {
726 return synchronization;
729 public void setSynchronization(List<Synchronization> synchronization) {
730 this.synchronization = synchronization;
733 public List<PathRequest> createEmptyPathRequest(PathComputationRequestInput input, AToZDirection atoz) {
734 // Create the path request
735 List<PathRequest> pathRequestList = new ArrayList<>();
737 // 1. Create the path request element 1
739 String sourceNode = input.getServiceAEnd().getNodeId();
740 String destNode = input.getServiceZEnd().getNodeId();
742 // 1.2 Create a path constraints
743 Long rate = atoz.getRate();
745 // Create EffectiveFreqSlot
746 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
747 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
748 effectiveFreqSlot.add(effectiveFreqSlot1);
750 // Create Te-Bandwidth
751 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
752 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
753 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
754 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
755 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(new Long(0))
756 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
757 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
759 pathRequestList.add(pathRequest1);
760 return pathRequestList;