Creation of OTS-OMS interfaces
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / DeviceRendererServiceImpl.java
index b9ec7e89f1600cbe888782528c27f1b4153615a4..e247ba11901dad355285725a6892b334bfda81b2 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
@@ -53,6 +54,10 @@ import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.ServiceNodelist;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist.NodelistKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.portmapping.rev170228.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.CreateOtsOmsOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackOutputBuilder;
@@ -75,15 +80,17 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
     private final OpenRoadmInterfaces openRoadmInterfaces;
     private final CrossConnect crossConnect;
+    private final PortMapping portMapping;
 
     public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
-            OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
-            CrossConnect crossConnect) {
+        OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
+        CrossConnect crossConnect, PortMapping portMapping) {
         this.dataBroker = dataBroker;
         this.deviceTransactionManager = deviceTransactionManager;
         this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
         this.openRoadmInterfaces = openRoadmInterfaces;
         this.crossConnect = crossConnect;
+        this.portMapping = portMapping;
     }
 
     @Override
@@ -101,121 +108,117 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         AtomicBoolean success = new AtomicBoolean(true);
 
         ForkJoinPool forkJoinPool = new ForkJoinPool();
-        ForkJoinTask forkJoinTask = forkJoinPool.submit(() ->
-            nodes.parallelStream().forEach(node -> {
-                String nodeId = node.getNodeId();
-                LOG.info("Starting provisioning for node : {}", nodeId);
-                List<String> createdEthInterfaces = new ArrayList<>();
-                List<String> createdOtuInterfaces = new ArrayList<>();
-                List<String> createdOduInterfaces = new ArrayList<>();
-                List<String> createdOchInterfaces = new ArrayList<>();
-                List<String> createdConnections = new ArrayList<>();
-                int crossConnectFlag = 0;
-
-                try {
-                    // if the node is currently mounted then proceed
-                    if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
-                        String srcTp = node.getSrcTp();
-                        String destTp = node.getDestTp();
-
-                        Long waveNumber = input.getWaveNumber();
-                        if ((destTp != null) && destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
-                            crossConnectFlag++;
-                            // create OpenRoadm Xponder Line Interfaces
-                            String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
-                                    nodeId, destTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
-                            createdOchInterfaces.add(supportingOchInterface);
-
-                            String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
-                                    nodeId, destTp, supportingOchInterface);
-                            createdOtuInterfaces.add(supportingOtuInterface);
-
-                            createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(
-                                    nodeId, destTp,supportingOtuInterface));
-                        }
-                        if ((srcTp != null) && srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
-                            crossConnectFlag++;
-                            // create OpenRoadm Xponder Client Interfaces
-                            createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId,
-                                    srcTp));
-
+        ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
+            String nodeId = node.getNodeId();
+            LOG.info("Starting provisioning for node : {}", nodeId);
+            List<String> createdEthInterfaces = new ArrayList<>();
+            List<String> createdOtuInterfaces = new ArrayList<>();
+            List<String> createdOduInterfaces = new ArrayList<>();
+            List<String> createdOchInterfaces = new ArrayList<>();
+            List<String> createdConnections = new ArrayList<>();
+            int crossConnectFlag = 0;
+
+            try {
+                // if the node is currently mounted then proceed
+                if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
+                    String srcTp = node.getSrcTp();
+                    String destTp = node.getDestTp();
+
+                    Long waveNumber = input.getWaveNumber();
+                    if ((destTp != null) && destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
+                        crossConnectFlag++;
+                        // create OpenRoadm Xponder Line Interfaces
+                        String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
+                            nodeId, destTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
+                        createdOchInterfaces.add(supportingOchInterface);
+
+                        String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
+                            nodeId, destTp, supportingOchInterface);
+                        createdOtuInterfaces.add(supportingOtuInterface);
+
+                        createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
+                            destTp, supportingOtuInterface));
+                    }
+                    if ((srcTp != null) && srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+                        crossConnectFlag++;
+                        // create OpenRoadm Xponder Client Interfaces
+                        createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId,
+                            srcTp));
 
-                        }
-                        if ((srcTp != null) && srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
-                            crossConnectFlag++;
-                            // create OpenRoadm Xponder Line Interfaces
-                            String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
-                                    nodeId, srcTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
-                            createdOchInterfaces.add(supportingOchInterface);
-
-                            String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
-                                    nodeId, srcTp, supportingOchInterface);
-                            createdOtuInterfaces.add(supportingOtuInterface);
-
-                            createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(
-                                    nodeId, srcTp, supportingOtuInterface));
-                        }
-                        if ((destTp != null) && destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
-                            crossConnectFlag++;
-                            // create OpenRoadm Xponder Client Interfaces
-                            createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId,
-                                    destTp));
+                    }
+                    if ((srcTp != null) && srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
+                        crossConnectFlag++;
+                        // create OpenRoadm Xponder Line Interfaces
+                        String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
+                            nodeId, srcTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
+                        createdOchInterfaces.add(supportingOchInterface);
+
+                        String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface(
+                            nodeId, srcTp, supportingOchInterface);
+                        createdOtuInterfaces.add(supportingOtuInterface);
+
+                        createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
+                            srcTp, supportingOtuInterface));
+                    }
+                    if ((destTp != null) && destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+                        crossConnectFlag++;
+                        // create OpenRoadm Xponder Client Interfaces
+                        createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId,
+                            destTp));
 
+                    }
+                    if ((srcTp != null) && (srcTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) || srcTp.contains(
+                        OpenRoadmInterfacesImpl.PP_TOKEN))) {
+                        createdOchInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(nodeId,
+                            srcTp, waveNumber));
+                    }
+                    if ((destTp != null) && (destTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) || destTp.contains(
+                        OpenRoadmInterfacesImpl.PP_TOKEN))) {
+                        createdOchInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(nodeId,
+                            destTp, waveNumber));
+                    }
+                    if (crossConnectFlag < 1) {
+                        LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
+                            destTp, nodeId);
+                        Optional<String> connectionNameOpt = this.crossConnect.postCrossConnect(nodeId, waveNumber,
+                            srcTp, destTp);
+                        if (connectionNameOpt.isPresent()) {
+                            nodesProvisioned.add(nodeId);
+                            List<Ports> ports = this.crossConnect.getConnectionPortTrail(nodeId, waveNumber, srcTp,
+                                destTp);
+                            if (ServicePathDirection.A_TO_Z.equals(direction)) {
+                                topology.updateAtoZTopologyList(ports, nodeId);
+                            }
+                            if (ServicePathDirection.Z_TO_A.equals(direction)) {
+                                topology.updateZtoATopologyList(ports, nodeId);
 
-                        }
-                        if ((srcTp != null) && (srcTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN)
-                                || srcTp.contains(OpenRoadmInterfacesImpl.PP_TOKEN))) {
-                            createdOchInterfaces.add(this.openRoadmInterfaceFactory .createOpenRoadmOchInterface(nodeId,
-                                    srcTp, waveNumber));
-                        }
-                        if ((destTp != null) && (destTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN)
-                                || destTp.contains(OpenRoadmInterfacesImpl.PP_TOKEN))) {
-                            createdOchInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(nodeId,
-                                    destTp, waveNumber));
-                        }
-                        if (crossConnectFlag < 1) {
-                            LOG.info("Creating cross connect between source {} and destination {} for node {}",
-                                    srcTp, destTp, nodeId);
-                            Optional<String> connectionNameOpt = this.crossConnect.postCrossConnect(nodeId, waveNumber,
-                                    srcTp, destTp);
-                            if (connectionNameOpt.isPresent()) {
-                                nodesProvisioned.add(nodeId);
-                                List<Ports> ports = this.crossConnect.getConnectionPortTrail(nodeId, waveNumber, srcTp,
-                                        destTp);
-                                if (ServicePathDirection.A_TO_Z.equals(direction)) {
-                                    topology.updateAtoZTopologyList(ports, nodeId);
-                                }
-                                if (ServicePathDirection.Z_TO_A.equals(direction)) {
-                                    topology.updateZtoATopologyList(ports, nodeId);
-
-                                }
-                                createdConnections.add(connectionNameOpt.get());
-                            } else {
-                                processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
-                                        results);
-                                success.set(false);
                             }
+                            createdConnections.add(connectionNameOpt.get());
+                        } else {
+                            processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
+                                results);
+                            success.set(false);
                         }
-                    } else {
-                        processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
-                        success.set(false);
                     }
-                } catch (OpenRoadmInterfaceException ex) {
-                    processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
+                } else {
+                    processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
                     success.set(false);
                 }
+            } catch (OpenRoadmInterfaceException ex) {
+                processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
+                success.set(false);
+            }
 
-                NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder();
-                nodeInterfaceBuilder.withKey(new NodeInterfaceKey(nodeId));
-                nodeInterfaceBuilder.setNodeId(nodeId);
-                nodeInterfaceBuilder.setConnectionId(createdConnections);
-                nodeInterfaceBuilder.setEthInterfaceId(createdEthInterfaces);
-                nodeInterfaceBuilder.setOtuInterfaceId(createdOtuInterfaces);
-                nodeInterfaceBuilder.setOduInterfaceId(createdOduInterfaces);
-                nodeInterfaceBuilder.setOchInterfaceId(createdOchInterfaces);
-                nodeInterfaces.add(nodeInterfaceBuilder.build());
-            })
-        );
+            NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder();
+            nodeInterfaceBuilder.withKey(new NodeInterfaceKey(nodeId));
+            nodeInterfaceBuilder.setNodeId(nodeId);
+            nodeInterfaceBuilder.setConnectionId(createdConnections);
+            nodeInterfaceBuilder.setEthInterfaceId(createdEthInterfaces);
+            nodeInterfaceBuilder.setOtuInterfaceId(createdOtuInterfaces);
+            nodeInterfaceBuilder.setOduInterfaceId(createdOduInterfaces);
+            nodeInterfaceBuilder.setOchInterfaceId(createdOchInterfaces);
+            nodeInterfaces.add(nodeInterfaceBuilder.build());
+        }));
 
         try {
             forkJoinTask.get();
@@ -233,7 +236,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         setServBldr.setSuccess(success.get());
         setServBldr.setResult(String.join("\n", results));
 
-        //setting topology in the service list data store
+        // setting topology in the service list data store
         try {
             setTopologyForService(input.getServiceName(), topology.getTopology());
         } catch (InterruptedException | TimeoutException | ExecutionException e) {
@@ -248,7 +251,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     }
 
     private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
-            ConcurrentLinkedQueue<String> messages) {
+        ConcurrentLinkedQueue<String> messages) {
         LOG.warn(message);
         messages.add(message);
         forkJoinPool.shutdown();
@@ -258,86 +261,85 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     @Override
     public ServicePathOutput deleteServicePath(ServicePathInput input) {
         List<Nodes> nodes = input.getNodes();
-        ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
+        AtomicBoolean success = new AtomicBoolean(true);
 
         ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
         if (!alarmSuppressionNodeRegistration(input)) {
             LOG.warn("Alarm suppresion node registraion failed!!!!");
         }
         ForkJoinPool forkJoinPool = new ForkJoinPool();
-        ForkJoinTask forkJoinTask = forkJoinPool.submit(() ->
-            nodes.parallelStream().forEach(node -> {
-                List<String> interfacesToDelete = new LinkedList<>();
-                String nodeId = node.getNodeId();
-                LOG.info("Deleting service setup on node {}", nodeId);
-                String srcTp = node.getSrcTp();
-                String destTp = node.getDestTp();
-                Long waveNumber = input.getWaveNumber();
-
-                if ((srcTp == null) || (destTp == null)) {
-                    LOG.error("Source ({}) or destination ({}) termination point is null.", srcTp, destTp);
-                    return;
-                }
+        ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
+            List<String> interfacesToDelete = new LinkedList<>();
+            String nodeId = node.getNodeId();
+            LOG.info("Deleting service setup on node {}", nodeId);
+            String srcTp = node.getSrcTp();
+            String destTp = node.getDestTp();
+            Long waveNumber = input.getWaveNumber();
+
+            if ((srcTp == null) || (destTp == null)) {
+                LOG.error("Source ({}) or destination ({}) termination point is null.", srcTp, destTp);
+                return;
+            }
 
-                // if the node is currently mounted then proceed.
-                if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
-                    if (destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)
-                            || srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)
-                            || srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)
-                            || destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
-                        if (destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
-                            interfacesToDelete.add(destTp + "-ODU");
-                            interfacesToDelete.add(destTp + "-OTU");
-                            interfacesToDelete.add(
-                                    this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
-                        }
-                        if (srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
-                            interfacesToDelete.add(srcTp + "-ODU");
-                            interfacesToDelete.add(srcTp + "-OTU");
-                            interfacesToDelete.add(
-                                this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
-                        }
-                        if (srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
-                            interfacesToDelete.add(srcTp + "-ETHERNET");
-                        }
-                        if (destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
-                            interfacesToDelete.add(destTp + "-ETHERNET");
-                        }
-                    } else {
-                        String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
-                        if (!this.crossConnect.deleteCrossConnect(nodeId, connectionNumber)) {
-                            LOG.error("Failed to delete cross connect {}", connectionNumber);
-                        }
-                        connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
-                        String interfName = this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp,
-                            waveNumber);
-                        if (!isUsedByXc(nodeId, interfName, connectionNumber)) {
-                            interfacesToDelete.add(interfName);
-                        }
-                        interfName = this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber);
-                        if (!isUsedByXc(nodeId, interfName, connectionNumber)) {
-                            interfacesToDelete.add(interfName);
-                        }
+            // if the node is currently mounted then proceed.
+            if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
+                if (destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN) || srcTp.contains(
+                    OpenRoadmInterfacesImpl.CLIENT_TOKEN) || srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)
+                    || destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+                    if (destTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
+                        interfacesToDelete.add(destTp + "-ODU");
+                        interfacesToDelete.add(destTp + "-OTU");
+                        interfacesToDelete.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp,
+                            waveNumber));
+                    }
+                    if (srcTp.contains(OpenRoadmInterfacesImpl.NETWORK_TOKEN)) {
+                        interfacesToDelete.add(srcTp + "-ODU");
+                        interfacesToDelete.add(srcTp + "-OTU");
+                        interfacesToDelete.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp,
+                            waveNumber));
+                    }
+                    if (srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+                        interfacesToDelete.add(srcTp + "-ETHERNET");
+                    }
+                    if (destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) {
+                        interfacesToDelete.add(destTp + "-ETHERNET");
                     }
                 } else {
-                    String result = nodeId + " is not mounted on the controller";
-                    results.add(result);
-                    LOG.warn(result);
-                    forkJoinPool.shutdown();
-                    return; // TODO should deletion end here?
+                    String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
+                    if (!this.crossConnect.deleteCrossConnect(nodeId, connectionNumber)) {
+                        LOG.error("Failed to delete cross connect {}", connectionNumber);
+                    }
+                    connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
+                    String interfName = this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp,
+                        waveNumber);
+                    if (!isUsedByXc(nodeId, interfName, connectionNumber)) {
+                        interfacesToDelete.add(interfName);
+                    }
+                    interfName = this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber);
+                    if (!isUsedByXc(nodeId, interfName, connectionNumber)) {
+                        interfacesToDelete.add(interfName);
+                    }
                 }
+            } else {
+                String result = nodeId + " is not mounted on the controller";
+                results.add(result);
+                success.set(false);
+                LOG.warn(result);
+                forkJoinPool.shutdown();
+                return; // TODO should deletion end here?
+            }
 
-                for (String interfaceId : interfacesToDelete) {
-                    try {
-                        this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
-                    } catch (OpenRoadmInterfaceException e) {
-                        String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
-                        LOG.error(result, e);
-                        results.add(result);
-                    }
+            for (String interfaceId : interfacesToDelete) {
+                try {
+                    this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
+                } catch (OpenRoadmInterfaceException e) {
+                    String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
+                    success.set(false);
+                    LOG.error(result, e);
+                    results.add(result);
                 }
-            })
-        );
+            }
+        }));
 
         try {
             forkJoinTask.get();
@@ -349,6 +351,8 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
             LOG.error("Alarm suppresion node removal failed!!!!");
         }
+        ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
+        delServBldr.setSuccess(success.get());
         if (results.isEmpty()) {
             return delServBldr.setResult("Request processed").build();
         } else {
@@ -391,8 +395,8 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
             }
 
-            LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
-                    String.join(", ", interfacesToDelete));
+            LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId, String.join(", ",
+                interfacesToDelete));
 
             for (String interfaceId : interfacesToDelete) {
                 try {
@@ -404,43 +408,37 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                     failedInterfaces.add(interfaceId);
                 }
             }
-            failedToRollbackList.add(new FailedToRollbackBuilder()
-                    .withKey(new FailedToRollbackKey(nodeId))
-                    .setNodeId(nodeId)
-                    .setInterface(failedInterfaces)
-                    .build()
-            );
+            failedToRollbackList.add(new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId)).setNodeId(
+                nodeId).setInterface(failedInterfaces).build());
         }
-        return new RendererRollbackOutputBuilder()
-                .setSuccess(success)
-                .setFailedToRollback(failedToRollbackList)
-                .build();
+        return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
+            .build();
     }
 
     private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
         NodelistBuilder nodeListBuilder = new NodelistBuilder();
         nodeListBuilder.withKey(new NodelistKey(input.getServiceName()));
         nodeListBuilder.setServiceName(input.getServiceName());
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service
-            .nodelist.nodelist.Nodes> nodeList = new ArrayList<>();
-        for (Nodes node: input.getNodes()) {
-            nodeList.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
-                    .yang.alarmsuppression.rev171102.service.nodelist.nodelist.NodesBuilder()
-                    .setNodeId(node.getNodeId()).build());
+        List<
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist
+                .nodelist.Nodes> nodeList = new ArrayList<>();
+        for (Nodes node : input.getNodes()) {
+            nodeList.add(
+                new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service
+                    .nodelist.nodelist.NodesBuilder().setNodeId(node.getNodeId()).build());
         }
         nodeListBuilder.setNodes(nodeList);
-        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params
-            .xml.ns.yang.alarmsuppression.rev171102.service.nodelist.Nodelist> nodeListIID =
-            InstanceIdentifier.create(ServiceNodelist.class).child(org.opendaylight.yang.gen.v1.urn
-            .opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist.Nodelist.class,
-                    new NodelistKey(input.getServiceName()));
+        InstanceIdentifier<
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist
+                .Nodelist> nodeListIID = InstanceIdentifier.create(ServiceNodelist.class).child(org.opendaylight.yang
+                        .gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist
+                        .Nodelist.class, new NodelistKey(input.getServiceName()));
         final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
         Future<Void> submit = writeTransaction.submit();
         try {
             submit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
-            LOG.info("Nodes are register for alarm suppression for service: {}",
-                    input.getServiceName());
+            LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
             return true;
 
         } catch (ExecutionException | InterruptedException | TimeoutException e) {
@@ -450,11 +448,11 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     }
 
     private boolean alarmSuppressionNodeRemoval(String serviceName) {
-        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params
-            .xml.ns.yang.alarmsuppression.rev171102.service.nodelist.Nodelist> nodeListIID =
-            InstanceIdentifier.create(ServiceNodelist.class).child(org.opendaylight.yang.gen.v1.urn
-                .opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service.nodelist.Nodelist.class,
-                        new NodelistKey(serviceName));
+        InstanceIdentifier<
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102.service
+                .nodelist.Nodelist> nodeListIID = InstanceIdentifier.create(ServiceNodelist.class).child(
+                        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.alarmsuppression.rev171102
+                            .service.nodelist.Nodelist.class, new NodelistKey(serviceName));
         final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
         writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
         Future<Void> submit = writeTransaction.submit();
@@ -469,15 +467,15 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         }
     }
 
-    private void setTopologyForService(String serviceName, Topology topo)
-            throws InterruptedException, ExecutionException, TimeoutException {
+    private void setTopologyForService(String serviceName, Topology topo) throws InterruptedException,
+        ExecutionException, TimeoutException {
 
         ServicesBuilder servicesBuilder;
-        //Get the service from the service list inventory
+        // Get the service from the service list inventory
 
         ServicesKey serviceKey = new ServicesKey(serviceName);
-        InstanceIdentifier<Services> iid =
-                InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
+        InstanceIdentifier<Services> iid = InstanceIdentifier.create(ServiceList.class).child(Services.class,
+            serviceKey);
         Optional<Services> services;
         try (ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
             Future<com.google.common.base.Optional<Services>> future = readTx.read(LogicalDatastoreType.OPERATIONAL,
@@ -502,17 +500,15 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
     }
 
     private boolean isUsedByXc(String nodeid, String interfaceid, String xcid) {
-        InstanceIdentifier<RoadmConnections> xciid = InstanceIdentifier.create(OrgOpenroadmDevice.class)
-            .child(RoadmConnections.class, new RoadmConnectionsKey(xcid));
+        InstanceIdentifier<RoadmConnections> xciid = InstanceIdentifier.create(OrgOpenroadmDevice.class).child(
+            RoadmConnections.class, new RoadmConnectionsKey(xcid));
         LOG.info("reading xc {} in node {}", xcid, nodeid);
-        Optional<RoadmConnections> crossconnection = deviceTransactionManager.getDataFromDevice(nodeid,
-            LogicalDatastoreType.CONFIGURATION, xciid, Timeouts.DEVICE_READ_TIMEOUT,
-            Timeouts.DEVICE_READ_TIMEOUT_UNIT);
+        Optional<RoadmConnections> crossconnection = this.deviceTransactionManager.getDataFromDevice(nodeid,
+            LogicalDatastoreType.CONFIGURATION, xciid, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT);
         if (crossconnection.isPresent()) {
             RoadmConnections xc = crossconnection.get();
             LOG.info("xd {} found", xcid);
-            if (xc.getSource().getSrcIf().equals(interfaceid) || xc.getDestination().getDstIf().equals(
-                interfaceid)) {
+            if (xc.getSource().getSrcIf().equals(interfaceid) || xc.getDestination().getDstIf().equals(interfaceid)) {
                 return true;
             }
         } else {
@@ -520,4 +516,32 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
         }
         return false;
     }
+
+    @Override
+    public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
+        CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
+        String result = "";
+        Boolean success = false;
+        // if the node is currently mounted then proceed.
+        if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
+            Mapping mapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
+            if (mapping != null) {
+                String otsInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(),
+                    mapping);
+                mapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
+                String omsInterface = this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(),
+                    mapping);
+                result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node " + input
+                    .getNodeId();
+                success = true;
+            } else {
+                result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
+                    + input.getNodeId();
+            }
+        } else {
+            result = input.getNodeId() + " is not mounted on the controller";
+            LOG.warn(result);
+        }
+        return output.setResult(result).setSuccess(success).build();
+    }
 }