Wrong Tp designation in DeviceRenderer.java
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / DeviceRenderer.java
index da94656ed207d1c7e980d86740971bd7e2d0125b..ee4caacfc7c76fcc3aeea4e95e132ea52a63c462 100644 (file)
@@ -48,22 +48,20 @@ public class DeviceRenderer implements RendererService {
 
     /**
      * This method is the implementation of the 'service-path' RESTCONF service,
-     * which is one of the external APIs into the renderer application. The
-     * service provides two functions:
+     * which is one of the external APIs into the renderer application. The service
+     * provides two functions:
      *
      * <p>
      * 1. Create This operation results in provisioning the device for a given
-     * wavelength and a list of nodes with each node listing its termination
-     * points.
+     * wavelength and a list of nodes with each node listing its termination points.
      *
      * <p>
-     * 2. Delete This operation results in de-provisioning the device for a
-     * given wavelength and a list of nodes with each node listing its
-     * termination points.
+     * 2. Delete This operation results in de-provisioning the device for a given
+     * wavelength and a list of nodes with each node listing its termination points.
      *
      * <p>
-     * The signature for this method was generated by yang tools from the
-     * renderer API model.
+     * The signature for this method was generated by yang tools from the renderer
+     * API model.
      *
      * @param input
      *            Input parameter from the service-path yang model
@@ -84,13 +82,12 @@ public class DeviceRenderer implements RendererService {
     }
 
     /**
-     * This method set's wavelength path based on following steps: For each
-     * node:
+     * This method set's wavelength path based on following steps: For each node:
      *
      * <p>
-     * 1. Create Och interface on source termination point. 2. Create Och
-     * interface on destination termination point. 3. Create cross connect
-     * between source and destination tps created in step 1 and 2.
+     * 1. Create Och interface on source termination point. 2. Create Och interface
+     * on destination termination point. 3. Create cross connect between source and
+     * destination tps created in step 1 and 2.
      *
      * <p>
      * Naming convention used for OCH interfaces name : tp-wavenumber Naming
@@ -119,15 +116,31 @@ public class DeviceRenderer implements RendererService {
                 String destTp = n.getDestTp();
 
                 Long waveNumber = input.getWaveNumber();
-                if (destTp.contains("NETWORK")) {
+                String mf = input.getModulationFormat();
+                if (destTp.contains("LINE")) {
                     crossConnectFlag++;
+
+                    ModulationFormat modulationFormat = null;
+                    for (int i = 0; i < ModulationFormat.values().length; i++) {
+                        ModulationFormat smodulationFormat = ModulationFormat.forValue(i);
+                        if (smodulationFormat.getName().equals(mf)) {
+                            modulationFormat = smodulationFormat;
+                        }
+                    }
+                    try {
+                        LOG.info("Modulation Format {} configured exists.", modulationFormat.getName());
+                    } catch (NullPointerException e) {
+                        LOG.error(mf + " modulation format does not exist.");
+                    }
+
                     if (!new OpenRoadmXponderInterface(db, mps, nodeId, destTp, serviceName)
-                            .createLineInterfaces(waveNumber, R100G.class, ModulationFormat.Qpsk)) {
+                            .createLineInterfaces(waveNumber, R100G.class, modulationFormat)) {
 
                         return setServBldr.setResult("Unable to LINE interface on " + nodeId + " at " + destTp);
                     }
+                    LOG.info("LINE interface created for node " + nodeId);
                 }
-                if (srcTp.contains("CLIENT")) {
+                if (srcTp.contains("CLNT")) {
                     crossConnectFlag++;
                     if (!new OpenRoadmXponderInterface(db, mps, nodeId, srcTp, serviceName).createClientInterfaces()) {
                         return setServBldr.setResult("Unable to Client interface on " + nodeId + " at " + srcTp);
@@ -159,7 +172,7 @@ public class DeviceRenderer implements RendererService {
                     DataBroker netconfNodeDataBroker = PortMapping.getDeviceDataBroker(nodeId, mps);
                     String crossConnectName = srcTp + "-" + destTp + "-" + waveNumber;
                     CrossConnect roadmConnections = new CrossConnect(netconfNodeDataBroker);
-                    if (roadmConnections.postCrossConnect(waveNumber, srcTp, destTp) == true) {
+                    if (roadmConnections.postCrossConnect(waveNumber, srcTp, destTp)) {
                         nodesProvisioned.add(nodeId);
                         roadmConnections.getConnectionPortTrail(nodeId, mps, waveNumber, srcTp, destTp);
                     } else {
@@ -174,15 +187,13 @@ public class DeviceRenderer implements RendererService {
         return setServBldr.setResult("Roadm-connection successfully created for nodes " + nodesProvisioned.toString());
     }
 
-
     /**
-     * This method removes wavelength path based on following steps: For each
-     * node:
+     * This method removes wavelength path based on following steps: For each node:
      *
      * <p>
      * 1. Delete Cross connect between source and destination tps. 2. Delete Och
-     * interface on source termination point. 3. Delete Och interface on
-     * destination termination point.
+     * interface on source termination point. 3. Delete Och interface on destination
+     * termination point.
      *
      * <p>
      * Naming convention used for OCH interfaces name : tp-wavenumber Naming
@@ -208,21 +219,21 @@ public class DeviceRenderer implements RendererService {
             // if the node is currently mounted then proceed.
             if (currentMountedDevice.contains(nodeId)) {
 
-                if (destTp.contains("NETWORK")) {
+                if (destTp.contains("LINE")) {
                     if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
-                             .deleteInterface(destTp + "-ODU") == false) {
+                            .deleteInterface(destTp + "-ODU") == false) {
                         LOG.error("Failed to delete interface " + destTp + "-ODU");
                     }
                     if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
-                             .deleteInterface(destTp + "-OTU") == false) {
+                            .deleteInterface(destTp + "-OTU") == false) {
                         LOG.error("Failed to delete interface " + destTp + "-OTU");
                     }
                     if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
-                             .deleteInterface(destTp + "-" + waveNumber) == false) {
+                            .deleteInterface(destTp + "-" + waveNumber) == false) {
                         LOG.error("Failed to delete interface " + destTp + "-" + waveNumber);
                     }
                 }
-                if (srcTp.contains("CLIENT")) {
+                if (srcTp.contains("CLNT")) {
                     // Deleting interface on source termination point
                     if (new OpenRoadmInterfaces(db, mps, nodeId, srcTp)
                             .deleteInterface(srcTp + "-ETHERNET") == false) {
@@ -237,14 +248,14 @@ public class DeviceRenderer implements RendererService {
                     LOG.error("Failed to delete {} ", srcTp + "-" + destTp + "-" + waveNumber);
                 }
                 // Deleting interface on source termination point
-                if (new OpenRoadmInterfaces(db, mps, nodeId, srcTp)
-                        .deleteInterface(srcTp + "-" + waveNumber.toString()) == false) {
+                if (!new OpenRoadmInterfaces(db, mps, nodeId, srcTp)
+                        .deleteInterface(srcTp + "-" + waveNumber.toString())) {
                     LOG.error("Failed to delete interface " + srcTp + "-" + waveNumber.toString());
                 }
 
                 // Deleting interface on destination termination point
-                if (new OpenRoadmInterfaces(db, mps, nodeId, destTp)
-                        .deleteInterface(destTp + "-" + waveNumber.toString()) == false) {
+                if (!new OpenRoadmInterfaces(db, mps, nodeId, destTp)
+                        .deleteInterface(destTp + "-" + waveNumber.toString())) {
                     LOG.error("Failed to delete interface " + destTp + "-" + waveNumber.toString());
                 }
             } else {