+ } catch (TransactionCommitFailedException e) {
+ LOG.warn("Failed to post {} ", nwBldr.build(), e);
+ return false;
+
+ }
+ }
+
+ /**
+ * This method for a given node's termination point returns the Mapping
+ * object based on portmapping.yang model stored in the MD-SAL data store
+ * which is created when the node is connected for the first time. The
+ * mapping object basically contains the following attributes of interest:
+ *
+ * <p>
+ * 1. Supporting circuit pack
+ *
+ * <p>
+ * 2. Supporting port
+ *
+ * <p>
+ * 3. Supporting OMS interface (if port on ROADM) 4. Supporting OTS
+ * interface (if port on ROADM)
+ *
+ * @param nodeId
+ * Unique Identifier for the node of interest.
+ * @param logicalConnPoint
+ * Name of the logical point
+ *
+ * @return Result Mapping object if success otherwise null.
+ */
+ public static Mapping getMapping(String nodeId, String logicalConnPoint, DataBroker db) {
+
+ /*
+ * Getting physical mapping corresponding to logical connection point
+ */
+ InstanceIdentifier<Mapping> portMapping = InstanceIdentifier.builder(Network.class).child(Nodes.class,
+ new NodesKey(nodeId)).child(Mapping.class, new MappingKey(logicalConnPoint)).build();
+ ReadOnlyTransaction readTx = db.newReadOnlyTransaction();
+ Optional<Mapping> mapObject;
+ try {
+ mapObject = readTx.read(LogicalDatastoreType.CONFIGURATION, portMapping).get();
+ if (mapObject.isPresent()) {
+ LOG.info("Found mapping for the logical port " + mapObject.get().toString());
+ return mapObject.get();
+ } else {
+ LOG.info("Could not find mapping for logical connection point : " + logicalConnPoint + " for nodeId "
+ + nodeId);
+ return null;
+ }
+ } catch (InterruptedException | ExecutionException ex) {
+ LOG.info("Unable to read mapping for logical connection point : " + logicalConnPoint + " for nodeId "
+ + nodeId);
+ }
+ return null;
+ }
+
+ /**
+ * This static method returns the DataBroker for a netconf node.
+ *
+ * @param nodeId
+ * Unique identifier for the mounted netconf- node
+ * @param mps
+ * Reference to mount service
+ * @return Databroker for the given device
+ */