2 * Copyright © 2019 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.regex.Pattern;
18 import java.util.stream.IntStream;
19 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
20 import org.opendaylight.transportpce.common.NetworkUtils;
21 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
22 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Coordinate;
23 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Km;
24 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.Operational;
25 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.edfa.params.OperationalBuilder;
26 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Edfa;
27 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.EdfaBuilder;
28 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.FiberRoadmBuilder;
29 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.Transceiver;
30 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.TransceiverBuilder;
31 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.Params;
32 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.ParamsBuilder;
33 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Fiber;
34 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.FiberBuilder;
35 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.Roadm;
36 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.element.type.choice.element.type.fiberroadm.params.fiberroadm.RoadmBuilder;
37 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.Location;
38 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.location.attributes.LocationBuilder;
39 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Connections;
40 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ConnectionsBuilder;
41 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.Elements;
42 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.ElementsBuilder;
43 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.Metadata;
44 import org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.topo.elements.MetadataBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.SpanAttributes;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.AmplifiedLink;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.Span;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.amplified.link.attributes.amplified.link.section.element.section.element.ila.Ila;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.rev181130.Node1;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.OMSAttributes;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
54 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
55 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.node.SupportingNode;
62 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
63 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
64 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
65 import org.slf4j.Logger;
66 import org.slf4j.LoggerFactory;
69 * Class to create the topology corresponding to GNPy requirements.
71 * @author Ahmed Triki ( ahmed.triki@orange.com )
75 public class GnpyTopoImpl {
76 private static final Logger LOG = LoggerFactory.getLogger(GnpyTopoImpl.class);
77 private final NetworkTransactionService networkTransactionService;
79 private List<Elements> elements = new ArrayList<>();
80 private List<Connections> connections = new ArrayList<>();
82 //Mapping between the ord-topo and ord-ntw node
83 private Map<String, String> mapDisgNodeRefNode = new HashMap<>();
84 //Mapping between the ord-ntw and node ip
85 private Map<String, IpAddress> mapNodeRefIp = new HashMap<>();
86 //Mapping between the ROADM-ROADM linkId/secElement and the linkId
87 private Map<String, List<String>> mapLinkFiber = new HashMap<>();
88 //Mapping between the ROADM-ROADM linkId/secElement and ipAddress
89 private Map<String, IpAddress> mapFiberIp = new HashMap<>();
91 private List<String> trxList = new ArrayList<>();
92 //Initialize the 32 bit identifiers for the edfa and the fiber.
93 //These 32-bit identifiers are not ipv4 addresses (despite having ipv4Adresses format, dotted-decimal notation).
94 //They are imposed by the GNPy yang model to identify network elements and not used for any routing purposes.
95 private Ipv4Address edfaId;
96 private Ipv4Address fiberId;
97 private static final double LATITUDE = 0;
98 private static final double LONGITUTE = 0;
99 private static final String REGION = "N/A";
100 private static final String CITY = "N/A";
101 private static final int CONVERT_KM_M = 1000;
102 private static final double TARGET_PCH_OUT_DB = -20;
105 * Construct the ExtractTopoDataStoreImpl.
107 public GnpyTopoImpl(final NetworkTransactionService networkTransactionService) throws GnpyException {
108 this.networkTransactionService = networkTransactionService;
109 //32-bit identifier for the fiber. The dotted decimal notation has the format 243.x.x.x (0<=x<=255)
110 fiberId = new Ipv4Address("243.0.0.1");
111 //32-bit identifier for the edfa. The dotted decimal notation has the format 244.x.x.x (0<=x<=255)
112 edfaId = new Ipv4Address("244.0.0.1");
115 } catch (NullPointerException e) {
116 throw new GnpyException("In GnpyTopoImpl: one of the elements is null",e);
121 * extract the topology: all the elements have ipAddress as uid and maintain
122 * a mapping structure to map between the nodeId and the ipAddress (uid)
125 private void extractTopo() throws GnpyException {
126 // Define the instance identifier of the OpenRoadm topology
127 InstanceIdentifier<Network> insIdOpenRoadmTopo = InstanceIdentifier
128 .builder(Networks.class)
129 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
130 // Define the instance identifier of the OpenRoadm network
131 InstanceIdentifier<Network> insIdrOpenRoadmNet = InstanceIdentifier
132 .builder(Networks.class)
133 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID))).build();
135 // Initialize the reading of the networkTransactionService
136 // read the configuration part of the data broker that concerns the openRoadm topology and get all the nodes
137 java.util.Optional<Network> openRoadmTopo = this.networkTransactionService
138 .read(LogicalDatastoreType.CONFIGURATION, insIdOpenRoadmTopo).get();
139 java.util.Optional<Network> openRoadmNet = this.networkTransactionService
140 .read(LogicalDatastoreType.CONFIGURATION, insIdrOpenRoadmNet).get();
141 if (openRoadmNet.isPresent() && openRoadmTopo.isPresent()) {
142 extractElements(openRoadmTopo,openRoadmNet);
143 extractConnections(openRoadmTopo);
144 LOG.debug("In GnpyTopoImpl : elements and connections are well extracted");
147 throw new GnpyException(
148 "In GnpyTopoImpl : openroadm topology network or openroadm network are not well mounted ...");
150 } catch (InterruptedException | ExecutionException e) {
151 this.networkTransactionService.close();
152 throw new GnpyException("In gnpyTopoImpl: error in reading the topology", e);
154 this.networkTransactionService.close();
157 private void extractElements(java.util.Optional<Network> openRoadmTopo,
158 java.util.Optional<Network> openRoadmNet) throws GnpyException {
159 if ((!openRoadmNet.isPresent()) || (!openRoadmTopo.isPresent())) {
160 throw new GnpyException("In gnpyTopoImpl: openRoadmNet or openRoadmTopo is not present");
162 // Create the list of nodes
163 List<Node> openRoadmNetNodeList = openRoadmNet.get().getNode();
164 List<Node> openRoadmTopoNodeList = openRoadmTopo.get().getNode();
165 List<String> nodesList = new ArrayList<>();
167 if (openRoadmTopoNodeList.isEmpty() || openRoadmNetNodeList.isEmpty()) {
168 throw new GnpyException("In gnpyTopoImpl: no nodes in the openradm topology or openroadm network");
171 for (Node openRoadmTopoNode : openRoadmTopoNodeList) {
172 // Retrieve the supporting node and the type of the node in openRoadm network
173 List<SupportingNode> supportingNodeList = openRoadmTopoNode.getSupportingNode();
175 for (SupportingNode supportingNode : supportingNodeList) {
176 if (!supportingNode.getNetworkRef().getValue().equals("openroadm-network")) {
179 IpAddress ipAddress = null;
180 String nodeRef = supportingNode.getNodeRef().getValue();
181 if (nodeRef == null) {
182 throw new GnpyException("In gnpyTopoImpl: nodeRef is null");
184 // Retrieve the mapping between the openRoadm topology and openRoadm network
185 mapDisgNodeRefNode.put(openRoadmTopoNode.getNodeId().getValue(), nodeRef);
186 Node1 openRoadmNetNode1 = null;
187 org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
188 .Node1 commonNetworkNode1 = null;
189 for (Node openRoadmNetNode : openRoadmNetNodeList) {
190 if (openRoadmNetNode.getNodeId().getValue().equals(nodeRef)) {
191 openRoadmNetNode1 = openRoadmNetNode.augmentation(Node1.class);
192 commonNetworkNode1 = openRoadmNetNode.augmentation(org.opendaylight.yang.gen.v1
193 .http.org.openroadm.common.network.rev181130.Node1.class);
194 ipAddress = openRoadmNetNode1.getIp();
195 if (ipAddress == null) {
196 throw new GnpyException(String.format(
197 "In gnpyTopoImpl: ipAddress of node %s is null",nodeRef));
199 mapNodeRefIp.put(nodeRef, ipAddress);
203 if (commonNetworkNode1 == null) {
204 throw new GnpyException(String.format("In gnpyTopoImpl: the node type of %s is null",nodeRef));
206 if (commonNetworkNode1.getNodeType().getName().equals("ROADM")) {
207 if (!nodesList.contains(nodeRef)) {
208 Elements element = createElementsRoadm(LATITUDE, LONGITUTE, nodeRef,
209 openRoadmNetNode1.getShelf(),TARGET_PCH_OUT_DB, ipAddress.getIpv4Address().getValue());
210 this.elements.add(element);
211 nodesList.add(nodeRef);
213 } else if (commonNetworkNode1.getNodeType().getName().equals("XPONDER")) {
214 if (!nodesList.contains(nodeRef)) {
215 Elements element = createElementsTransceiver(LATITUDE, LONGITUTE, nodeRef,
216 openRoadmNetNode1.getShelf(),ipAddress.getIpv4Address().getValue());
217 this.elements.add(element);
218 nodesList.add(nodeRef);
219 trxList.add(nodeRef);
222 throw new GnpyException("In gnpyTopoImpl: the type is not implemented");
228 private void extractConnections(java.util.Optional<Network> openRoadmTopo) throws GnpyException {
229 // Create the list of connections
230 if (!openRoadmTopo.isPresent()) {
231 throw new GnpyException("In gnpyTopoImpl: openroadmTopo is not present");
233 Network1 nw1 = openRoadmTopo.get().augmentation(Network1.class);
234 List<Link> linksList = nw1.getLink();
235 // 1:EXPRESS-LINK 2:ADD-LINK 3:DROP-LINK
236 // 4:ROADM-To-ROADM 5:XPONDER-INPUT 6:XPONDER-OUTPUT
237 int[] externalLink = {OpenroadmLinkType.ROADMTOROADM.getIntValue(),OpenroadmLinkType.XPONDERINPUT.getIntValue(),
238 OpenroadmLinkType.XPONDEROUTPUT.getIntValue()};
240 if (linksList.isEmpty()) {
241 throw new GnpyException("In gnpyTopoImpl: no links in the network");
244 for (Link link : linksList) {
245 Link1 link1 = link.augmentation(Link1.class);
246 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130
247 .Link1 openroadmNetworkLink1 = link.augmentation(org.opendaylight.yang.gen.v1.http.org
248 .openroadm.network.topology.rev181130.Link1.class);
249 if (link1.getLinkType() == null) {
250 throw new GnpyException("In gnpyTopoImpl: the link type is null");
252 int linkType = link1.getLinkType().getIntValue();
253 if (! IntStream.of(externalLink).anyMatch(x -> x == linkType)) {
257 String srcId = mapDisgNodeRefNode.get(link.getSource().getSourceNode().getValue());
258 IpAddress srcIp = mapNodeRefIp.get(srcId);
259 String linkId = link.getLinkId().getValue();
260 String destId = null;
261 IpAddress destIp = null;
262 if (linkType == OpenroadmLinkType.ROADMTOROADM.getIntValue()) {
263 OMSAttributes omsAttributes = openroadmNetworkLink1.getOMSAttributes();
264 if (omsAttributes == null) {
265 throw new GnpyException(String.format(
266 "In gnpyTopoImpl: OMS attributes do not exit for ROADM to ROADM link: %s",linkId));
268 //Case of amplified link
269 if (omsAttributes.getAmplifiedLink() != null) {
270 srcIp = extractAmplifiedLink(omsAttributes, linkId, srcIp);
272 //Case of one span link
273 if (omsAttributes.getSpan() != null) {
274 srcIp = extractSpanLink(omsAttributes, linkId, srcIp);
278 destId = mapDisgNodeRefNode.get(link.getDestination().getDestNode().getValue());
279 destIp = mapNodeRefIp.get(destId);
280 createNewConnection(srcIp,destIp);
284 private IpAddress extractAmplifiedLink(OMSAttributes omsAttributes, String linkId, IpAddress srcIp)
285 throws GnpyException {
287 List<AmplifiedLink> amplifiedLinkList = omsAttributes.getAmplifiedLink()
289 IpAddress destIp = null;
290 if (!amplifiedLinkList.isEmpty()) {
291 for (AmplifiedLink amplifiedLink : amplifiedLinkList) {
292 String secElt = amplifiedLink.getSectionEltNumber().toString();
294 if (amplifiedLink.getSectionElement().getSectionElement() instanceof Ila) {
295 Ila ila = (Ila) amplifiedLink.getSectionElement().getSectionElement();
296 destIp = extractILAFromAmpLink(ila);
299 if (amplifiedLink.getSectionElement().getSectionElement() instanceof Span) {
300 Span span = (Span) amplifiedLink.getSectionElement().getSectionElement();
301 destIp = extractSpan(span.getSpan(), linkId, secElt);
304 if (createNewConnection(srcIp,destIp)) {
312 private IpAddress extractSpanLink(OMSAttributes omsAttributes, String linkId, IpAddress srcIp)
313 throws GnpyException {
315 SpanAttributes span = omsAttributes.getSpan();
316 IpAddress destIp = extractSpan(span, linkId, linkId);
317 if (createNewConnection(srcIp, destIp)) {
323 private IpAddress extractILAFromAmpLink(Ila ila) throws GnpyException {
324 String nodeId = ila.getNodeId().getValue();
325 IpAddress ipEdfa = new IpAddress(edfaId);
326 edfaId = incrementIdentifier(edfaId);
327 mapDisgNodeRefNode.put(nodeId, nodeId);
328 mapNodeRefIp.put(nodeId, ipEdfa);
329 Elements element = createElementsEdfa(LATITUDE, LONGITUTE, REGION, CITY,
330 ila.getGain().getValue(), ila.getTilt().getValue(),
331 ila.getOutVoaAtt().getValue(), "std_medium_gain",
332 ipEdfa.getIpv4Address().getValue());
333 this.elements.add(element);
337 private IpAddress extractSpan(SpanAttributes span, String linkId, String subLinkId) throws GnpyException {
338 IpAddress ipFiber = new IpAddress(fiberId);
340 if (!mapLinkFiber.containsKey(linkId)) {
341 mapLinkFiber.put(linkId, new ArrayList<String>());
343 mapLinkFiber.get(linkId).add(subLinkId);
344 mapFiberIp.put(subLinkId, ipFiber);
345 fiberId = incrementIdentifier(fiberId);
349 String typeVariety = "SSMF";
351 // Compute the length of the link
352 List<LinkConcatenation> linkConcatenationList = span.getLinkConcatenation();
353 for (LinkConcatenation linkConcatenation : linkConcatenationList) {
354 double srlgLength = linkConcatenation.getSRLGLength().toJava();
355 //convert to kilometer
356 length += srlgLength / CONVERT_KM_M;
359 throw new GnpyException(String.format(
360 "In gnpyTopoImpl: length of the link %s is equal to zero",linkId));
362 double lossCoef = span.getSpanlossCurrent().getValue().doubleValue() / length;
363 Elements element = createElementsFiber(LATITUDE, LONGITUTE, REGION, CITY,
364 ipFiber.getIpv4Address().getValue(), length, attIn, lossCoef, connIn, connOut, typeVariety);
365 this.elements.add(element);
371 * Method to create Fiber
373 private Elements createElementsFiber(double latitude, double longitude, String region, String city, String uidFiber,
374 double length, double attIn, double lossCoef, double connIn, double connOut, String typeVariety) {
375 // Create an amplifier after the ROADM
376 Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
377 Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
378 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
380 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
381 Fiber fiber = new FiberBuilder().setLength(BigDecimal.valueOf(length)).setLengthUnits(Km.class)
382 .setAttIn(BigDecimal.valueOf(attIn)).setLossCoef(BigDecimal.valueOf(lossCoef))
383 .setConIn(BigDecimal.valueOf(connIn))
384 .setConOut(BigDecimal.valueOf(connOut)).build();
385 Params params1 = new ParamsBuilder().setFiberroadm(fiber).build();
386 return new ElementsBuilder().setUid(uidFiber)
387 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Fiber.class)
388 .setTypeVariety(typeVariety).setMetadata(metadata1)
389 .setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
393 * Method to create EDFA
395 private Elements createElementsEdfa(double latitude, double longitude, String region, String city,
396 BigDecimal gainTarget, BigDecimal tiltTarget, BigDecimal outVoa, String typeVariety, String uidEdfa) {
397 // Create an amplifier after the ROADM
398 Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
399 Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
400 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
402 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
403 Operational operational = new OperationalBuilder().setGainTarget(gainTarget).setTiltTarget(tiltTarget)
404 .setOutVoa(outVoa).build();
405 Edfa edfa = new EdfaBuilder()
406 .setOperational(operational).build();
407 return new ElementsBuilder().setUid(uidEdfa)
408 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Edfa.class)
409 .setMetadata(metadata1).setElementType(edfa).setTypeVariety(typeVariety).build();
413 * Method to create ROADM
415 private Elements createElementsRoadm(double latitude, double longitude, String region, String city,
416 double targetPchOutDb, String uidRoadm) {
418 Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
419 Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
420 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
422 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
423 Roadm roadm = new RoadmBuilder().setTargetPchOutDb(BigDecimal.valueOf(targetPchOutDb)).build();
424 Params params1 = new ParamsBuilder().setFiberroadm(roadm).build();
425 return new ElementsBuilder().setUid(uidRoadm)
426 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Roadm.class)
427 .setMetadata(metadata1).setElementType(new FiberRoadmBuilder().setParams(params1).build()).build();
431 * Method to create Transceiver
433 private Elements createElementsTransceiver(double latitude, double longitude, String region, String city,
435 Coordinate c1 = new Coordinate(BigDecimal.valueOf(latitude));
436 Coordinate c2 = new Coordinate(BigDecimal.valueOf(longitude));
437 Location location1 = new LocationBuilder().setRegion(region).setCity(city).setLatitude(c1).setLongitude(c2)
439 Metadata metadata1 = new MetadataBuilder().setLocation(location1).build();
440 Transceiver transceiver = new TransceiverBuilder().build();
441 return new ElementsBuilder().setUid(uidTrans)
442 .setType(org.opendaylight.yang.gen.v1.gnpy.gnpy.network.topology.rev181214.Transceiver.class)
443 .setMetadata(metadata1).setElementType(transceiver).build();
447 * Method to create Connection
449 private boolean createNewConnection(IpAddress srcIp, IpAddress destIp) throws GnpyException {
450 if (srcIp == null || destIp == null) {
451 throw new GnpyException("create new connection : null node IpAddress");
453 String fromNode = srcIp.getIpv4Address().getValue();
454 String toNode = destIp.getIpv4Address().getValue();
455 if (fromNode.equals(toNode)) {
458 Connections connection = new ConnectionsBuilder().setFromNode(fromNode).setToNode(toNode).build();
459 this.connections.add(connection);
464 * Increment 32-bit identifier
466 private Ipv4Address incrementIdentifier(Ipv4Address id) throws GnpyException {
467 String ips = id.getValue();
468 String [] fields = ips.split(Pattern.quote("."));
469 int intF1 = Integer.parseInt(fields[1]);
470 int intF2 = Integer.parseInt(fields[2]);
471 int intF3 = Integer.parseInt(fields[3]);
484 throw new GnpyException("GnpyTopoImpl : the topology is not supported by gnpy");
486 fields[1] = Integer.toString(intF1);
488 fields[2] = Integer.toString(intF2);
490 fields[3] = Integer.toString(intF3);
491 String nidString = fields[0] + "." + fields[1] + "." + fields[2] + "." + fields[3];
492 return new Ipv4Address(nidString);
495 public List<Elements> getElements() {
499 public void setElements(List<Elements> elements) {
500 this.elements = elements;
503 public List<Connections> getConnections() {
507 public void setConnections(List<Connections> connections) {
508 this.connections = connections;
511 public Map<String, String> getMapDisgNodeRefNode() {
512 return mapDisgNodeRefNode;
515 public void setMapDisgNodeRefNode(Map<String, String> mapDisgNodeRefNode) {
516 this.mapDisgNodeRefNode = mapDisgNodeRefNode;
519 public Map<String, IpAddress> getMapNodeRefIp() {
523 public void setMapNodeRefIp(Map<String, IpAddress> mapNodeRefIp) {
524 this.mapNodeRefIp = mapNodeRefIp;
527 public Map<String, List<String>> getMapLinkFiber() {
531 public void setMapLinkFiber(Map<String, List<String>> mapLinkFiber) {
532 this.mapLinkFiber = mapLinkFiber;
535 public Map<String, IpAddress> getMapFiberIp() {
539 public void setMapFiberIp(Map<String, IpAddress> mapFiberIp) {
540 this.mapFiberIp = mapFiberIp;
543 public List<String> getTrxList() {
547 public void setTrxList(List<String> trxList) {
548 this.trxList = trxList;