2 * Copyright © 2017 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.renderer.provisiondevice;
10 import com.google.common.collect.Sets;
11 import com.google.common.util.concurrent.FluentFuture;
12 import java.util.ArrayList;
13 import java.util.LinkedList;
14 import java.util.List;
15 import java.util.Optional;
17 import java.util.concurrent.ConcurrentLinkedQueue;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.ForkJoinPool;
20 import java.util.concurrent.ForkJoinTask;
21 import java.util.concurrent.Future;
22 import java.util.concurrent.TimeUnit;
23 import java.util.concurrent.TimeoutException;
24 import java.util.concurrent.atomic.AtomicBoolean;
25 import org.eclipse.jdt.annotation.NonNull;
26 import org.opendaylight.mdsal.binding.api.DataBroker;
27 import org.opendaylight.mdsal.binding.api.ReadTransaction;
28 import org.opendaylight.mdsal.binding.api.WriteTransaction;
29 import org.opendaylight.mdsal.common.api.CommitInfo;
30 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
31 import org.opendaylight.transportpce.common.StringConstants;
32 import org.opendaylight.transportpce.common.Timeouts;
33 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
34 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
35 import org.opendaylight.transportpce.common.mapping.PortMapping;
36 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
37 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
38 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
39 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
40 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev190702.network.nodes.Mapping;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsInput;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsOutput;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsOutputBuilder;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackInput;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackOutput;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackOutputBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathInput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathOutput;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollback;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollbackBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollbackKey;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.Topology;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.R100G;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceList;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesKey;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterface;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceKey;
67 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.Nodes;
68 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
69 import org.slf4j.Logger;
70 import org.slf4j.LoggerFactory;
72 public class DeviceRendererServiceImpl implements DeviceRendererService {
73 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
74 private final DataBroker dataBroker;
75 private final DeviceTransactionManager deviceTransactionManager;
76 private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
77 private final OpenRoadmInterfaces openRoadmInterfaces;
78 private final CrossConnect crossConnect;
79 private final PortMapping portMapping;
81 public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
82 OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
83 CrossConnect crossConnect, PortMapping portMapping) {
84 this.dataBroker = dataBroker;
85 this.deviceTransactionManager = deviceTransactionManager;
86 this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
87 this.openRoadmInterfaces = openRoadmInterfaces;
88 this.crossConnect = crossConnect;
89 this.portMapping = portMapping;
93 public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
94 List<Nodes> nodes = input.getNodes();
95 // Register node for suppressing alarms
96 if (!alarmSuppressionNodeRegistration(input)) {
97 LOG.warn("Alarm suppresion node registration failed!!!!");
99 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
100 Set<NodeInterface> nodeInterfaces = Sets.newConcurrentHashSet();
101 Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
102 ServiceListTopology topology = new ServiceListTopology();
103 AtomicBoolean success = new AtomicBoolean(true);
104 ForkJoinPool forkJoinPool = new ForkJoinPool();
105 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
106 String nodeId = node.getNodeId();
107 LOG.info("Starting provisioning for node : {}", nodeId);
108 List<String> createdEthInterfaces = new ArrayList<>();
109 List<String> createdOtuInterfaces = new ArrayList<>();
110 List<String> createdOduInterfaces = new ArrayList<>();
111 List<String> createdOchInterfaces = new ArrayList<>();
112 List<String> createdConnections = new ArrayList<>();
113 int crossConnectFlag = 0;
115 // if the node is currently mounted then proceed
116 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
117 String srcTp = node.getSrcTp();
118 String destTp = node.getDestTp();
119 Long waveNumber = input.getWaveNumber();
120 if ((destTp != null) && destTp.contains(StringConstants.NETWORK_TOKEN)) {
122 // create OpenRoadm Xponder Line Interfaces
123 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
124 nodeId, destTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
125 createdOchInterfaces.add(supportingOchInterface);
126 String supportingOtuInterface = this.openRoadmInterfaceFactory
127 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface);
128 createdOtuInterfaces.add(supportingOtuInterface);
129 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
130 destTp, supportingOtuInterface));
132 if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
134 // create OpenRoadm Xponder Client Interfaces
135 createdEthInterfaces.add(
136 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
138 if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
140 // create OpenRoadm Xponder Line Interfaces
141 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
142 nodeId, srcTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
143 createdOchInterfaces.add(supportingOchInterface);
144 String supportingOtuInterface = this.openRoadmInterfaceFactory
145 .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
146 createdOtuInterfaces.add(supportingOtuInterface);
147 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
148 srcTp, supportingOtuInterface));
150 if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
152 // create OpenRoadm Xponder Client Interfaces
153 createdEthInterfaces.add(
154 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
156 if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
157 || srcTp.contains(StringConstants.PP_TOKEN))) {
158 createdOchInterfaces.addAll(
159 this.openRoadmInterfaceFactory
160 .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber));
162 if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
163 || destTp.contains(StringConstants.PP_TOKEN))) {
164 createdOchInterfaces.addAll(
165 this.openRoadmInterfaceFactory
166 .createOpenRoadmOchInterface(nodeId, destTp, waveNumber));
168 if (crossConnectFlag < 1) {
169 LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
171 Optional<String> connectionNameOpt =
172 this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp);
173 if (connectionNameOpt.isPresent()) {
174 nodesProvisioned.add(nodeId);
175 createdConnections.add(connectionNameOpt.get());
177 processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
183 processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
186 } catch (OpenRoadmInterfaceException ex) {
187 processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
190 NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
191 .withKey(new NodeInterfaceKey(nodeId))
193 .setConnectionId(createdConnections)
194 .setEthInterfaceId(createdEthInterfaces)
195 .setOtuInterfaceId(createdOtuInterfaces)
196 .setOduInterfaceId(createdOduInterfaces)
197 .setOchInterfaceId(createdOchInterfaces);
198 nodeInterfaces.add(nodeInterfaceBuilder.build());
202 } catch (InterruptedException | ExecutionException e) {
203 LOG.error("Error while setting up service paths!", e);
205 forkJoinPool.shutdown();
208 results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
210 ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
211 .setNodeInterface(new ArrayList<>(nodeInterfaces))
212 .setSuccess(success.get())
213 .setResult(String.join("\n", results));
214 // setting topology in the service list data store
216 setTopologyForService(input.getServiceName(), topology.getTopology());
217 } catch (InterruptedException | TimeoutException | ExecutionException e) {
218 LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e);
220 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
221 LOG.error("Alarm suppresion node removal failed!!!!");
223 return setServBldr.build();
226 private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
227 ConcurrentLinkedQueue<String> messages) {
229 messages.add(message);
230 forkJoinPool.shutdown();
235 public ServicePathOutput deleteServicePath(ServicePathInput input) {
236 List<Nodes> nodes = input.getNodes();
237 AtomicBoolean success = new AtomicBoolean(true);
238 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
239 if (!alarmSuppressionNodeRegistration(input)) {
240 LOG.warn("Alarm suppresion node registraion failed!!!!");
242 ForkJoinPool forkJoinPool = new ForkJoinPool();
243 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
244 List<String> interfacesToDelete = new LinkedList<>();
245 String nodeId = node.getNodeId();
246 LOG.info("Deleting service setup on node {}", nodeId);
247 String srcTp = node.getSrcTp();
248 String destTp = node.getDestTp();
249 Long waveNumber = input.getWaveNumber();
250 if ((srcTp == null) || (destTp == null)) {
251 LOG.error("Source ({}) or destination ({}) termination point is null.", srcTp, destTp);
254 // if the node is currently mounted then proceed.
255 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
256 if (destTp.contains(StringConstants.NETWORK_TOKEN)
257 || srcTp.contains(StringConstants.CLIENT_TOKEN)
258 || srcTp.contains(StringConstants.NETWORK_TOKEN)
259 || destTp.contains(StringConstants.CLIENT_TOKEN)) {
260 if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
261 interfacesToDelete.add(destTp + "-ODU");
262 interfacesToDelete.add(destTp + "-OTU");
263 interfacesToDelete.add(
264 this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
266 if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
267 interfacesToDelete.add(srcTp + "-ODU");
268 interfacesToDelete.add(srcTp + "-OTU");
270 .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
272 if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
273 interfacesToDelete.add(srcTp + "-ETHERNET");
275 if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
276 interfacesToDelete.add(destTp + "-ETHERNET");
279 String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
280 List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber);
281 connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
282 if (intToDelete != null) {
283 for (String interf : intToDelete) {
284 if (!this.openRoadmInterfaceFactory.isUsedbyXc(nodeId, interf, connectionNumber,
285 this.deviceTransactionManager)) {
286 interfacesToDelete.add(interf);
292 String result = nodeId + " is not mounted on the controller";
296 forkJoinPool.shutdown();
298 //TODO should deletion end here?
300 for (String interfaceId : interfacesToDelete) {
302 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
303 } catch (OpenRoadmInterfaceException e) {
304 String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
306 LOG.error(result, e);
313 } catch (InterruptedException | ExecutionException e) {
314 LOG.error("Error while deleting service paths!", e);
316 forkJoinPool.shutdown();
317 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
318 LOG.error("Alarm suppresion node removal failed!!!!");
320 ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
321 delServBldr.setSuccess(success.get());
322 if (results.isEmpty()) {
323 return delServBldr.setResult("Request processed").build();
325 return delServBldr.setResult(String.join("\n", results)).build();
330 public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
331 boolean success = true;
332 List<FailedToRollback> failedToRollbackList = new ArrayList<>();
333 for (NodeInterface nodeInterfaces : input.getNodeInterface()) {
334 List<String> failedInterfaces = new ArrayList<>();
335 String nodeId = nodeInterfaces.getNodeId();
336 for (String connectionId : nodeInterfaces.getConnectionId()) {
337 List<String> listInter = this.crossConnect.deleteCrossConnect(nodeId, connectionId);
338 if (listInter != null) {
339 LOG.info("Cross connect {} on node {} successfully deleted.", connectionId, nodeId);
341 LOG.error("Failed to delete cross connect {} on node {}!", connectionId, nodeId);
343 failedInterfaces.add(connectionId);
346 // Interfaces needs to be in specific order to delete. Order is:
351 LinkedList<String> interfacesToDelete = new LinkedList<>();
352 if (nodeInterfaces.getOduInterfaceId() != null) {
353 interfacesToDelete.addAll(nodeInterfaces.getOduInterfaceId());
355 if (nodeInterfaces.getOtuInterfaceId() != null) {
356 interfacesToDelete.addAll(nodeInterfaces.getOtuInterfaceId());
358 if (nodeInterfaces.getOchInterfaceId() != null) {
359 interfacesToDelete.addAll(nodeInterfaces.getOchInterfaceId());
361 if (nodeInterfaces.getEthInterfaceId() != null) {
362 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
364 LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
365 String.join(", ", interfacesToDelete));
366 for (String interfaceId : interfacesToDelete) {
368 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
369 LOG.info("Interface {} on node {} successfully deleted.", interfaceId, nodeId);
370 } catch (OpenRoadmInterfaceException e) {
371 LOG.error("Failed to delete interface {} on node {}!", interfaceId, nodeId);
373 failedInterfaces.add(interfaceId);
376 failedToRollbackList.add(new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
377 .setNodeId(nodeId).setInterface(failedInterfaces).build());
379 return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
383 private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
384 NodelistBuilder nodeListBuilder = new NodelistBuilder()
385 .withKey(new NodelistKey(input.getServiceName()))
386 .setServiceName(input.getServiceName());
387 List<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
388 .nodelist.nodelist.Nodes> nodeList =
390 for (Nodes node : input.getNodes()) {
392 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
393 .service.nodelist.nodelist.NodesBuilder()
394 .setNodeId(node.getNodeId()).build());
396 nodeListBuilder.setNodes(nodeList);
397 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
398 .service.nodelist.Nodelist> nodeListIID =
399 InstanceIdentifier.create(ServiceNodelist.class).child(
400 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
401 .rev171102.service.nodelist.Nodelist.class,
402 new NodelistKey(input.getServiceName()));
403 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
404 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
405 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
407 commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
408 LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
410 } catch (ExecutionException | InterruptedException | TimeoutException e) {
411 LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e);
416 private boolean alarmSuppressionNodeRemoval(String serviceName) {
417 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
418 .service.nodelist.Nodelist> nodeListIID =
419 InstanceIdentifier.create(ServiceNodelist.class).child(
420 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
421 .rev171102.service.nodelist.Nodelist.class,
422 new NodelistKey(serviceName));
423 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
424 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
425 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
427 commit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
428 LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
430 } catch (InterruptedException | TimeoutException | ExecutionException e) {
431 LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e);
436 private void setTopologyForService(String name, Topology topo)
437 throws InterruptedException, ExecutionException, TimeoutException {
438 ServicesBuilder servicesBuilder;
439 // Get the service from the service list inventory
440 ServicesKey serviceKey = new ServicesKey(name);
441 InstanceIdentifier<Services> iid =
442 InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
443 Optional<Services> services;
444 try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
445 Future<java.util.Optional<Services>> future =
446 readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
447 services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
448 } catch (InterruptedException | ExecutionException | TimeoutException e) {
451 if (services.isPresent()) {
452 LOG.info("service {} already exists", name);
453 servicesBuilder = new ServicesBuilder(services.get()).setTopology(topo);
454 WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
455 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
456 writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
458 LOG.warn("Service {} does not exist - topology can not be updated", name);
463 public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
464 CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
466 Boolean success = false;
467 // if the node is currently mounted then proceed.
468 if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
469 Mapping oldMapping = null;
470 Mapping newMapping = null;
471 oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
472 if (oldMapping != null) {
473 String otsInterface =
474 this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
475 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
477 Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
478 while (!isSupportingOtsPresent && (count < 6)) {
479 LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
482 this.portMapping.updateMapping(input.getNodeId(), oldMapping);
483 } catch (InterruptedException e) {
484 LOG.error("Failed to wait for post interface operation ");
486 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
487 isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
491 String omsInterface =
492 this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
493 if (omsInterface != null) {
494 result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
498 LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
499 result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
502 LOG.error("Unable to get ots interface from mapping {} for node {}",
503 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
504 result = String.format("Unable to get ots interface from mapping %s - %s",
505 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
508 result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
512 result = input.getNodeId() + " is not mounted on the controller";
515 return output.setResult(result).setSuccess(success).build();
518 private Boolean isSupportingOtsPresent(Mapping mapping) {
519 Boolean result = false;
520 if (mapping != null) {
521 if (mapping.getSupportingOts() != null) {
522 LOG.info("SupportingOts info is present in mapping {}", mapping);
525 LOG.warn("SupportingOts info not present in mapping {}", mapping);