From: Dhruv Bhardwaj Date: Mon, 24 Apr 2017 18:57:24 +0000 (+0300) Subject: Update PortMapping & imports to v1.2.1 X-Git-Tag: v0.2.0~132^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=7088d43a03e07109eaee31194168e63a9c147ece Update PortMapping & imports to v1.2.1 1. Updated code to Device model version 1.2.1. 2. Updated portmapping to store OTS interface required for spanloss measurement. 3. Updated portmapping to handle uni-directional PP ports by appending TX/RX/TXRX based on direction of th port. 4. Updated portmapping to create mapping for xponder line and client ports. Signed-off-by: Dhruv Bhardwaj Change-Id: Icb440866648d4d1c50f12d9684c1321003f96da7 --- diff --git a/api/src/main/yang/portmapping.yang b/api/src/main/yang/portmapping.yang index 5a0a36545..d2fba6e2e 100644 --- a/api/src/main/yang/portmapping.yang +++ b/api/src/main/yang/portmapping.yang @@ -37,6 +37,11 @@ module portmapping { description "OMS interface provisioned on the port"; } + leaf supporting-ots{ + type string; + description + "OTS interface provisioned on the port"; + } } } } diff --git a/ordmodels/pom.xml b/ordmodels/pom.xml index a63a34278..6946dfc0f 100644 --- a/ordmodels/pom.xml +++ b/ordmodels/pom.xml @@ -29,7 +29,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.mdsal.model iana-afn-safi - 2013.07.04.9.3-SNAPSHOT + 2013.07.04.9.4-SNAPSHOT org.opendaylight.mdsal.model @@ -38,7 +38,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.mdsal.model iana-if-type-2014-05-08 - 2014.05.08.9.3-SNAPSHOT + 2014.05.08.9.4-SNAPSHOT org.opendaylight.mdsal.model @@ -47,7 +47,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.mdsal.model ietf-interfaces - 2014.05.08.9.3-SNAPSHOT + 2014.05.08.9.4-SNAPSHOT org.opendaylight.mdsal.model diff --git a/ordmodels/src/main/yang/ietf-netconf-monitoring-extension.yang b/ordmodels/src/main/yang/ietf-netconf-monitoring-extension.yang deleted file mode 100644 index e8f2ec324..000000000 --- a/ordmodels/src/main/yang/ietf-netconf-monitoring-extension.yang +++ /dev/null @@ -1,31 +0,0 @@ -module ietf-netconf-monitoring-extension { - - yang-version 1; - - namespace - "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring-extension"; - - prefix ncme; - - import ietf-netconf-monitoring { - prefix ncm; - } - - revision "2013-12-10" { - description "Initial revision."; - - } - - identity netconf-tcp { - base ncm:transport; - description - "NETCONF over TCP."; - } - - augment "/ncm:netconf-state/ncm:sessions/ncm:session" { - leaf session-identifier { - type string; - } - } - -} \ No newline at end of file diff --git a/ordmodels/src/main/yang/org-openroadm-device.yang b/ordmodels/src/main/yang/org-openroadm-device.yang index d633b1572..03d96597d 100644 --- a/ordmodels/src/main/yang/org-openroadm-device.yang +++ b/ordmodels/src/main/yang/org-openroadm-device.yang @@ -85,6 +85,11 @@ module org-openroadm-device { Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License."; + revision 2017-02-06 { + description + "Version 1.2.1 - removed pattern for current-datetime in info tree and rpc"; + } + revision 2016-10-14 { description "Version 1.2"; @@ -182,9 +187,7 @@ module org-openroadm-device { "Set the info/current-datetime leaf to the specified value."; input { leaf current-datetime { - type ietf-yang-types:date-and-time { - pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}'; - } + type ietf-yang-types:date-and-time; mandatory true; description "The current system date and time in UTC. Format: YYYY-MM-DDTHH:MM:SS"; @@ -288,9 +291,7 @@ module org-openroadm-device { "Template information used in the deployment."; } leaf current-datetime { - type ietf-yang-types:date-and-time { - pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'; - } + type ietf-yang-types:date-and-time; config false; description "The current system date and time in UTC. Format: YYYY-MM-DDTHH:MM:SS.mm+ "; @@ -1209,4 +1210,4 @@ module org-openroadm-device { } } // list edit } // notification change-notification -} +} \ No newline at end of file diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/RendererNotificationsImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/RendererNotificationsImpl.java index 90b12a93e..451c1a64a 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/RendererNotificationsImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/RendererNotificationsImpl.java @@ -40,7 +40,7 @@ import org.opendaylight.transportpce.renderer.mapping.PortMapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev161014.AlarmNotification; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev161014.OrgOpenroadmAlarmListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev161014.OrgOpenroadmDeOperationsListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.OrgOpenroadmDeviceListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.OrgOpenroadmLldpListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev161014.OrgOpenroadmTcaListener; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder; @@ -60,6 +60,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -229,4 +230,4 @@ public class RendererNotificationsImpl implements DataTreeChangeListener { } } } -} \ No newline at end of file +} diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/listeners/DeviceListener.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/listeners/DeviceListener.java index 4b0f45c05..2f57b3108 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/listeners/DeviceListener.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/listeners/DeviceListener.java @@ -8,9 +8,9 @@ package org.opendaylight.transportpce.renderer.listeners; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.ChangeNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.OrgOpenroadmDeviceListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.OtdrScanResult; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.ChangeNotification; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OtdrScanResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/mapping/PortMapping.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/mapping/PortMapping.java index c8fc2a1ac..7945cf4ed 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/mapping/PortMapping.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/mapping/PortMapping.java @@ -22,17 +22,23 @@ import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.pack.Ports; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.pack.PortsKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.packs.CircuitPacksKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.degree.ConnectionPorts; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.Degree; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.DegreeKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.PortsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.degree.ConnectionPorts; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Degree; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.DegreeKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.Interfaces; +import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.InterfaceType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpenROADMOpticalMultiplex; +import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpticalTransport; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.Network; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.NetworkBuilder; @@ -58,7 +64,6 @@ public class PortMapping { private static final Logger LOG = LoggerFactory.getLogger(PortMapping.class); private final DataBroker db; private final MountPointService mps; - private final String nodeId; public PortMapping(DataBroker db, MountPointService mps, String nodeId) { @@ -69,163 +74,364 @@ public class PortMapping { } /** - * This method creates logical to physical port mapping - * for a given device. - * Instead of parsing all the circuit packs/ports in the device - * this methods does a selective read operation on degree/srg - * subtree to get circuit packs/ports that map to : - * DEGn-TTP-TX - * DEGn-TTP-RX - * DEGn-TTP-TXRX - * SRGn-PPp - * This methods skips the logical ports that are internal. - * if operation is successful the mapping gets stored in - * datastore corresponding to portmapping.yang data model. - * - * @return true/false based on status of operation - */ + * This method creates logical to physical port mapping for a given device. + * Instead of parsing all the circuit packs/ports in the device this methods + * does a selective read operation on degree/srg subtree to get circuit + * packs/ports that map to : + * + *

+ * 1. DEGn-TTP-TX, DEGn-TTP-RX, DEGn-TTP-TXRX + * + *

+ * 2. SRGn-PPp-TX, SRGn-PPp-RX, SRGn-PPp-TXRX + * + *

+ * 3. LINEn + * + *

+ * 4. CLNTn. + * + *

+ * If the port is Mw it also store the OMS, OTS interface provisioned on the + * port. It skips the logical ports that are internal. If operation is + * successful the mapping gets stored in datastore corresponding to + * portmapping.yang data model. + * + * @return true/false based on status of operation + */ public boolean createMappingData() { LOG.info(" Create Mapping Data for node " + nodeId); - DataBroker deviceDb = getDeviceDataBroker(nodeId, mps); Info deviceInfo = getDeviceInfo(deviceDb); - - InstanceIdentifier nodesIID = InstanceIdentifier.builder(Network.class).build(); - - NetworkBuilder nwBldr = new NetworkBuilder(); List portMapList = new ArrayList<>(); - List nodesList = new ArrayList<>(); - - if (deviceDb != null && deviceInfo != null) { - - // Creating mapping data for degree TTP's - List degreeConPorts = getDegreePorts(deviceDb, deviceInfo); - - //Getting circuit-pack-name/port-name corresponding to TTP's - for (ConnectionPorts cp : degreeConPorts) { - InstanceIdentifier portIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( - CircuitPacks.class, new CircuitPacksKey(cp.getCircuitPackName())).child(Ports.class, new PortsKey(cp - .getPortName().toString())); - try { - LOG.info("Fetching logical Connection Point value for port " + cp.getPortName().toString() - + " at circuit pack " + cp.getCircuitPackName()); - ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); - Optional portObject = rtx.read(LogicalDatastoreType.OPERATIONAL, portIID).get(); - - if (portObject.isPresent()) { - Ports port = portObject.get(); - if (port.getLogicalConnectionPoint() != null) { + if (deviceDb != null) { + if (deviceInfo != null) { + Integer nodeType = deviceInfo.getNodeType().getIntValue(); + // Create Mapping for Roadm Node + if (nodeType == 1) { + // Get TTP port mapping + if (!createTtpPortMapping(deviceDb, deviceInfo, portMapList)) { + // return false if mapping creation for TTP's failed + LOG.info("Unable to create mapping for TTP's"); + return false; + } - LOG.info("Logical Connection Point for " + cp.getCircuitPackName() + " " + port - .getPortName() + " is " + port.getLogicalConnectionPoint()); - MappingBuilder mpBldr = new MappingBuilder(); - mpBldr.setKey(new MappingKey(port.getLogicalConnectionPoint())).setLogicalConnectionPoint( - port.getLogicalConnectionPoint()).setSupportingCircuitPackName(cp.getCircuitPackName()) - .setSupportingPort(port.getPortName()); - portMapList.add(mpBldr.build()); + // Get PP port mapping + if (!createPpPortMapping(deviceDb, deviceInfo, portMapList)) { + // return false if mapping creation for PP's failed + LOG.info("Unable tp create mapping for PP's"); + return false; + } + } + // Create Mapping for Xponder Node + if (nodeType == 2) { + if (!createXpdrPortMapping(deviceDb, deviceInfo, portMapList)) { + LOG.info("Unable to create mapping for Xponder"); + return false; + } + } + } else { + LOG.info(" Device info subtree is absent for " + nodeId); + return false; + } - } else { + } else { + LOG.info(" Unable to get Data broker for node " + nodeId); + return false; + } + return postPortMapping(deviceInfo, portMapList); + } - LOG.warn("Logical Connection Point value missing for " + cp.getCircuitPackName() + " " - + port.getPortName()); - } + /** + * This private method gets the list of external ports on a degree. For each + * port in the degree, it does a get on port subtree with + * circuit-pack-name/port-name as key in order to get the logical connection + * point name corresponding to it. + * + * @param deviceDb + * Reference to device's databroker + * @param deviceInfo + * Info subtree read from the device + * @param portMapList + * Reference to the list containing the mapping to be pushed to + * MD-SAL + * + * @return true/false based on status of operation + */ + private boolean createTtpPortMapping(DataBroker deviceDb, Info deviceInfo, List portMapList) { + // Creating mapping data for degree TTP's + List degreeConPorts = getDegreePorts(deviceDb, deviceInfo); + + // Getting circuit-pack-name/port-name corresponding to TTP's + for (ConnectionPorts cp : degreeConPorts) { + String circuitPackName = cp.getCircuitPackName(); + String portName = cp.getPortName().toString(); + InstanceIdentifier portIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( + CircuitPacks.class, new CircuitPacksKey(circuitPackName)).child(Ports.class, new PortsKey(portName)); + try { + LOG.info("Fetching logical Connection Point value for port " + portName + " at circuit pack " + + circuitPackName); + ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); + Optional portObject = rtx.read(LogicalDatastoreType.OPERATIONAL, portIID).get(); + if (portObject.isPresent()) { + Ports port = portObject.get(); + if (port.getLogicalConnectionPoint() != null) { + + LOG.info("Logical Connection Point for " + circuitPackName + " " + portName + " is " + port + .getLogicalConnectionPoint()); + portMapList.add(createMappingObject(port, circuitPackName, port.getLogicalConnectionPoint(), + deviceDb)); + } else { + + LOG.warn("Logical Connection Point value missing for " + circuitPackName + " " + port + .getPortName()); } - } catch (InterruptedException | ExecutionException ex) { - LOG.warn("Read failed for Logical Connection Point value missing for " + cp.getCircuitPackName() - + " " + cp.getPortName()); } + } catch (InterruptedException | ExecutionException ex) { + LOG.warn("Read failed for Logical Connection Point value missing for " + circuitPackName + " " + + portName); + return false; } - // Creating mapping data for degree PP's - List srgCps = getSrgCps( - deviceDb, deviceInfo); - - for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.srg.CircuitPacks cps : srgCps) { - InstanceIdentifier cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( - CircuitPacks.class, new CircuitPacksKey(cps.getCircuitPackName())); - try { + } + return true; + } - ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); - Optional circuitPackObject = rtx.read(LogicalDatastoreType.OPERATIONAL, cpIID).get(); + /** + * This private method gets the list of circuit packs on an Srg. For each + * circuit pack on an Srg, it does a get on circuit-pack subtree with + * circuit-pack-name as key in order to get the list of ports. It then + * iterates over the list of ports to get ports with port-qual as + * roadm-external. It appends a TX,RX,TXRX to the logical connection point + * name based on the direction of the port. + * + * @param deviceDb + * Reference to device's databroker + * @param deviceInfo + * Info subtree read from the device + * @param portMapList + * Reference to the list containing the mapping to be pushed to + * MD-SAL + * + * @return true/false based on status of operation + */ - if (circuitPackObject.isPresent()) { - CircuitPacks circuitPack = circuitPackObject.get(); - if (!circuitPack.getPorts().isEmpty()) { - for (Ports port : circuitPack.getPorts()) { + private boolean createPpPortMapping(DataBroker deviceDb, Info deviceInfo, List portMapList) { + // Creating mapping data for degree PP's + List srgCps = getSrgCps( + deviceDb, deviceInfo); - if (port.getLogicalConnectionPoint() != null && port.getPortQual().getIntValue() == 2) { + for (org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks cps : srgCps) { + String circuitPackName = cps.getCircuitPackName(); + try { + InstanceIdentifier cpIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( + CircuitPacks.class, new CircuitPacksKey(circuitPackName)); + ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); + Optional circuitPackObject = rtx.read(LogicalDatastoreType.OPERATIONAL, cpIID).get(); + + if (circuitPackObject.isPresent()) { + CircuitPacks cp = circuitPackObject.get(); + if (!cp.getPorts().isEmpty()) { + for (Ports port : cp.getPorts()) { + + if (port.getLogicalConnectionPoint() != null && port.getPortQual().getIntValue() == 2) { + String logicalConnectionPoint = null; + if (port.getPortDirection().getIntValue() == 1) { + // Port direction is transmit + logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TX"; + } + if (port.getPortDirection().getIntValue() == 2) { + // Port direction is receive + logicalConnectionPoint = port.getLogicalConnectionPoint() + "-RX"; + } + if (port.getPortDirection().getIntValue() == 3) { + // port is bi-directional + logicalConnectionPoint = port.getLogicalConnectionPoint() + "-TXRX"; + } - LOG.info("Logical Connection Point for " + circuitPack.getCircuitPackName() + " " - + port.getPortName() + " is " + port.getLogicalConnectionPoint()); - MappingBuilder mpBldr = new MappingBuilder(); - mpBldr.setKey(new MappingKey(port.getLogicalConnectionPoint())) - .setLogicalConnectionPoint(port.getLogicalConnectionPoint()) - .setSupportingCircuitPackName(circuitPack.getCircuitPackName()) - .setSupportingPort(port.getPortName()); - portMapList.add(mpBldr.build()); + LOG.info("Logical Connection Point for " + circuitPackName + " " + port.getPortName() + + " is " + logicalConnectionPoint); - } else if (port.getPortQual().getIntValue() == 1) { + portMapList.add(createMappingObject(port, circuitPackName, logicalConnectionPoint, + deviceDb)); - LOG.info("Port is internal, skipping Logical Connection Point missing for " - + circuitPack.getCircuitPackName() + " " + port.getPortName()); + } else if (port.getPortQual().getIntValue() == 1) { - } else if (port.getLogicalConnectionPoint() == null) { + LOG.info("Port is internal, skipping Logical Connection Point missing for " + + circuitPackName + " " + port.getPortName()); - LOG.info("Value missing, Skipping Logical Connection Point missing for " - + circuitPack.getCircuitPackName() + " " + port.getPortName()); - } + } else if (port.getLogicalConnectionPoint() == null) { + LOG.info("Value missing, Skipping Logical Connection Point missing for " + + circuitPackName + " " + port.getPortName()); } } } - } catch (InterruptedException | ExecutionException ex) { - LOG.warn("Read failed for " + cps.getCircuitPackName()); - } + } + } catch (InterruptedException | ExecutionException ex) { + LOG.warn("Read failed for " + circuitPackName); + return false; } + } - NodesBuilder nodesBldr = new NodesBuilder(); - nodesBldr.setKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId()); - nodesBldr.setMapping(portMapList); - nodesList.add(nodesBldr.build()); - nwBldr.setNodes(nodesList); - final WriteTransaction writeTransaction = db.newWriteOnlyTransaction(); - writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, nwBldr.build()); - CheckedFuture submit = writeTransaction.submit(); - try { - submit.checkedGet(); - return true; + return true; + } - } catch (TransactionCommitFailedException e) { - LOG.warn("Failed to post {} ", nwBldr.build(), e); - return false; + /** + * This private method gets the list of circuit packs on a xponder. For each + * circuit pack on a Xponder, it does a get on circuit-pack subtree with + * circuit-pack-name as key in order to get the list of ports. It then + * iterates over the list of ports to get ports with port-qual as + * xpdr-network/xpdr-client. The line and client ports are saved as: + * + *

+ * 1. LINEn + * + *

+ * 2. CLNTn + * + * @param deviceDb + * Reference to device's databroker + * @param deviceInfo + * Info subtree read from the device + * @param portMapList + * Reference to the list containing the mapping to be pushed to + * MD-SAL + * + * @return true/false based on status of operation + */ + private boolean createXpdrPortMapping(DataBroker deviceDb, Info deviceInfo, List portMapList) { + // Creating for Xponder Line and Client Ports + try { + InstanceIdentifier deviceIID = InstanceIdentifier.create(OrgOpenroadmDevice.class); + ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); + Optional deviceObject = rtx.read(LogicalDatastoreType.OPERATIONAL, deviceIID).get(); + + // Variable to keep track of number of line ports + int line = 1; + // Variable to keep track of number of client ports + int client = 1; + if (deviceObject.isPresent()) { + for (CircuitPacks cp : deviceObject.get().getCircuitPacks()) { + String circuitPackName = cp.getCircuitPackName(); + for (Ports port : cp.getPorts()) { + if (port.getPortQual().getIntValue() == 3) { + // Port is xpdr-network + portMapList.add(createMappingObject(port, circuitPackName, "LINE" + line, deviceDb)); + line++; + } + if (port.getPortQual().getIntValue() == 4) { + // port is xpdr-client + portMapList.add(createMappingObject(port, circuitPackName, "CLNT" + client, deviceDb)); + client++; + } + } + } + } else { + LOG.info("Circuit Packs are not present for " + nodeId); + return false; } - } else { - LOG.info(" Unable to get Data broker for node " + nodeId); + + } catch (InterruptedException | ExecutionException ex) { + LOG.warn("Read failed for CircuitPacks of " + nodeId); return false; } + return true; + } + + /** + * This private method builds the mapping object to be pushed in MD-SAL in + * order to save port mapping. In case of TTP ports, it also saves the + * OTS,OMS interfaces provisioned on the port. + * + * @param port + * Reference to device's port subtree object. + * @param circuitPackName + * Name of cp where port exists. + * @param logicalConnectionPoint + * logical name of the port. + * @param deviceDb + * Reference to device's databroker. + * + * @return true/false based on status of operation + */ + private Mapping createMappingObject(Ports port, String circuitPackName, String logicalConnectionPoint, + DataBroker deviceDb) { + MappingBuilder mpBldr = new MappingBuilder(); + mpBldr.setKey(new MappingKey(logicalConnectionPoint)).setLogicalConnectionPoint(logicalConnectionPoint) + .setSupportingCircuitPackName(circuitPackName).setSupportingPort(port.getPortName()); + + // Get OMS and OTS interface provisioned on the TTP's + if (logicalConnectionPoint.contains("TTP") && port.getInterfaces() != null) { + for (Interfaces interfaces : port.getInterfaces()) { + Class interfaceType = getInterfaceType(deviceDb, interfaces + .getInterfaceName()); + // Check if interface type is OMS or OTS + if (interfaceType.equals(OpenROADMOpticalMultiplex.class)) { + String omsInterfaceName = interfaces.getInterfaceName(); + mpBldr.setSupportingOms(omsInterfaceName); + } + if (interfaceType.equals(OpticalTransport.class)) { + String otsInterfaceName = interfaces.getInterfaceName(); + mpBldr.setSupportingOts(otsInterfaceName); + } + } + } + return mpBldr.build(); } /** - * This method does a get operation on info subtree - * of the netconf device's config datastore and returns - * info object.It is required to get device attributes such - * as maxDegrees,maxSrgs. + * This private does a get on the interface subtree of the device with the + * interface name as the key and return the class corresponding to the + * interface type. * - * @param deviceDb Reference to device's databroker + * @param interfaceName + * Name of the interface + * @param deviceDb + * Reference to device's databroker. + * + * @return true/false based on status of operation + */ + + private Class getInterfaceType(DataBroker deviceDb, String interfaceName) { + ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); + InstanceIdentifier interfacesIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( + Interface.class, new InterfaceKey(interfaceName)); + try { + Optional interfaceObject = rtx.read(LogicalDatastoreType.OPERATIONAL, interfacesIID).get(); + if (interfaceObject.isPresent()) { + return interfaceObject.get().getType(); + } else { + LOG.info("Interface subtree is not present for " + interfaceName); + } + } catch (InterruptedException | ExecutionException ex) { + LOG.info("Read failed on interface subtree for"); + return null; + } + return null; + } + + /** + * This method does a get operation on info subtree of the netconf device's + * configuration datastore and returns info object.It is required to get + * device attributes such as maxDegrees,maxSrgs and node-type. + * + * @param deviceDb + * Reference to device's databroker * @return Info object * */ - public Info getDeviceInfo(DataBroker deviceDb) { + private Info getDeviceInfo(DataBroker deviceDb) { ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); InstanceIdentifier infoIID = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(Info.class); try { - Optional ordmInfoObject = rtx.read(LogicalDatastoreType.CONFIGURATION, infoIID).get(); + Optional ordmInfoObject = rtx.read(LogicalDatastoreType.OPERATIONAL, infoIID).get(); if (ordmInfoObject.isPresent()) { return ordmInfoObject.get(); } else { @@ -239,25 +445,25 @@ public class PortMapping { } /** - * This method does a get operation on degree subtree - * of the netconf device's config datastore and returns a list - * of all connection port objects. - * It is required for doing a selective get on ports that + * This method does a get operation on degree subtree of the netconf + * device's config datastore and returns a list of all connection port + * objects. It is required for doing a selective get on ports that * correspond to logical connection points of interest. * - * @param deviceDb Reference to device's databroker - * @param ordmInfo Info subtree from the device - * @return List of connection ports object belonging to- - * degree subtree + * @param deviceDb + * Reference to device's databroker + * @param ordmInfo + * Info subtree from the device + * @return List of connection ports object belonging to- degree subtree */ - public List getDegreePorts(DataBroker deviceDb, Info ordmInfo) { + private List getDegreePorts(DataBroker deviceDb, Info ordmInfo) { List degreeConPorts = new ArrayList<>(); ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); Integer maxDegree; - //Get value for max degree from info subtree, required for iteration - //if not present assume to be 20 (temporary) + // Get value for max degree from info subtree, required for iteration + // if not present assume to be 20 (temporary) if (ordmInfo.getMaxDegrees() != null) { maxDegree = ordmInfo.getMaxDegrees(); } else { @@ -289,27 +495,28 @@ public class PortMapping { } /** - * This method does a get operation on shared risk group subtree - * of the netconf device's config datastore and returns a list - * of all circuit packs objects that are part of srgs. - * It is required to do a selective get on all the circuit packs - * that contain add/drop ports of interest. + * This method does a get operation on shared risk group subtree of the + * netconf device's config datastore and returns a list of all circuit packs + * objects that are part of srgs. It is required to do a selective get on + * all the circuit packs that contain add/drop ports of interest. * - * @param deviceDb Reference to device's databroker - * @param ordmInfo Info subtree from the device - * @return List of circuit packs object belonging to- - * shared risk group subtree + * @param deviceDb + * Reference to device's databroker + * @param ordmInfo + * Info subtree from the device + * @return List of circuit packs object belonging to- shared risk group + * subtree */ - public List getSrgCps( + private List getSrgCps( DataBroker deviceDb, Info ordmInfo) { - List srgCps = + List srgCps = new ArrayList<>(); ReadOnlyTransaction rtx = deviceDb.newReadOnlyTransaction(); Integer maxSrg; - //Get value for max Srg from info subtree, required for iteration - //if not present assume to be 20 (temporary) + // Get value for max Srg from info subtree, required for iteration + // if not present assume to be 20 (temporary) if (ordmInfo.getMaxSrgs() != null) { maxSrg = ordmInfo.getMaxSrgs(); } else { @@ -327,8 +534,8 @@ public class PortMapping { if (ordmSrgObject.isPresent()) { srgCps.addAll( - new ArrayList(ordmSrgObject.get().getCircuitPacks())); + new ArrayList(ordmSrgObject.get().getCircuitPacks())); } else { LOG.info("Device has " + (srgCounter - 1) + " Srg"); @@ -345,15 +552,103 @@ public class PortMapping { } /** - * This static method returns the DataBroker for a netconf - * node. + * This method for ports the portMapping corresponding to the + * portmapping.yang file to the MD-SAL datastore. * - * @param nodeId Unique identifier for the mounted netconf- - * node - * @param mps Reference to mount service - * @return Databroker for the given device + *

+ * 1. Supporting circuit pack 2. Supporting port 3. Supporting OMS interface + * (if port on ROADM) + * + * @param deviceInfo + * Info subtree from the device. + * @param portMapList + * Reference to the list containing the mapping to be pushed to + * MD-SAL. + * + * @return Result true/false based on status of operation. */ + private boolean postPortMapping(Info deviceInfo, List portMapList) { + + List nodesList = new ArrayList<>(); + NodesBuilder nodesBldr = new NodesBuilder(); + nodesBldr.setKey(new NodesKey(deviceInfo.getNodeId())).setNodeId(deviceInfo.getNodeId()); + nodesBldr.setMapping(portMapList); + nodesList.add(nodesBldr.build()); + NetworkBuilder nwBldr = new NetworkBuilder(); + nwBldr.setNodes(nodesList); + final WriteTransaction writeTransaction = db.newWriteOnlyTransaction(); + InstanceIdentifier nodesIID = InstanceIdentifier.builder(Network.class).build(); + writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, nwBldr.build()); + CheckedFuture submit = writeTransaction.submit(); + try { + submit.checkedGet(); + return true; + } 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: + * + *

+ * 1. Supporting circuit pack + * + *

+ * 2. Supporting port + * + *

+ * 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 portMapping = InstanceIdentifier.builder(Network.class).child(Nodes.class, + new NodesKey(nodeId)).child(Mapping.class, new MappingKey(logicalConnPoint)).build(); + ReadOnlyTransaction readTx = db.newReadOnlyTransaction(); + Optional 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 + */ public static DataBroker getDeviceDataBroker(String nodeId, MountPointService mps) { InstanceIdentifier netconfNodeIID = InstanceIdentifier.builder(NetworkTopology.class).child( Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))).child(Node.class, diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java index e5fb17932..6df6ddb27 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRenderer.java @@ -23,14 +23,14 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.transportpce.renderer.mapping.PortMapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticalControlMode; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.connection.DestinationBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.connection.SourceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.interfaces.grp.InterfaceKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.RoadmConnections; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.DestinationBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.connection.SourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnections; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.org.openroadm.device.RoadmConnectionsKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutput; @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -257,4 +258,4 @@ public class DeviceRenderer implements RendererService { return delServBldr.setResult("Request processed"); } -} \ No newline at end of file +} diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OpenRoadmInterfaces.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OpenRoadmInterfaces.java index 39e64da57..0a2a612fa 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OpenRoadmInterfaces.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/OpenRoadmInterfaces.java @@ -21,15 +21,15 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.transportpce.renderer.mapping.PortMapping; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.pack.Ports; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.pack.PortsKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.circuit.packs.CircuitPacksKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.interfaces.grp.InterfaceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.interfaces.grp.InterfaceKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev161014.port.Interfaces; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.PortsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacks; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.packs.CircuitPacksKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.port.Interfaces; import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OpticalChannel; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.Interface1; import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.Interface1Builder; @@ -41,6 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapp import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.MappingKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -293,4 +295,4 @@ public class OpenRoadmInterfaces { } return null; } -} \ No newline at end of file +}