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;
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;
26 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
27 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
28 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
29 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
30 import org.opendaylight.transportpce.common.StringConstants;
31 import org.opendaylight.transportpce.common.Timeouts;
32 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
33 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
34 import org.opendaylight.transportpce.common.mapping.PortMapping;
35 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
36 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
37 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
38 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
39 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
40 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
41 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev190702.network.nodes.Mapping;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsInput;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsOutput;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.CreateOtsOmsOutputBuilder;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackInput;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackOutput;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.RendererRollbackOutputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathInput;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathOutput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.ServicePathOutputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollback;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollbackBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev170228.renderer.rollback.output.FailedToRollbackKey;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.R100G;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey;
63 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterface;
64 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.node.interfaces.NodeInterfaceKey;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev170907.olm.renderer.input.Nodes;
67 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
71 public class DeviceRendererServiceImpl implements DeviceRendererService {
72 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
73 private final DataBroker dataBroker;
74 private final DeviceTransactionManager deviceTransactionManager;
75 private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
76 private final OpenRoadmInterfaces openRoadmInterfaces;
77 private final CrossConnect crossConnect;
78 private final PortMapping portMapping;
80 public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
81 OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
82 CrossConnect crossConnect, PortMapping portMapping) {
83 this.dataBroker = dataBroker;
84 this.deviceTransactionManager = deviceTransactionManager;
85 this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
86 this.openRoadmInterfaces = openRoadmInterfaces;
87 this.crossConnect = crossConnect;
88 this.portMapping = portMapping;
92 public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
93 List<Nodes> nodes = input.getNodes();
94 // Register node for suppressing alarms
95 if (!alarmSuppressionNodeRegistration(input)) {
96 LOG.warn("Alarm suppresion node registration failed!!!!");
98 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
99 Set<NodeInterface> nodeInterfaces = Sets.newConcurrentHashSet();
100 Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
101 ServiceListTopology topology = new ServiceListTopology();
102 AtomicBoolean success = new AtomicBoolean(true);
103 ForkJoinPool forkJoinPool = new ForkJoinPool();
104 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
105 String nodeId = node.getNodeId();
106 LOG.info("Starting provisioning for node : {}", nodeId);
107 List<String> createdEthInterfaces = new ArrayList<>();
108 List<String> createdOtuInterfaces = new ArrayList<>();
109 List<String> createdOduInterfaces = new ArrayList<>();
110 List<String> createdOchInterfaces = new ArrayList<>();
111 List<String> createdConnections = new ArrayList<>();
112 int crossConnectFlag = 0;
114 // if the node is currently mounted then proceed
115 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
116 String srcTp = node.getSrcTp();
117 String destTp = node.getDestTp();
118 Long waveNumber = input.getWaveNumber();
119 if ((destTp != null) && destTp.contains(StringConstants.NETWORK_TOKEN)) {
121 // create OpenRoadm Xponder Line Interfaces
122 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
123 nodeId, destTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
124 createdOchInterfaces.add(supportingOchInterface);
125 String supportingOtuInterface = this.openRoadmInterfaceFactory
126 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface);
127 createdOtuInterfaces.add(supportingOtuInterface);
128 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
129 destTp, supportingOtuInterface));
131 if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
133 // create OpenRoadm Xponder Client Interfaces
134 createdEthInterfaces.add(
135 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
137 if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
139 // create OpenRoadm Xponder Line Interfaces
140 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
141 nodeId, srcTp, waveNumber, R100G.class, ModulationFormat.DpQpsk);
142 createdOchInterfaces.add(supportingOchInterface);
143 String supportingOtuInterface = this.openRoadmInterfaceFactory
144 .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
145 createdOtuInterfaces.add(supportingOtuInterface);
146 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
147 srcTp, supportingOtuInterface));
149 if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
151 // create OpenRoadm Xponder Client Interfaces
152 createdEthInterfaces.add(
153 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
155 if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
156 || srcTp.contains(StringConstants.PP_TOKEN))) {
157 createdOchInterfaces.addAll(
158 this.openRoadmInterfaceFactory
159 .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber));
161 if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
162 || destTp.contains(StringConstants.PP_TOKEN))) {
163 createdOchInterfaces.addAll(
164 this.openRoadmInterfaceFactory
165 .createOpenRoadmOchInterface(nodeId, destTp, waveNumber));
167 if (crossConnectFlag < 1) {
168 LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
170 Optional<String> connectionNameOpt =
171 this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp);
172 if (connectionNameOpt.isPresent()) {
173 nodesProvisioned.add(nodeId);
174 createdConnections.add(connectionNameOpt.get());
176 processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
182 processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
185 } catch (OpenRoadmInterfaceException ex) {
186 processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
189 NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder();
190 nodeInterfaceBuilder.withKey(new NodeInterfaceKey(nodeId));
191 nodeInterfaceBuilder.setNodeId(nodeId);
192 nodeInterfaceBuilder.setConnectionId(createdConnections);
193 nodeInterfaceBuilder.setEthInterfaceId(createdEthInterfaces);
194 nodeInterfaceBuilder.setOtuInterfaceId(createdOtuInterfaces);
195 nodeInterfaceBuilder.setOduInterfaceId(createdOduInterfaces);
196 nodeInterfaceBuilder.setOchInterfaceId(createdOchInterfaces);
197 nodeInterfaces.add(nodeInterfaceBuilder.build());
201 } catch (InterruptedException | ExecutionException e) {
202 LOG.error("Error while setting up service paths!", e);
204 forkJoinPool.shutdown();
207 results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
209 ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder();
210 setServBldr.setNodeInterface(new ArrayList<>(nodeInterfaces));
211 setServBldr.setSuccess(success.get());
212 setServBldr.setResult(String.join("\n", results));
213 // setting topology in the service list data store
215 setTopologyForService(input.getServiceName(), topology.getTopology());
216 } catch (InterruptedException | TimeoutException | ExecutionException e) {
217 LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e);
219 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
220 LOG.error("Alarm suppresion node removal failed!!!!");
222 return setServBldr.build();
225 private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
226 ConcurrentLinkedQueue<String> messages) {
228 messages.add(message);
229 forkJoinPool.shutdown();
234 public ServicePathOutput deleteServicePath(ServicePathInput input) {
235 List<Nodes> nodes = input.getNodes();
236 AtomicBoolean success = new AtomicBoolean(true);
237 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
238 if (!alarmSuppressionNodeRegistration(input)) {
239 LOG.warn("Alarm suppresion node registraion failed!!!!");
241 ForkJoinPool forkJoinPool = new ForkJoinPool();
242 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
243 List<String> interfacesToDelete = new LinkedList<>();
244 String nodeId = node.getNodeId();
245 LOG.info("Deleting service setup on node {}", nodeId);
246 String srcTp = node.getSrcTp();
247 String destTp = node.getDestTp();
248 Long waveNumber = input.getWaveNumber();
249 if ((srcTp == null) || (destTp == null)) {
250 LOG.error("Source ({}) or destination ({}) termination point is null.", srcTp, destTp);
253 // if the node is currently mounted then proceed.
254 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
255 if (destTp.contains(StringConstants.NETWORK_TOKEN)
256 || srcTp.contains(StringConstants.CLIENT_TOKEN)
257 || srcTp.contains(StringConstants.NETWORK_TOKEN)
258 || destTp.contains(StringConstants.CLIENT_TOKEN)) {
259 if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
260 interfacesToDelete.add(destTp + "-ODU");
261 interfacesToDelete.add(destTp + "-OTU");
262 interfacesToDelete.add(
263 this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
265 if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
266 interfacesToDelete.add(srcTp + "-ODU");
267 interfacesToDelete.add(srcTp + "-OTU");
269 .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
271 if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
272 interfacesToDelete.add(srcTp + "-ETHERNET");
274 if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
275 interfacesToDelete.add(destTp + "-ETHERNET");
278 String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
279 List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber);
280 connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
281 if (intToDelete != null) {
282 for (String interf : intToDelete) {
283 if (!this.openRoadmInterfaceFactory.isUsedbyXc(nodeId, interf, connectionNumber,
284 this.deviceTransactionManager)) {
285 interfacesToDelete.add(interf);
291 String result = nodeId + " is not mounted on the controller";
295 forkJoinPool.shutdown();
296 return; // TODO should deletion end here?
298 for (String interfaceId : interfacesToDelete) {
300 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
301 } catch (OpenRoadmInterfaceException e) {
302 String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
304 LOG.error(result, e);
311 } catch (InterruptedException | ExecutionException e) {
312 LOG.error("Error while deleting service paths!", e);
314 forkJoinPool.shutdown();
315 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
316 LOG.error("Alarm suppresion node removal failed!!!!");
318 ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
319 delServBldr.setSuccess(success.get());
320 if (results.isEmpty()) {
321 return delServBldr.setResult("Request processed").build();
323 return delServBldr.setResult(String.join("\n", results)).build();
328 public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
329 boolean success = true;
330 List<FailedToRollback> failedToRollbackList = new ArrayList<>();
331 for (NodeInterface nodeInterfaces : input.getNodeInterface()) {
332 List<String> failedInterfaces = new ArrayList<>();
333 String nodeId = nodeInterfaces.getNodeId();
334 for (String connectionId : nodeInterfaces.getConnectionId()) {
335 List<String> listInter = this.crossConnect.deleteCrossConnect(nodeId, connectionId);
336 if (listInter != null) {
337 LOG.info("Cross connect {} on node {} successfully deleted.", connectionId, nodeId);
339 LOG.error("Failed to delete cross connect {} on node {}!", connectionId, nodeId);
341 failedInterfaces.add(connectionId);
344 // Interfaces needs to be in specific order to delete. Order is:
349 LinkedList<String> interfacesToDelete = new LinkedList<>();
350 if (nodeInterfaces.getOduInterfaceId() != null) {
351 interfacesToDelete.addAll(nodeInterfaces.getOduInterfaceId());
353 if (nodeInterfaces.getOtuInterfaceId() != null) {
354 interfacesToDelete.addAll(nodeInterfaces.getOtuInterfaceId());
356 if (nodeInterfaces.getOchInterfaceId() != null) {
357 interfacesToDelete.addAll(nodeInterfaces.getOchInterfaceId());
359 if (nodeInterfaces.getEthInterfaceId() != null) {
360 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
362 LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
363 String.join(", ", interfacesToDelete));
364 for (String interfaceId : interfacesToDelete) {
366 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
367 LOG.info("Interface {} on node {} successfully deleted.", interfaceId, nodeId);
368 } catch (OpenRoadmInterfaceException e) {
369 LOG.error("Failed to delete interface {} on node {}!", interfaceId, nodeId);
371 failedInterfaces.add(interfaceId);
374 failedToRollbackList.add(new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
375 .setNodeId(nodeId).setInterface(failedInterfaces).build());
377 return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
381 private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
382 NodelistBuilder nodeListBuilder = new NodelistBuilder();
383 nodeListBuilder.withKey(new NodelistKey(input.getServiceName()));
384 nodeListBuilder.setServiceName(input.getServiceName());
385 List<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
386 .nodelist.nodelist.Nodes> nodeList =
388 for (Nodes node : input.getNodes()) {
390 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
391 .service.nodelist.nodelist.NodesBuilder()
392 .setNodeId(node.getNodeId()).build());
394 nodeListBuilder.setNodes(nodeList);
395 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
396 .service.nodelist.Nodelist> nodeListIID =
397 InstanceIdentifier.create(ServiceNodelist.class).child(
398 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
399 .rev171102.service.nodelist.Nodelist.class,
400 new NodelistKey(input.getServiceName()));
401 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
402 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
403 Future<Void> submit = writeTransaction.submit();
405 submit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
406 LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
408 } catch (ExecutionException | InterruptedException | TimeoutException e) {
409 LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e);
414 private boolean alarmSuppressionNodeRemoval(String serviceName) {
415 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
416 .service.nodelist.Nodelist> nodeListIID =
417 InstanceIdentifier.create(ServiceNodelist.class).child(
418 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
419 .rev171102.service.nodelist.Nodelist.class,
420 new NodelistKey(serviceName));
421 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
422 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
423 Future<Void> submit = writeTransaction.submit();
425 submit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
426 LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
428 } catch (InterruptedException | TimeoutException | ExecutionException e) {
429 LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e);
434 private void setTopologyForService(String name, Topology topo)
435 throws InterruptedException, ExecutionException, TimeoutException {
436 ServicesBuilder servicesBuilder;
437 // Get the service from the service list inventory
438 ServicesKey serviceKey = new ServicesKey(name);
439 InstanceIdentifier<Services> iid =
440 InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
441 Optional<Services> services;
442 try (ReadOnlyTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
443 Future<com.google.common.base.Optional<Services>> future =
444 readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
445 services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS).toJavaUtil();
446 } catch (InterruptedException | ExecutionException | TimeoutException e) {
449 if (services.isPresent()) {
450 LOG.info("service {} already exists", name);
451 servicesBuilder = new ServicesBuilder(services.get());
452 servicesBuilder.setTopology(topo);
453 WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
454 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
455 writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
457 LOG.warn("Service {} does not exist - topology can not be updated", name);
462 public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
463 CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
465 Boolean success = false;
466 // if the node is currently mounted then proceed.
467 if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
468 Mapping oldMapping = null;
469 Mapping newMapping = null;
470 oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
471 if (oldMapping != null) {
472 String otsInterface =
473 this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
474 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
476 Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
477 while (!isSupportingOtsPresent && (count < 6)) {
478 LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
481 this.portMapping.updateMapping(input.getNodeId(), oldMapping);
482 } catch (InterruptedException e) {
483 LOG.error("Failed to wait for post interface operation ");
485 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
486 isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
490 String omsInterface =
491 this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
492 if (omsInterface != null) {
493 result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
497 LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
498 result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
501 LOG.error("Unable to get ots interface from mapping {} for node {}",
502 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
503 result = String.format("Unable to get ots interface from mapping %s - %s",
504 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
507 result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
511 result = input.getNodeId() + " is not mounted on the controller";
514 return output.setResult(result).setSuccess(success).build();
517 private Boolean isSupportingOtsPresent(Mapping mapping) {
518 Boolean result = false;
519 if (mapping != null) {
520 if (mapping.getSupportingOts() != null) {
521 LOG.info("SupportingOts info is present in mapping {}", mapping);
524 LOG.warn("SupportingOts info not present in mapping {}", mapping);