2 * Copyright © 2017 AT&T 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.renderer.mapping;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import java.util.ArrayList;
14 import java.util.List;
15 import java.util.concurrent.ExecutionException;
16 import java.util.concurrent.TimeUnit;
17 import java.util.concurrent.TimeoutException;
18 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
19 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
20 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
21 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
22 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
23 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
24 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
25 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaces;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.NodeTypes;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.PortsKey;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.DegreeKey;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.Interfaces;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.InterfaceType;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpenROADMOpticalMultiplex;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpticalTransport;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.Network;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.NetworkBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.Nodes;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.NodesBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.NodesKey;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.Mapping;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingKey;
51 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
52 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
53 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
54 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
55 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
56 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
57 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
58 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
59 import org.slf4j.Logger;
60 import org.slf4j.LoggerFactory;
62 public class PortMapping {
64 private static final Logger LOG = LoggerFactory.getLogger(PortMapping.class);
65 private final DataBroker db;
66 private final MountPointService mps;
67 private final String nodeId;
69 public PortMapping(DataBroker db, MountPointService mps, String nodeId) {
77 * This method creates logical to physical port mapping for a given device.
78 * Instead of parsing all the circuit packs/ports in the device this methods
79 * does a selective read operation on degree/srg subtree to get circuit
80 * packs/ports that map to :
83 * 1. DEGn-TTP-TX, DEGn-TTP-RX, DEGn-TTP-TXRX
86 * 2. SRGn-PPp-TX, SRGn-PPp-RX, SRGn-PPp-TXRX
95 * If the port is Mw it also store the OMS, OTS interface provisioned on the
96 * port. It skips the logical ports that are internal. If operation is
97 * successful the mapping gets stored in datastore corresponding to
98 * portmapping.yang data model.
100 * @return true/false based on status of operation
102 public boolean createMappingData() {
104 LOG.info("Create Mapping Data for node " + nodeId);
105 DataBroker deviceDb = getDeviceDataBroker(nodeId, mps);
106 List<Mapping> portMapList = new ArrayList<>();
108 Integer nodeType = 1;
109 if (deviceDb != null) {
110 deviceInfo = getDeviceInfo(deviceDb);
111 if (deviceInfo != null) {
112 if (deviceInfo.getNodeType() == null) {
113 LOG.info("Node type mandatory field is missing");
116 nodeType = deviceInfo.getNodeType().getIntValue();
117 // Create Mapping for Roadm Node
119 // Get TTP port mapping
120 if (!createTtpPortMapping(deviceDb, deviceInfo, portMapList)) {
121 // return false if mapping creation for TTP's failed
122 LOG.info("Unable to create mapping for TTP's");
126 // Get PP port mapping
127 if (!createPpPortMapping(deviceDb, deviceInfo, portMapList)) {
128 // return false if mapping creation for PP's failed
129 LOG.info("Unable tp create mapping for PP's");
133 // Create Mapping for Xponder Node
135 if (!createXpdrPortMapping(deviceDb, deviceInfo, portMapList)) {
136 LOG.info("Unable to create mapping for Xponder");
141 LOG.info("Device info subtree is absent for " + nodeId);
146 LOG.info("Unable to get Data broker for node " + nodeId);
149 return postPortMapping(deviceInfo, portMapList, nodeType);
153 * This method removes mapping data from the datastore after disconnecting
154 * ODL from a Netconf device.
156 public void deleteMappingData() {
157 LOG.info("Deleting Mapping Data corresponding at node " + nodeId);
158 WriteTransaction rw = db.newWriteOnlyTransaction();
159 InstanceIdentifier<Nodes> nodesIID = InstanceIdentifier.create(Network.class)
160 .child(Nodes.class, new NodesKey(nodeId));
161 rw.delete(LogicalDatastoreType.CONFIGURATION, nodesIID);
163 rw.submit().get(1, TimeUnit.SECONDS);
164 LOG.info("Port mapping removal for node " + nodeId);
165 } catch (InterruptedException | ExecutionException | TimeoutException e) {
166 LOG.error("Error for removing port mapping infos for node " + nodeId);
171 * This private method gets the list of external ports on a degree. For each
172 * port in the degree, it does a get on port subtree with
173 * circuit-pack-name/port-name as key in order to get the logical connection
174 * point name corresponding to it.
177 * Reference to device's databroker
179 * Info subtree read from the device
181 * Reference to the list containing the mapping to be pushed to
184 * @return true/false based on status of operation
186 private boolean createTtpPortMapping(DataBroker deviceDb, Info deviceInfo, List<Mapping> portMapList) {
187 // Creating mapping data for degree TTP's
188 List<ConnectionPorts> degreeConPorts = getDegreePorts(deviceDb, deviceInfo);
190 // Getting circuit-pack-name/port-name corresponding to TTP's
191 for (ConnectionPorts cp : degreeConPorts) {
192 String circuitPackName = cp.getCircuitPackName();
193 String portName = cp.getPortName().toString();
194 InstanceIdentifier<Ports> portIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
195 CircuitPacks.class, new CircuitPacksKey(circuitPackName)).child(Ports.class, new PortsKey(portName));
197 LOG.info("Fetching logical Connection Point value for port " + portName + " at circuit pack "
199 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
200 Optional<Ports> portObject = rtx.read(LogicalDatastoreType.OPERATIONAL, portIID).get();
201 if (portObject.isPresent()) {
202 Ports port = portObject.get();
203 if (port.getLogicalConnectionPoint() != null) {
205 LOG.info("Logical Connection Point for " + circuitPackName + " " + portName + " is " + port
206 .getLogicalConnectionPoint());
207 portMapList.add(createMappingObject(port, circuitPackName, port.getLogicalConnectionPoint(),
211 LOG.warn("Logical Connection Point value missing for " + circuitPackName + " " + port
215 } catch (InterruptedException | ExecutionException ex) {
216 LOG.warn("Read failed for Logical Connection Point value missing for " + circuitPackName + " "
225 * This private method gets the list of circuit packs on an Srg. For each
226 * circuit pack on an Srg, it does a get on circuit-pack subtree with
227 * circuit-pack-name as key in order to get the list of ports. It then
228 * iterates over the list of ports to get ports with port-qual as
229 * roadm-external. It appends a TX,RX,TXRX to the logical connection point
230 * name based on the direction of the port.
233 * Reference to device's databroker
235 * Info subtree read from the device
237 * Reference to the list containing the mapping to be pushed to
240 * @return true/false based on status of operation
243 private boolean createPpPortMapping(DataBroker deviceDb, Info deviceInfo, List<Mapping> portMapList) {
244 // Creating mapping data for degree PP's
245 List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> srgCps = getSrgCps(
246 deviceDb, deviceInfo);
248 for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks cps : srgCps) {
249 String circuitPackName = cps.getCircuitPackName();
251 InstanceIdentifier<CircuitPacks> cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
252 CircuitPacks.class, new CircuitPacksKey(circuitPackName));
253 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
254 Optional<CircuitPacks> circuitPackObject = rtx.read(LogicalDatastoreType.OPERATIONAL, cpIID).get();
256 if (circuitPackObject.isPresent()) {
257 CircuitPacks cp = circuitPackObject.get();
258 if (cp.getPorts() == null) {
259 LOG.warn("No port found for {} {}: {}", deviceInfo.getNodeId(), circuitPackName, cp);
260 } else if (!cp.getPorts().isEmpty()) {
261 for (Ports port : cp.getPorts()) {
263 if (port.getLogicalConnectionPoint() != null && port.getPortQual().getIntValue() == 2) {
264 String logicalConnectionPoint = null;
265 if (port.getPortDirection().getIntValue() == 1) {
266 // Port direction is transmit
267 logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TX";
269 if (port.getPortDirection().getIntValue() == 2) {
270 // Port direction is receive
271 logicalConnectionPoint = port.getLogicalConnectionPoint() + "-RX";
273 if (port.getPortDirection().getIntValue() == 3) {
274 // port is bi-directional
275 logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TXRX";
278 LOG.info("Logical Connection Point for " + circuitPackName + " " + port.getPortName()
279 + " is " + logicalConnectionPoint);
281 portMapList.add(createMappingObject(port, circuitPackName, logicalConnectionPoint,
284 } else if (port.getPortQual().getIntValue() == 1) {
286 LOG.info("Port is internal, skipping Logical Connection Point missing for "
287 + circuitPackName + " " + port.getPortName());
289 } else if (port.getLogicalConnectionPoint() == null) {
291 LOG.info("Value missing, Skipping Logical Connection Point missing for "
292 + circuitPackName + " " + port.getPortName());
300 } catch (InterruptedException | ExecutionException ex) {
301 LOG.warn("Read failed for " + circuitPackName, ex);
310 * This private method gets the list of circuit packs on a xponder. For each
311 * circuit pack on a Xponder, it does a get on circuit-pack subtree with
312 * circuit-pack-name as key in order to get the list of ports. It then
313 * iterates over the list of ports to get ports with port-qual as
314 * xpdr-network/xpdr-client. The line and client ports are saved as:
323 * Reference to device's databroker
325 * Info subtree read from the device
327 * Reference to the list containing the mapping to be pushed to
330 * @return true/false based on status of operation
333 private boolean createXpdrPortMapping(DataBroker deviceDb, Info deviceInfo, List<Mapping> portMapList) {
334 // Creating for Xponder Line and Client Ports
336 InstanceIdentifier<OrgOpenroadmDevice> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class);
337 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
338 Optional<OrgOpenroadmDevice> deviceObject = rtx.read(LogicalDatastoreType.OPERATIONAL, deviceIID).get();
340 // Variable to keep track of number of line ports
342 // Variable to keep track of number of client ports
344 if (deviceObject.isPresent()) {
345 for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) {
346 String circuitPackName = cp.getCircuitPackName();
347 if (cp.getPorts() == null) {
348 LOG.warn("No port found for {}, circuit pack {}", deviceInfo.getNodeId(), circuitPackName);
350 for (Ports port : cp.getPorts()) {
351 if (port.getPortQual() != null) {
352 if (port.getPortQual().getIntValue() == 3) {
353 // Port is xpdr-network
354 portMapList.add(createMappingObject(port, circuitPackName, "XPDR-LINE"
356 LOG.info("Logical Connection Point for {} {} is XPDR-LINE{}", circuitPackName, port
357 .getPortName(), line);
360 if (port.getPortQual().getIntValue() == 4) {
361 // port is xpdr-client
362 portMapList.add(createMappingObject(port, circuitPackName, "XPDR-CLNT"
363 + client, deviceDb));
364 LOG.info("Logical Connection Point for {} {} is XPDR-CLNT{}", circuitPackName, port
365 .getPortName(), client);
369 LOG.info("no PortQual for port {} of circuit pack {}", port.getPortName(), cp
370 .getCircuitPackName());
376 LOG.info("No deviceObject present for {}", nodeId);
380 } catch (InterruptedException | ExecutionException ex) {
381 LOG.warn("Read failed for CircuitPacks of {}", nodeId, ex);
388 * This private method builds the mapping object to be pushed in MD-SAL in
389 * order to save port mapping. In case of TTP ports, it also saves the
390 * OTS,OMS interfaces provisioned on the port.
393 * Reference to device's port subtree object.
394 * @param circuitPackName
395 * Name of cp where port exists.
396 * @param logicalConnectionPoint
397 * logical name of the port.
399 * Reference to device's databroker.
401 * @return true/false based on status of operation
404 private Mapping createMappingObject(Ports port, String circuitPackName, String logicalConnectionPoint,
405 DataBroker deviceDb) {
406 MappingBuilder mpBldr = new MappingBuilder();
407 mpBldr.setKey(new MappingKey(logicalConnectionPoint)).setLogicalConnectionPoint(logicalConnectionPoint)
408 .setSupportingCircuitPackName(circuitPackName).setSupportingPort(port.getPortName());
410 // Get OMS and OTS interface provisioned on the TTP's
411 if (logicalConnectionPoint.contains("TTP") && port.getInterfaces() != null) {
412 for (Interfaces interfaces : port.getInterfaces()) {
413 Class<? extends InterfaceType> interfaceType = new OpenRoadmInterfaces(db, mps, nodeId,
414 logicalConnectionPoint).getInterface(interfaces.getInterfaceName()).getType();
415 // Check if interface type is OMS or OTS
416 if (interfaceType.equals(OpenROADMOpticalMultiplex.class)) {
417 String omsInterfaceName = interfaces.getInterfaceName();
418 mpBldr.setSupportingOms(omsInterfaceName);
420 if (interfaceType.equals(OpticalTransport.class)) {
421 String otsInterfaceName = interfaces.getInterfaceName();
422 mpBldr.setSupportingOts(otsInterfaceName);
426 return mpBldr.build();
430 * This method does a get operation on info subtree of the netconf device's
431 * configuration datastore and returns info object.It is required to get
432 * device attributes such as maxDegrees,maxSrgs and node-type.
435 * Reference to device's databroker
436 * @return Info object
439 private Info getDeviceInfo(DataBroker deviceDb) {
440 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
441 InstanceIdentifier<Info> infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class);
443 Optional<Info> ordmInfoObject = rtx.read(LogicalDatastoreType.OPERATIONAL, infoIID).get();
444 if (ordmInfoObject.isPresent()) {
445 LOG.info("Info subtree is present {}", ordmInfoObject.get());
446 return ordmInfoObject.get();
448 LOG.error("Info subtree is not present");
450 } catch (NullPointerException ex) {
451 LOG.warn("Try to get Info from a non Open ROADM device {}", deviceDb);
453 } catch (InterruptedException | ExecutionException ex) {
454 LOG.error("Read failed on info subtree ", ex);
461 * This method does a get operation on degree subtree of the netconf
462 * device's config datastore and returns a list of all connection port
463 * objects. It is required for doing a selective get on ports that
464 * correspond to logical connection points of interest.
467 * Reference to device's databroker
469 * Info subtree from the device
470 * @return List of connection ports object belonging to- degree subtree
472 private List<ConnectionPorts> getDegreePorts(DataBroker deviceDb, Info ordmInfo) {
474 List<ConnectionPorts> degreeConPorts = new ArrayList<>();
475 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
478 // Get value for max degree from info subtree, required for iteration
479 // if not present assume to be 20 (temporary)
480 if (ordmInfo.getMaxDegrees() != null) {
481 maxDegree = ordmInfo.getMaxDegrees();
485 Integer degreeCounter = 1;
486 while (degreeCounter <= maxDegree) {
487 LOG.info("Getting Connection ports for Degree Number " + degreeCounter);
488 InstanceIdentifier<Degree> deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
489 Degree.class, new DegreeKey(degreeCounter));
491 Optional<Degree> ordmDegreeObject = rtx.read(LogicalDatastoreType.CONFIGURATION, deviceIID).get();
493 if (ordmDegreeObject.isPresent()) {
494 degreeConPorts.addAll(new ArrayList<>(ordmDegreeObject.get().getConnectionPorts()));
497 LOG.info("Device has " + (degreeCounter - 1) + " degree");
500 } catch (InterruptedException | ExecutionException ex) {
501 LOG.error("Failed to read degree " + degreeCounter, ex);
507 return degreeConPorts;
511 * This method does a get operation on shared risk group subtree of the
512 * netconf device's config datastore and returns a list of all circuit packs
513 * objects that are part of srgs. It is required to do a selective get on
514 * all the circuit packs that contain add/drop ports of interest.
517 * Reference to device's databroker
519 * Info subtree from the device
520 * @return List of circuit packs object belonging to- shared risk group
524 private List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> getSrgCps(
525 DataBroker deviceDb, Info ordmInfo) {
527 List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks> srgCps =
529 ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction();
531 // Get value for max Srg from info subtree, required for iteration
532 // if not present assume to be 20 (temporary)
533 if (ordmInfo.getMaxSrgs() != null) {
534 maxSrg = ordmInfo.getMaxSrgs();
539 Integer srgCounter = 1;
540 while (srgCounter <= maxSrg) {
541 LOG.info("Getting Circuitpacks for Srg Number " + srgCounter);
542 InstanceIdentifier<SharedRiskGroup> srgIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
543 SharedRiskGroup.class, new SharedRiskGroupKey(srgCounter));
545 Optional<SharedRiskGroup> ordmSrgObject = rtx.read(LogicalDatastoreType.CONFIGURATION, srgIID).get();
547 if (ordmSrgObject.isPresent()) {
550 new ArrayList<>(ordmSrgObject.get().getCircuitPacks()));
553 LOG.info("Device has " + (srgCounter - 1) + " Srg");
556 } catch (InterruptedException | ExecutionException ex) {
557 LOG.warn("Failed to read Srg " + srgCounter, ex);
567 * This method for ports the portMapping corresponding to the
568 * portmapping.yang file to the MD-SAL datastore.
571 * 1. Supporting circuit pack 2. Supporting port 3. Supporting OMS interface
575 * Info subtree from the device.
577 * Reference to the list containing the mapping to be pushed to
580 * @return Result true/false based on status of operation.
582 private boolean postPortMapping(Info deviceInfo, List<Mapping> portMapList, Integer nodeType) {
584 NodesBuilder nodesBldr = new NodesBuilder();
585 nodesBldr.setKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId());
586 nodesBldr.setNodeType(NodeTypes.forValue(nodeType));
587 nodesBldr.setMapping(portMapList);
588 List<Nodes> nodesList = new ArrayList<>();
589 nodesList.add(nodesBldr.build());
590 NetworkBuilder nwBldr = new NetworkBuilder();
591 nwBldr.setNodes(nodesList);
592 final WriteTransaction writeTransaction = db.newWriteOnlyTransaction();
593 InstanceIdentifier<Network> nodesIID = InstanceIdentifier.builder(Network.class).build();
594 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, nwBldr.build());
595 CheckedFuture<Void, TransactionCommitFailedException> submit = writeTransaction.submit();
600 } catch (TransactionCommitFailedException e) {
601 LOG.warn("Failed to post {} ", nwBldr.build(), e);
608 * This method for a given node's termination point returns the Mapping
609 * object based on portmapping.yang model stored in the MD-SAL data store
610 * which is created when the node is connected for the first time. The
611 * mapping object basically contains the following attributes of interest:
614 * 1. Supporting circuit pack
620 * 3. Supporting OMS interface (if port on ROADM) 4. Supporting OTS
621 * interface (if port on ROADM)
624 * Unique Identifier for the node of interest.
625 * @param logicalConnPoint
626 * Name of the logical point
628 * Databroker / MD-SAL data store
630 * @return Result Mapping object if success otherwise null.
632 public static Mapping getMapping(String nodeId, String logicalConnPoint, DataBroker db) {
635 * Getting physical mapping corresponding to logical connection point
637 InstanceIdentifier<Mapping> portMapping = InstanceIdentifier.builder(Network.class).child(Nodes.class,
638 new NodesKey(nodeId)).child(Mapping.class, new MappingKey(logicalConnPoint)).build();
639 ReadOnlyTransaction readTx = db.newReadOnlyTransaction();
640 Optional<Mapping> mapObject;
642 mapObject = readTx.read(LogicalDatastoreType.CONFIGURATION, portMapping).get();
643 if (mapObject.isPresent()) {
644 LOG.info("Found mapping for the logical port " + mapObject.get().toString());
645 return mapObject.get();
647 LOG.info("Could not find mapping for logical connection point : " + logicalConnPoint + " for nodeId "
651 } catch (InterruptedException | ExecutionException ex) {
652 LOG.error("Unable to read mapping for logical connection point : " + logicalConnPoint + " for nodeId "
659 * This static method returns the DataBroker for a netconf node.
662 * Unique identifier for the mounted netconf- node
664 * Reference to mount service
665 * @return Databroker for the given device
667 public static DataBroker getDeviceDataBroker(String nodeId, MountPointService mps) {
668 MountPoint netconfNode = getDeviceMountPoint(nodeId, mps);
669 if (netconfNode != null) {
670 DataBroker netconfNodeDataBroker = netconfNode.getService(DataBroker.class).get();
671 return netconfNodeDataBroker;
673 LOG.error("Device Data broker not found for :" + nodeId);
678 public static MountPoint getDeviceMountPoint(String nodeId, MountPointService mps) {
679 InstanceIdentifier<Node> netconfNodeIID = InstanceIdentifier.builder(NetworkTopology.class).child(
680 Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))).child(Node.class,
681 new NodeKey(new NodeId(nodeId))).build();
683 // Get mount point for specified device
684 final Optional<MountPoint> netconfNodeOptional = mps.getMountPoint(netconfNodeIID);
685 if (netconfNodeOptional.isPresent()) {
686 MountPoint netconfNode = netconfNodeOptional.get();
689 LOG.error("Mount Point not found for :" + nodeId);