X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FDeviceRendererServiceImpl.java;h=f5a57fc0a1616204edfe90180ccc585a42ff767d;hb=44684ce8c8552a35e51a154de3342cfc4c50e4f5;hp=e247ba11901dad355285725a6892b334bfda81b2;hpb=17ed4b007aeaca9c1c88c49f70c70d2195f9cf5b;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java index e247ba119..f5a57fc0a 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java @@ -5,10 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.transportpce.renderer.provisiondevice; import com.google.common.collect.Sets; + import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -22,6 +22,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -72,41 +73,40 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DeviceRendererServiceImpl implements DeviceRendererService { - private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class); - private final DataBroker dataBroker; private final DeviceTransactionManager deviceTransactionManager; private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory; private final OpenRoadmInterfaces openRoadmInterfaces; private final CrossConnect crossConnect; private final PortMapping portMapping; + private String serviceName; public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager, - OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces, - CrossConnect crossConnect, PortMapping portMapping) { + 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; + serviceName = "Undefined"; } @Override public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) { + this.serviceName = input.getServiceName(); List nodes = input.getNodes(); // Register node for suppressing alarms if (!alarmSuppressionNodeRegistration(input)) { LOG.warn("Alarm suppresion node registration failed!!!!"); } - ConcurrentLinkedQueue results = new ConcurrentLinkedQueue<>(); Set nodeInterfaces = Sets.newConcurrentHashSet(); Set nodesProvisioned = Sets.newConcurrentHashSet(); ServiceListTopology topology = new ServiceListTopology(); AtomicBoolean success = new AtomicBoolean(true); - ForkJoinPool forkJoinPool = new ForkJoinPool(); ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> { String nodeId = node.getNodeId(); @@ -117,86 +117,79 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { List createdOchInterfaces = new ArrayList<>(); List 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); + nodeId, destTp, waveNumber, R100G.class, ModulationFormat.DpQpsk, serviceName); createdOchInterfaces.add(supportingOchInterface); - - String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface( - nodeId, destTp, supportingOchInterface); + String supportingOtuInterface = this.openRoadmInterfaceFactory + .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface, serviceName); createdOtuInterfaces.add(supportingOtuInterface); - createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId, - destTp, supportingOtuInterface)); + destTp, supportingOtuInterface, serviceName)); } if ((srcTp != null) && srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) { crossConnectFlag++; // create OpenRoadm Xponder Client Interfaces - createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, - srcTp)); - + createdEthInterfaces.add( + this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp, serviceName)); } 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); + nodeId, srcTp, waveNumber, R100G.class, ModulationFormat.DpQpsk, serviceName); createdOchInterfaces.add(supportingOchInterface); - - String supportingOtuInterface = this.openRoadmInterfaceFactory.createOpenRoadmOtu4Interface( - nodeId, srcTp, supportingOchInterface); + String supportingOtuInterface = this.openRoadmInterfaceFactory + .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface, serviceName); createdOtuInterfaces.add(supportingOtuInterface); - createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId, - srcTp, supportingOtuInterface)); + srcTp, supportingOtuInterface, serviceName)); } if ((destTp != null) && destTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) { crossConnectFlag++; // create OpenRoadm Xponder Client Interfaces - createdEthInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, - destTp)); - + createdEthInterfaces.add( + this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp, serviceName)); } - if ((srcTp != null) && (srcTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) || srcTp.contains( - OpenRoadmInterfacesImpl.PP_TOKEN))) { - createdOchInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(nodeId, - srcTp, waveNumber)); + if ((srcTp != null) && (srcTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) + || srcTp.contains(OpenRoadmInterfacesImpl.PP_TOKEN))) { + createdOchInterfaces.add( + this.openRoadmInterfaceFactory + .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber, serviceName)); } - if ((destTp != null) && (destTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) || destTp.contains( - OpenRoadmInterfacesImpl.PP_TOKEN))) { - createdOchInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(nodeId, - destTp, waveNumber)); + if ((destTp != null) && (destTp.contains(OpenRoadmInterfacesImpl.TTP_TOKEN) + || destTp.contains(OpenRoadmInterfacesImpl.PP_TOKEN))) { + createdOchInterfaces.add( + this.openRoadmInterfaceFactory + .createOpenRoadmOchInterface(nodeId, destTp, waveNumber, serviceName)); } if (crossConnectFlag < 1) { LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp, - destTp, nodeId); - Optional connectionNameOpt = this.crossConnect.postCrossConnect(nodeId, waveNumber, - srcTp, destTp); + destTp, nodeId); + Optional connectionNameOpt = + this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp); if (connectionNameOpt.isPresent()) { nodesProvisioned.add(nodeId); - List ports = this.crossConnect.getConnectionPortTrail(nodeId, waveNumber, srcTp, - destTp); + List 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); + results); success.set(false); } } @@ -208,7 +201,6 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { 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); @@ -219,15 +211,12 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { nodeInterfaceBuilder.setOchInterfaceId(createdOchInterfaces); nodeInterfaces.add(nodeInterfaceBuilder.build()); })); - try { forkJoinTask.get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Error while setting up service paths!", e); } - forkJoinPool.shutdown(); - if (success.get()) { results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned)); } @@ -235,23 +224,20 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { setServBldr.setNodeInterface(new ArrayList<>(nodeInterfaces)); setServBldr.setSuccess(success.get()); setServBldr.setResult(String.join("\n", results)); - // setting topology in the service list data store try { setTopologyForService(input.getServiceName(), topology.getTopology()); } catch (InterruptedException | TimeoutException | ExecutionException e) { LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e); } - if (!alarmSuppressionNodeRemoval(input.getServiceName())) { LOG.error("Alarm suppresion node removal failed!!!!"); } - return setServBldr.build(); } private ConcurrentLinkedQueue processErrorMessage(String message, ForkJoinPool forkJoinPool, - ConcurrentLinkedQueue messages) { + ConcurrentLinkedQueue messages) { LOG.warn(message); messages.add(message); forkJoinPool.shutdown(); @@ -262,7 +248,6 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { public ServicePathOutput deleteServicePath(ServicePathInput input) { List nodes = input.getNodes(); AtomicBoolean success = new AtomicBoolean(true); - ConcurrentLinkedQueue results = new ConcurrentLinkedQueue<>(); if (!alarmSuppressionNodeRegistration(input)) { LOG.warn("Alarm suppresion node registraion failed!!!!"); @@ -275,28 +260,27 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { 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) + || 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)); + 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)); + interfacesToDelete + .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber)); } if (srcTp.contains(OpenRoadmInterfacesImpl.CLIENT_TOKEN)) { interfacesToDelete.add(srcTp + "-ETHERNET"); @@ -310,8 +294,8 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { LOG.error("Failed to delete cross connect {}", connectionNumber); } connectionNumber = destTp + "-" + srcTp + "-" + waveNumber; - String interfName = this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, - waveNumber); + String interfName = + this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber); if (!isUsedByXc(nodeId, interfName, connectionNumber)) { interfacesToDelete.add(interfName); } @@ -328,7 +312,6 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { forkJoinPool.shutdown(); return; // TODO should deletion end here? } - for (String interfaceId : interfacesToDelete) { try { this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId); @@ -340,13 +323,11 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } } })); - try { forkJoinTask.get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Error while deleting service paths!", e); } - forkJoinPool.shutdown(); if (!alarmSuppressionNodeRemoval(input.getServiceName())) { LOG.error("Alarm suppresion node removal failed!!!!"); @@ -394,10 +375,8 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { if (nodeInterfaces.getEthInterfaceId() != null) { 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 { this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId); @@ -408,31 +387,34 @@ 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(); + .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<>(); + List 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()); + 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())); + 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 submit = writeTransaction.submit(); @@ -440,51 +422,48 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { submit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS); LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName()); return true; - } catch (ExecutionException | InterruptedException | TimeoutException e) { LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e); return false; } } - private boolean alarmSuppressionNodeRemoval(String serviceName) { + private boolean alarmSuppressionNodeRemoval(String name) { 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)); + 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(name)); final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction(); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID); Future submit = writeTransaction.submit(); try { submit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS); - LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName); + LOG.info("Nodes are unregister for alarm suppression for service: {}", name); return true; - } catch (InterruptedException | TimeoutException | ExecutionException e) { - LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e); + LOG.warn("Failed to alarm suppresslist for service: {}", name, e); return false; } } - private void setTopologyForService(String serviceName, Topology topo) throws InterruptedException, - ExecutionException, TimeoutException { - + private void setTopologyForService(String name, Topology topo) + throws InterruptedException, ExecutionException, TimeoutException { ServicesBuilder servicesBuilder; // Get the service from the service list inventory - - ServicesKey serviceKey = new ServicesKey(serviceName); - InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, - serviceKey); + ServicesKey serviceKey = new ServicesKey(name); + InstanceIdentifier iid = + InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey); Optional services; try (ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction()) { - Future> future = readTx.read(LogicalDatastoreType.OPERATIONAL, - iid); + Future> future = + readTx.read(LogicalDatastoreType.OPERATIONAL, iid); services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil(); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw e; } - if (services.isPresent()) { servicesBuilder = new ServicesBuilder(services.get()); } else { @@ -492,19 +471,18 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { servicesBuilder.withKey(serviceKey); } servicesBuilder.setTopology(topo); - WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction(); writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build()); writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS); - } private boolean isUsedByXc(String nodeid, String interfaceid, String xcid) { - InstanceIdentifier xciid = InstanceIdentifier.create(OrgOpenroadmDevice.class).child( - RoadmConnections.class, new RoadmConnectionsKey(xcid)); + InstanceIdentifier xciid = InstanceIdentifier.create(OrgOpenroadmDevice.class) + .child(RoadmConnections.class, new RoadmConnectionsKey(xcid)); LOG.info("reading xc {} in node {}", xcid, nodeid); - Optional crossconnection = this.deviceTransactionManager.getDataFromDevice(nodeid, - LogicalDatastoreType.CONFIGURATION, xciid, Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT); + Optional 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); @@ -524,19 +502,47 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { 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; + Mapping oldMapping = null; + Mapping newMapping = null; + oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint()); + if (oldMapping != null) { + String otsInterface = + this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping); + newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint()); + int count = 0; + Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping); + while (!isSupportingOtsPresent && (count < 6)) { + LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId()); + try { + Thread.sleep(10000); + this.portMapping.updateMapping(input.getNodeId(), oldMapping); + } catch (InterruptedException e) { + LOG.error("Failed to wait for post interface operation "); + } + newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint()); + isSupportingOtsPresent = isSupportingOtsPresent(newMapping); + count++; + } + if (count < 6) { + String omsInterface = + this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping); + if (omsInterface != null) { + result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node " + + input.getNodeId(); + success = true; + } else { + LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId()); + result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId(); + } + } else { + LOG.error("Unable to get ots interface from mapping {} for node {}", + oldMapping.getLogicalConnectionPoint(), input.getNodeId()); + result = String.format("Unable to get ots interface from mapping %s - %s", + oldMapping.getLogicalConnectionPoint(), input.getNodeId()); + } } else { result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for " - + input.getNodeId(); + + input.getNodeId(); } } else { result = input.getNodeId() + " is not mounted on the controller"; @@ -544,4 +550,17 @@ public class DeviceRendererServiceImpl implements DeviceRendererService { } return output.setResult(result).setSuccess(success).build(); } + + private Boolean isSupportingOtsPresent(Mapping mapping) { + Boolean result = false; + if (mapping != null) { + if (mapping.getSupportingOts() != null) { + LOG.info("SupportingOts info is present in mapping {}", mapping); + result = true; + } else { + LOG.warn("SupportingOts info not present in mapping {}", mapping); + } + } + return result; + } }