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.eqpt.config.rev181119.EdfaVariety;
25 //import org.opendaylight.yang.gen.v1.gnpy.gnpy.eqpt.config.rev181119.FiberVariety;
26 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
27 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
28 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
29 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.OperationalBuilder;
30 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Edfa;
31 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.EdfaBuilder;
32 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.FiberRoadmBuilder;
33 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Transceiver;
34 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.TransceiverBuilder;
35 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.Params;
36 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.ParamsBuilder;
37 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Fiber;
38 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.FiberBuilder;
39 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Roadm;
40 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.RoadmBuilder;
41 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.Location;
42 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.LocationBuilder;
43 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Connections;
44 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ConnectionsBuilder;
45 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Elements;
46 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ElementsBuilder;
47 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.Metadata;
48 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.MetadataBuilder;
49 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.RouteIncludeEro;
50 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeHopType;
51 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeNodeId;
52 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TePathDisjointness;
53 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.TeTpId;
54 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidth;
55 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.common.constraints_config.TeBandwidthBuilder;
56 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.Type;
57 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.NumUnnumHopBuilder;
58 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num.unnum.hop.NumUnnumHop;
59 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraints;
60 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.generic.path.constraints.PathConstraintsBuilder;
61 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlot;
62 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.gnpy.specific.parameters.EffectiveFreqSlotBuilder;
63 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjects;
64 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.ExplicitRouteObjectsBuilder;
65 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExclude;
66 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.path.route.objects.explicit.route.objects.RouteObjectIncludeExcludeBuilder;
67 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequest;
68 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.service.PathRequestBuilder;
69 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.Synchronization;
70 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.SynchronizationBuilder;
71 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.Svec;
72 import org.opendaylight.yang.gen.v1.gnpy.path.rev190502.synchronization.info.synchronization.SvecBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
78 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.rev181130.Node1;
79 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
80 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.OMSAttributes;
81 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
82 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
83 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
84 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA;
85 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
86 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
87 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
88 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
89 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
90 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
91 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
92 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
93 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
94 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
95 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
96 import org.slf4j.Logger;
97 import org.slf4j.LoggerFactory;
100 * Class to create the topology corresponding to GNPy requirements.
102 * @author Ahmed Triki ( ahmed.triki@orange.com )
106 public class ExtractTopoDataStoreImpl {
107 private static final Logger LOG = LoggerFactory.getLogger(ExtractTopoDataStoreImpl.class);
108 private final DataBroker dataBroker;
109 // private final OpenRoadmTopology openRoadmTopology;
110 // private final OpenRoadmInterfaces openRoadmInterfaces;
111 private List<Elements> elements = new ArrayList<>();
112 private List<Connections> connections = new ArrayList<>();
113 private List<PathRequest> pathRequest = new ArrayList<>();
114 private List<Synchronization> synchronization = new ArrayList<>();
115 private Map<String, String> mapDisgNodeRefNode = new HashMap<String, String>();
116 private Map<String, IpAddress> mapNodeRefIp = new HashMap<String, IpAddress>();
117 private Map<String, String> mapLinkFiber = new HashMap<String, String>();
118 private Map<String, IpAddress> mapFiberIp = new HashMap<String, IpAddress>();
119 private static int convertKmM = 1000;
122 * Construct the ExtractTopoDataStoreImpl.
124 @SuppressWarnings("unchecked")
125 public ExtractTopoDataStoreImpl(final DataBroker dataBroker, PathComputationRequestInput input, AToZDirection atoz,
127 this.dataBroker = dataBroker;
128 Map<String, List<?>> map = extractTopo();
129 if (map.containsKey("Elements")) {
130 elements = (List<Elements>) map.get("Elements");
134 if (map.containsKey("Elements")) {
135 connections = (List<Connections>) map.get("Connections");
139 pathRequest = extractPathRequest(input, atoz, requestId);
140 synchronization = extractSynchronization(requestId);
143 public ExtractTopoDataStoreImpl(final DataBroker dataBroker, PathComputationRequestInput input, ZToADirection ztoa,
145 this.dataBroker = dataBroker;
146 Map<String, List<?>> map = extractTopo();
147 if (map.containsKey("Elements")) {
148 elements = (List<Elements>) map.get("Elements");
152 if (map.containsKey("Elements")) {
153 connections = (List<Connections>) map.get("Connections");
157 pathRequest = extractPathRequest(input, ztoa, requestId);
158 synchronization = extractSynchronization(requestId);
162 * extract the topology: all the elements have ipAddress as uid and maintain
163 * a mapping structure to map between the nodeId and the ipAddress (uid)
166 public Map<String, List<?>> extractTopo() {
167 Map<String, List<?>> map = new HashMap<String, List<?>>();
168 // Define the elements
169 List<Elements> topoElements = new ArrayList<>();
170 // Define the connections
171 List<Connections> topoConnections = new ArrayList<>();
172 // Define the instance identifier of the OpenRoadm topology
173 InstanceIdentifier<Network> insIdOpenRoadmTopo = InstanceIdentifier
174 .builder(Networks.class)
175 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
176 // Define the instance identifier of the OpenRoadm network
177 InstanceIdentifier<Network> insIdrOpenRoadmNet = InstanceIdentifier
178 .builder(Networks.class)
179 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))).build();
180 ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
181 // Read the data broker
183 // Initialize the reading of the data broker
184 // read the configuration part of the data broker that concerns
185 // the openRoadm topology and get all the nodes
186 java.util.Optional<Network> openRoadmTopo = readOnlyTransaction
187 .read(LogicalDatastoreType.CONFIGURATION, insIdOpenRoadmTopo).get().toJavaUtil();
188 java.util.Optional<Network> openRoadmNet = readOnlyTransaction
189 .read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get().toJavaUtil();
190 if (openRoadmNet.isPresent()) {
191 List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
192 if (openRoadmTopo.isPresent()) {
193 List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
194 List<String> nodesList = new ArrayList<>();
195 // Create the list of nodes
196 if (!openRoadmTopoNodeList.isEmpty()) {
198 for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
199 // Retrieve the supporting node and the type of the
200 // node in openRoadm network
201 List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
202 for (SupportingNode supportingNode : supportingNodeList) {
203 String nodeRef = supportingNode.getNodeRef().getValue();
204 IpAddress ipAddress = null;
205 // Retrieve the mapping between the openRoadm
206 // topology and openRoadm network
207 mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
208 Node1 openRoadmNetNode1 = null;
209 for (Node openRoadmNetNode : openRoadmNetNodeList) {
210 if (openRoadmNetNode.getNodeId().getValue().equals(nodeRef)) {
211 openRoadmNetNode1 = openRoadmNetNode.augmentation(Node1.class);
212 ipAddress = openRoadmNetNode1.getIp();
213 mapNodeRefIp.put(nodeRef, ipAddress);
217 if (openRoadmNetNode1.getNodeType().getName().equals("ROADM")) {
218 if (!nodesList.contains(nodeRef)) {
219 Elements element = addElementsRoadm(2, 0, nodeRef, openRoadmNetNode1.getShelf(),
220 -20, ipAddress.getIpv4Address().getValue().toString());
221 topoElements.add(element);
222 nodesList.add(nodeRef);
224 } else if (openRoadmNetNode1.getNodeType().getName().equals("XPONDER")) {
225 if (!nodesList.contains(nodeRef)) {
226 Elements element = addElementsTransceiver(2, 0, nodeRef,
227 openRoadmNetNode1.getShelf(),
228 ipAddress.getIpv4Address().getValue().toString());
229 topoElements.add(element);
230 nodesList.add(nodeRef);
233 LOG.warn("the type is not implemented");
238 LOG.warn("no nodes in the network");
241 // Create the list of connections
242 Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
243 List<Link> linksList = nw1.getLink();
244 // 1:EXPRESS-LINK ; 2:ADD-LINK ; 3:DROP-LINK ;
245 // 4:ROADM-To-ROADM ; 5:XPONDER-INPUT ; 6:XPONDER-OUTPUT
246 int[] externalLink = {4,5,6};
249 if (!linksList.isEmpty()) {
250 LOG.warn("The link list is not empty");
251 for (Link link : linksList) {
252 Link1 link1 = link.augmentation(Link1.class);
253 int linkType = link1.getLinkType().getIntValue();
254 if (IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
255 // Verify if the node is a ROADM
256 String srcId = mapDisgNodeRefNode.get(link.getSource().getSourceNode().getValue());
257 IpAddress srcIp = mapNodeRefIp.get(srcId);
258 String destId = null;
259 IpAddress destIp = null;
260 // Add the links between amplifiers
261 OMSAttributes omsAttributes = link1.getOMSAttributes();
262 if (omsAttributes != null) {
263 if (omsAttributes.getAmplifiedLink() != null) {
264 List<AmplifiedLink> amplifiedLinkList = omsAttributes.getAmplifiedLink()
266 if (!amplifiedLinkList.isEmpty()) {
267 for (AmplifiedLink amplifiedLink : amplifiedLinkList) {
268 Elements element1 = null;
269 if (amplifiedLink.getSectionElement()
270 .getSectionElement() instanceof Ila) {
271 Ila ila = (Ila) amplifiedLink.getSectionElement()
272 .getSectionElement();
273 String nodeId = ila.getNodeId().getValue();
274 IpAddress ipEdfa = new IpAddress(
275 new Ipv4Address("1.1.1." + nbEDFA));
277 mapDisgNodeRefNode.put(nodeId, nodeId);
278 mapNodeRefIp.put(nodeId, ipEdfa);
279 // class std_medium_gain
280 // implements EdfaVariety {}
281 element1 = addElementsEdfa(2, 0, "RLD", "Lannion_CAS",
282 ila.getGain().getValue(), ila.getTilt().getValue(),
283 ila.getOutVoaAtt().getValue(), "std_medium_gain",
284 ipEdfa.getIpv4Address().getValue().toString());
285 } else if (amplifiedLink.getSectionElement()
286 .getSectionElement() instanceof Span) {
287 // Create the location
288 Span span = (Span) amplifiedLink.getSectionElement()
289 .getSectionElement();
290 String clfi = span.getSpan().getClfi();
291 IpAddress ipFiber = new IpAddress(
292 new Ipv4Address("2.2.2." + idFiber));
293 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
294 mapFiberIp.put(clfi, ipFiber);
296 // class SSMF implements
298 element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
299 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0,
302 if (element1 != null) {
303 topoElements.add(element1);
304 destId = element1.getUid();
307 if (srcId != destId) {
308 Connections connection = createNewConnection(srcId, srcIp,
310 topoConnections.add(connection);
317 } else if (omsAttributes.getSpan() != null) {
318 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
319 .networks.network.link.oms.attributes.@Nullable Span span
320 = omsAttributes.getSpan();
322 String clfi = span.getClfi();
323 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
324 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
325 mapFiberIp.put(clfi, ipFiber);
328 double attIn = span.getSpanlossCurrent().getValue().doubleValue();
329 double lossCoef = 0.2;
332 String typeVariety = "SSMF";
335 // Compute the length of the link
336 List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
337 for (LinkConcatenation linkConcatenation : linkConcatenationList) {
338 double srlgLength = linkConcatenation.getSRLGLength();
339 //convert to kilometer
340 length += srlgLength / convertKmM;
343 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
344 ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn,
345 connOut, typeVariety);
347 topoElements.add(element1);
349 destId = element1.getUid();
351 if (srcId != destId) {
352 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
353 topoConnections.add(connection);
359 String clfi = "Fiber" + idFiber;
360 IpAddress ipFiber = new IpAddress(new Ipv4Address("2.2.2." + idFiber));
361 mapLinkFiber.put(link.getLinkId().getValue(), clfi);
362 mapFiberIp.put(clfi, ipFiber);
364 // Create a new element
365 // class SSMF implements FiberVariety {}
366 Elements element1 = addElementsFiber(2, 0, "RLD", "Lannion_CAS",
367 ipFiber.getIpv4Address().getValue(), 20, 0, 0.2, 0, 0, "SSMF");
368 topoElements.add(element1);
370 destId = element1.getUid();
372 if (srcId != destId) {
373 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
374 topoConnections.add(connection);
380 LOG.warn("The oms attributes is null!");
383 destId = mapDisgNodeRefNode.get(link.getDestination().getDestNode().getValue());
384 destIp = mapNodeRefIp.get(destId);
385 Connections connection = createNewConnection(srcId, srcIp, destId, destIp);
386 topoConnections.add(connection);
390 LOG.warn("no links in the network");
393 LOG.warn("No nodes in the selected network ...");
396 } catch (InterruptedException | ExecutionException e) {
397 LOG.error("Error reading the topology", e);
398 readOnlyTransaction.close();
400 readOnlyTransaction.close();
401 map.put("Elements", topoElements);
402 map.put("Connections", topoConnections);
407 * Create the pathRequest
409 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, AToZDirection atoz, Long requestId) {
411 List<AToZ> listAtoZ = atoz.getAToZ();
412 int atozSize = listAtoZ.size();
413 // String modulationFormat = atoz.getModulationFormat();
414 // Create the path request
415 List<PathRequest> pathRequestList = new ArrayList<>();
416 // Define the instance identifier
417 // InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
418 // .builder(Network.class, new NetworkKey(new
419 // NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
421 // read the configuration part of the data broker that concerns the
422 // nodes ID and get all the nodes
423 // java.util.Optional<Network> networkObject = readOnlyTransaction
424 // .read(LogicalDatastoreType.CONFIGURATION,
425 // nwInstanceIdentifier).get().toJavaUtil();
426 // 1.1 Create explicitRouteObjects
427 // 1.1.1. create RouteObjectIncludeExclude list
428 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
429 IpAddress ipAddressCurrent = null;
430 Long index = (long) 0;
431 //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
432 for (int i = 0; i < atozSize; i++) {
433 // String idAtoZ = listAtoZ.get(i).getId();
434 String nodeId = null;
435 if (listAtoZ.get(i).getResource()
436 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
437 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
438 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
439 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
440 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listAtoZ
441 .get(i).getResource().getResource();
442 nodeId = node.getNodeId();
443 if (nodeId != null) {
444 String nodeRef = mapDisgNodeRefNode.get(nodeId);
445 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
446 for (Elements element : elements) {
447 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
448 String type = element.getType().getName();
449 if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
450 ipAddressCurrent = ipAddress;
451 // Fill in routeObjectIncludeExcludes
452 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
453 ipAddress, 1, index);
454 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
461 LOG.warn("node ID is null");
463 } else if (listAtoZ.get(i).getResource()
464 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
465 .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
466 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
467 .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
468 .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
469 .TerminationPoint) listAtoZ.get(i).getResource().getResource();
470 // Not used in this version
471 } else if (listAtoZ.get(i).getResource()
472 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
473 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
474 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
475 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
476 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listAtoZ
477 .get(i).getResource().getResource();
478 String clfi = mapLinkFiber.get(link.getLinkId());
479 IpAddress fiberIp = mapFiberIp.get(clfi);
481 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
483 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
488 // Create ExplicitRouteObjects
489 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
490 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
492 // 1. Create the path request element 1
494 // String serviceName = input.getServiceName();
495 String sourceNode = input.getServiceAEnd().getNodeId();
496 String destNode = input.getServiceZEnd().getNodeId();
498 // 1.2 Create a path constraints
499 Long rate = atoz.getRate();
500 // Long wavelengthNumber = atoz.getAToZWavelengthNumber();
501 // Create EffectiveFreqSlot
502 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
503 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
504 effectiveFreqSlot.add(effectiveFreqSlot1);
505 // Create Te-Bandwidth
506 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
507 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
508 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
509 // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
510 // BigDecimal(0.0012589254117941673))
511 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
512 // PathRequest pathRequest1 = new
513 // PathRequestBuilder().setRequestId(new
514 // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
515 // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
516 // .getPort().getPortName().getBytes())
517 // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
518 // .setPathConstraints(pathConstraints)
519 // .setExplicitRouteObjects(explicitRouteObjects).build();
520 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
521 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
522 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
523 .setExplicitRouteObjects(explicitRouteObjects).build();
524 pathRequestList.add(pathRequest1);
525 //readOnlyTransaction.close();
526 return pathRequestList;
529 public List<PathRequest> extractPathRequest(PathComputationRequestInput input, ZToADirection ztoa, Long requestId) {
531 List<ZToA> listZToA = ztoa.getZToA();
532 int ztoaSize = listZToA.size();
533 // String modulationFormat = ztoa.getModulationFormat();
534 // Create the path request
535 List<PathRequest> servicePathRequest = new ArrayList<>();
536 // Define the instance identifier
537 InstanceIdentifier<Network> nwInstanceIdentifier = InstanceIdentifier
538 .builder(Networks.class)
539 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
540 //ReadOnlyTransaction readOnlyTransaction = this.dataBroker.newReadOnlyTransaction();
542 // read the configuration part of the data broker that concerns the
543 // nodes ID and get all the nodes
544 // java.util.Optional<Network> networkObject = readOnlyTransaction
545 // .read(LogicalDatastoreType.CONFIGURATION,
546 // nwInstanceIdentifier).get().toJavaUtil();
547 // 1.1 Create explicitRouteObjects
548 // 1.1.1. create RouteObjectIncludeExclude list
549 List<RouteObjectIncludeExclude> routeObjectIncludeExcludes = new ArrayList<>();
550 IpAddress ipAddressCurrent = null;
551 Long index = (long) 0;
552 for (int i = 0; i < ztoaSize; i++) {
553 // String idZtoA = listZToA.get(i).getId();
554 String nodeId = null;
555 if (listZToA.get(i).getResource()
556 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
557 .pathdescription.rev171017.pce.resource.resource.resource.Node) {
558 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
559 .resource.resource.resource.Node node = (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c
560 ._interface.pathdescription.rev171017.pce.resource.resource.resource.Node) listZToA.get(i)
561 .getResource().getResource();
562 nodeId = node.getNodeId();
563 if (nodeId != null) {
564 String nodeRef = mapDisgNodeRefNode.get(nodeId);
565 IpAddress ipAddress = mapNodeRefIp.get(nodeRef);
566 for (Elements element : elements) {
567 if (element.getUid().contains(ipAddress.getIpv4Address().getValue().toString())) {
568 // String type = element.getType().getName();
569 if ((ipAddressCurrent == null) || (ipAddressCurrent != ipAddress)) {
570 ipAddressCurrent = ipAddress;
571 // Fill in routeObjectIncludeExcludes
572 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(
573 ipAddress, 1, index);
574 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
581 LOG.warn("node ID is null");
583 } else if (listZToA.get(i).getResource()
584 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
585 .pathdescription.rev171017.pce.resource.resource.resource.TerminationPoint) {
586 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
587 .resource.resource.resource.TerminationPoint tp = (org.opendaylight.yang.gen.v1.http.org
588 .transportpce.b.c._interface.pathdescription.rev171017.pce.resource.resource.resource
589 .TerminationPoint) listZToA.get(i).getResource().getResource();
590 // Not used in this version
591 } else if (listZToA.get(i).getResource()
592 .getResource() instanceof org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
593 .pathdescription.rev171017.pce.resource.resource.resource.Link) {
594 org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
595 .resource.resource.resource.Link link = (org.opendaylight.yang.gen.v1.http.org.transportpce
596 .b.c._interface.pathdescription.rev171017.pce.resource.resource.resource.Link) listZToA.get(i)
597 .getResource().getResource();
598 String clfi = mapLinkFiber.get(link.getLinkId());
599 IpAddress fiberIp = mapFiberIp.get(clfi);
601 RouteObjectIncludeExclude routeObjectIncludeExclude1 = addRouteObjectIncludeExclude(fiberIp, 1,
603 routeObjectIncludeExcludes.add(routeObjectIncludeExclude1);
608 // Create ExplicitRouteObjects
609 ExplicitRouteObjects explicitRouteObjects = new ExplicitRouteObjectsBuilder()
610 .setRouteObjectIncludeExclude(routeObjectIncludeExcludes).build();
612 // 1. Create the path request element 1
614 // String serviceName = input.getServiceName();
615 String sourceNode = input.getServiceZEnd().getNodeId();
616 String destNode = input.getServiceAEnd().getNodeId();
618 // 1.2 Create a path constraints
619 Long rate = ztoa.getRate();
620 // Long wavelengthNumber = ztoa.getZToAWavelengthNumber();
621 // Create EffectiveFreqSlot
622 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
623 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
624 effectiveFreqSlot.add(effectiveFreqSlot1);
625 // Create Te-Bandwidth
626 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
627 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
628 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
629 // .setMaxNbOfChannel(new Long(80)).setOutputPower(new
630 // BigDecimal(0.0012589254117941673))
631 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
632 // PathRequest pathRequest1 = new
633 // PathRequestBuilder().setRequestId(new
634 // Long(0)).setSource(mapNodeRefIp.get(sourceNode))
635 // .setDestination(mapNodeRefIp.get(destNode)).setSrcTpId(input.getServiceAEnd().getTxDirection()
636 // .getPort().getPortName().getBytes())
637 // .setDstTpId(input.getServiceAEnd().getRxDirection().getPort().getPortName().getBytes())
638 // .setPathConstraints(pathConstraints)
639 // .setExplicitRouteObjects(explicitRouteObjects).build();
640 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(requestId)
641 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
642 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
643 .setExplicitRouteObjects(explicitRouteObjects).build();
644 servicePathRequest.add(pathRequest1);
645 //readOnlyTransaction.close();
646 return servicePathRequest;
650 * Create the synchronization
652 public List<Synchronization> extractSynchronization(Long requestId) {
653 // Create RequestIdNumber
654 List<Long> requestIdNumber = new ArrayList<>();
655 requestIdNumber.add(0, new Long(0));
656 // Create a synchronization
657 Svec svec = new SvecBuilder().setRelaxable(true).setDisjointness(new TePathDisjointness(true, true, false))
658 .setRequestIdNumber(requestIdNumber).build();
659 List<Synchronization> synchro = new ArrayList<>();
660 Synchronization synchronization1 = new SynchronizationBuilder().setSynchronizationId(new Long(0)).setSvec(svec)
662 synchro.add(synchronization1);
667 * Method to add Fiber
669 private Elements addElementsFiber(double latitude, double longitude, String region, String city, String clfi,
670 double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
671 // Create an amplifier after the roadm
672 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
673 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
674 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
676 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
677 Fiber fiber = new FiberBuilder().setLength(new BigDecimal(length)).setLengthUnits(Km.class)
678 .setAttIn(new BigDecimal(attIn)).setLossCoef(new BigDecimal(lossCoef)).setConIn(new BigDecimal(connIn))
679 .setConOut(new BigDecimal(connOut)).build();
680 Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
681 // TypeElement Fiber = ; //new TypeElement(Fiber);
682 Elements element1 = new ElementsBuilder().setUid(clfi)
683 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
684 .setTypeVariety(typeVariety).setMetadata(metadata1)
685 .setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
692 private Elements addElementsEdfa(double latitude, double longitude, String region, String city,
693 BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
694 // Create an amplifier after the roadm
695 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
696 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
697 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
699 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
700 Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
701 .setOutVoa(outVoa).build();
702 Edfa edfa = new EdfaBuilder()
703 // .setTypeVariety(typeVariety)
704 .setOperational(operational).build();
705 Elements element1 = new ElementsBuilder().setUid(uidEdfa)
706 // Choose an ip address
707 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
708 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
713 * Method to add ROADM
715 private Elements addElementsRoadm(double latitude, double longitude, String region, String city,
716 double targetPchOutDb, String uidRoadm) {
718 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
719 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
720 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
722 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
724 Roadm roadm = new RoadmBuilder().setTargetPchOutDb(new BigDecimal(targetPchOutDb)).build();
725 Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
726 Elements element1 = new ElementsBuilder().setUid(uidRoadm)
727 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
728 .setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
733 * Method to add Transceiver
735 private Elements addElementsTransceiver(double latitude, double longitude, String region, String city,
737 Coordinate c1 = new Coordinate(new BigDecimal(latitude));
738 Coordinate c2 = new Coordinate(new BigDecimal(longitude));
739 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
741 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
742 Transceiver transceiver = new TransceiverBuilder().build();
743 Elements element1 = new ElementsBuilder().setUid(uidTrans)
744 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
745 .setMetadata(metadata1).setElementType(transceiver).build();
750 * Add routeObjectIncludeExclude
752 private RouteObjectIncludeExclude addRouteObjectIncludeExclude(IpAddress ipAddress, long teTpValue, long index) {
753 TeNodeId teNodeId = new TeNodeId(ipAddress);
754 TeTpId teTpId = new TeTpId(teTpValue);
755 NumUnnumHop numUnnumHop = new org.opendaylight.yang.gen.v1.gnpy.path.rev190502.explicit.route.hop.type.num
756 .unnum.hop.NumUnnumHopBuilder()
757 .setNodeId(teNodeId.getIpv4Address().getValue().toString()).setLinkTpId(teTpId.getUint32().toString())
758 .setHopType(TeHopType.STRICT).build();
759 Type type1 = new NumUnnumHopBuilder().setNumUnnumHop(numUnnumHop).build();
760 // Create routeObjectIncludeExclude element 1
761 RouteObjectIncludeExclude routeObjectIncludeExclude1 = new RouteObjectIncludeExcludeBuilder().setIndex(index)
762 .setExplicitRouteUsage(RouteIncludeEro.class).setType(type1).build();
763 return routeObjectIncludeExclude1;
766 private String fromToNodeForConnection(String id, IpAddress ip) {
767 String fromToNode = id;
769 fromToNode = ip.getIpv4Address().getValue().toString();
774 private Connections createNewConnection(String srcId, IpAddress srcIp, String destId, IpAddress destIp) {
775 String fromNode = srcId;
776 String toNode = destId;
778 fromNode = srcIp.getIpv4Address().getValue().toString();
780 if (destIp != null) {
781 toNode = destIp.getIpv4Address().getValue().toString();
783 Connections connection1 = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
784 return (connection1);
787 public List<Elements> getElements() {
791 public void setElements(List<Elements> elements) {
792 this.elements = elements;
795 public List<Connections> getConnections() {
799 public void setConnections(List<Connections> connections) {
800 this.connections = connections;
803 public List<PathRequest> getPathRequest() {
807 public void setPathRequest(List<PathRequest> pathRequest) {
808 this.pathRequest = pathRequest;
811 public List<Synchronization> getSynchronization() {
812 return synchronization;
815 public void setSynchronization(List<Synchronization> synchronization) {
816 this.synchronization = synchronization;
819 public List<PathRequest> createEmptyPathRequest(PathComputationRequestInput input, AToZDirection atoz) {
821 // List<AToZ> listAtoZ = atoz.getAToZ();
822 // int atozSize = listAtoZ.size();
824 // Create the path request
825 List<PathRequest> pathRequestList = new ArrayList<>();
827 // 1. Create the path request element 1
829 // String serviceName = input.getServiceName();
830 String sourceNode = input.getServiceAEnd().getNodeId();
831 String destNode = input.getServiceZEnd().getNodeId();
833 // 1.2 Create a path constraints
834 Long rate = atoz.getRate();
836 // Create EffectiveFreqSlot
837 List<EffectiveFreqSlot> effectiveFreqSlot = new ArrayList<>();
838 EffectiveFreqSlot effectiveFreqSlot1 = new EffectiveFreqSlotBuilder().setM(5).setN(8).build();
839 effectiveFreqSlot.add(effectiveFreqSlot1);
841 // Create Te-Bandwidth
842 TeBandwidth teBandwidth = new TeBandwidthBuilder().setPathBandwidth(new BigDecimal(rate))
843 .setTechnology("flexi-grid").setTrxType("openroadm-beta1").setTrxMode("W100G")
844 .setEffectiveFreqSlot(effectiveFreqSlot).setSpacing(new BigDecimal(50000000000.0)).build();
845 PathConstraints pathConstraints = new PathConstraintsBuilder().setTeBandwidth(teBandwidth).build();
846 PathRequest pathRequest1 = new PathRequestBuilder().setRequestId(new Long(0))
847 .setSource(mapNodeRefIp.get(sourceNode)).setDestination(mapNodeRefIp.get(destNode))
848 .setSrcTpId("srcTpId".getBytes()).setDstTpId("dstTpId".getBytes()).setPathConstraints(pathConstraints)
850 pathRequestList.add(pathRequest1);
851 return pathRequestList;