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.CopyOnWriteArrayList;
19 import java.util.concurrent.ExecutionException;
20 import java.util.concurrent.ForkJoinPool;
21 import java.util.concurrent.ForkJoinTask;
22 import java.util.concurrent.Future;
23 import java.util.concurrent.TimeUnit;
24 import java.util.concurrent.TimeoutException;
25 import java.util.concurrent.atomic.AtomicBoolean;
26 import org.eclipse.jdt.annotation.NonNull;
27 import org.opendaylight.mdsal.binding.api.DataBroker;
28 import org.opendaylight.mdsal.binding.api.ReadTransaction;
29 import org.opendaylight.mdsal.binding.api.WriteTransaction;
30 import org.opendaylight.mdsal.common.api.CommitInfo;
31 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
32 import org.opendaylight.transportpce.common.StringConstants;
33 import org.opendaylight.transportpce.common.Timeouts;
34 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
35 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
36 import org.opendaylight.transportpce.common.mapping.PortMapping;
37 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
38 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
39 import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
40 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
41 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
42 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
43 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
44 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
46 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200429.network.nodes.Mapping;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsInput;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsOutput;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsOutputBuilder;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackInput;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackOutput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackOutputBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathInput;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutput;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutputBuilder;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollback;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollbackBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollbackKey;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.Topology;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceList;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesKey;
65 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterface;
66 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceKey;
68 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.olm.renderer.input.Nodes;
69 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
70 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
71 import org.slf4j.Logger;
72 import org.slf4j.LoggerFactory;
75 public class DeviceRendererServiceImpl implements DeviceRendererService {
76 private static final String ODU4 = "-ODU4";
77 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
78 private final DataBroker dataBroker;
79 private final DeviceTransactionManager deviceTransactionManager;
80 private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
81 private final OpenRoadmInterfaces openRoadmInterfaces;
82 private final CrossConnect crossConnect;
83 private final PortMapping portMapping;
84 private final NetworkModelService networkModelService;
86 public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
87 OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
88 CrossConnect crossConnect, PortMapping portMapping, NetworkModelService networkModelService) {
89 this.dataBroker = dataBroker;
90 this.deviceTransactionManager = deviceTransactionManager;
91 this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
92 this.openRoadmInterfaces = openRoadmInterfaces;
93 this.crossConnect = crossConnect;
94 this.portMapping = portMapping;
95 this.networkModelService = networkModelService;
99 public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
100 List<Nodes> nodes = input.getNodes();
102 // Register node for suppressing alarms
103 if (!alarmSuppressionNodeRegistration(input)) {
104 LOG.warn("Alarm suppresion node registration failed!!!!");
106 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
107 Set<NodeInterface> nodeInterfaces = Sets.newConcurrentHashSet();
108 Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
109 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
110 ServiceListTopology topology = new ServiceListTopology();
111 AtomicBoolean success = new AtomicBoolean(true);
112 ForkJoinPool forkJoinPool = new ForkJoinPool();
114 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
115 String nodeId = node.getNodeId();
116 // take the index of the node
117 int nodeIndex = nodes.indexOf(node);
118 LOG.info("Starting provisioning for node : {}", nodeId);
119 List<String> createdEthInterfaces = new ArrayList<>();
120 List<String> createdOtuInterfaces = new ArrayList<>();
121 List<String> createdOduInterfaces = new ArrayList<>();
122 List<String> createdOchInterfaces = new ArrayList<>();
123 List<String> createdConnections = new ArrayList<>();
124 int crossConnectFlag = 0;
126 // if the node is currently mounted then proceed
127 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
128 String srcTp = node.getSrcTp();
129 String destTp = node.getDestTp();
130 Long waveNumber = input.getWaveNumber().toJava();
131 if ((destTp != null) && destTp.contains(StringConstants.NETWORK_TOKEN)) {
133 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
134 nodeId, destTp, waveNumber, ModulationFormat.DpQpsk);
135 createdOchInterfaces.add(supportingOchInterface);
136 // Here we pass logical connection-point of z-end to set SAPI and DAPI
137 Nodes tgtNode = null;
138 if (nodeIndex + 1 == nodes.size()) {
139 // For the end node, tgtNode becomes the first node in the list
140 tgtNode = nodes.get(0);
142 tgtNode = nodes.get(nodeIndex + 1);
144 // tgtNode srcTp is null in this if cond
145 String supportingOtuInterface = this.openRoadmInterfaceFactory
146 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface,
147 tgtNode.getNodeId(), tgtNode.getDestTp());
148 createdOtuInterfaces.add(supportingOtuInterface);
150 otnNodesProvisioned.add(node);
152 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
153 destTp, supportingOtuInterface));
156 if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
158 // create OpenRoadm Xponder Client Interfaces
159 createdEthInterfaces.add(
160 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
162 if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
164 // create OpenRoadm Xponder Line Interfaces
165 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
166 nodeId, srcTp, waveNumber, ModulationFormat.DpQpsk);
167 createdOchInterfaces.add(supportingOchInterface);
168 String supportingOtuInterface = this.openRoadmInterfaceFactory
169 .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
170 createdOtuInterfaces.add(supportingOtuInterface);
171 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
172 srcTp, supportingOtuInterface));
173 Mapping mapping = this.portMapping.getMapping(nodeId,srcTp);
174 if (mapping != null && mapping.getXponderType() != null
175 && (mapping.getXponderType().getIntValue() == 3
176 || mapping.getXponderType().getIntValue() == 2)) {
177 createdOduInterfaces.add(this.openRoadmInterfaceFactory
178 .createOpenRoadmOtnOdu4Interface(nodeId, destTp, supportingOtuInterface));
180 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
181 destTp, supportingOtuInterface));
184 if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
186 // create OpenRoadm Xponder Client Interfaces
187 createdEthInterfaces.add(
188 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
190 if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
191 || srcTp.contains(StringConstants.PP_TOKEN))) {
192 createdOchInterfaces.addAll(
193 this.openRoadmInterfaceFactory
194 .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber));
196 if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
197 || destTp.contains(StringConstants.PP_TOKEN))) {
198 createdOchInterfaces.addAll(
199 this.openRoadmInterfaceFactory
200 .createOpenRoadmOchInterface(nodeId, destTp, waveNumber));
202 if (crossConnectFlag < 1) {
203 LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
205 Optional<String> connectionNameOpt =
206 this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp);
207 if (connectionNameOpt.isPresent()) {
208 nodesProvisioned.add(nodeId);
209 createdConnections.add(connectionNameOpt.get());
211 processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
217 processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
220 } catch (OpenRoadmInterfaceException ex) {
221 processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
224 NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
225 .withKey(new NodeInterfaceKey(nodeId))
227 .setConnectionId(createdConnections)
228 .setEthInterfaceId(createdEthInterfaces)
229 .setOtuInterfaceId(createdOtuInterfaces)
230 .setOduInterfaceId(createdOduInterfaces)
231 .setOchInterfaceId(createdOchInterfaces);
232 nodeInterfaces.add(nodeInterfaceBuilder.build());
236 } catch (InterruptedException | ExecutionException e) {
237 LOG.error("Error while setting up service paths!", e);
239 forkJoinPool.shutdown();
242 results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
244 // setting topology in the service list data store
246 setTopologyForService(input.getServiceName(), topology.getTopology());
247 updateOtnTopology(otnNodesProvisioned, false);
248 } catch (InterruptedException | TimeoutException | ExecutionException e) {
249 LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e);
251 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
252 LOG.error("Alarm suppresion node removal failed!!!!");
254 ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
255 .setNodeInterface(new ArrayList<>(nodeInterfaces))
256 .setSuccess(success.get())
257 .setResult(String.join("\n", results));
258 return setServBldr.build();
261 private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
262 ConcurrentLinkedQueue<String> messages) {
263 LOG.warn("Received error message {}", message);
264 messages.add(message);
265 forkJoinPool.shutdown();
270 public ServicePathOutput deleteServicePath(ServicePathInput input) {
271 List<Nodes> nodes = input.getNodes();
272 AtomicBoolean success = new AtomicBoolean(true);
273 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
274 if (!alarmSuppressionNodeRegistration(input)) {
275 LOG.warn("Alarm suppresion node registraion failed!!!!");
277 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
278 ForkJoinPool forkJoinPool = new ForkJoinPool();
279 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
280 List<String> interfacesToDelete = new LinkedList<>();
281 String nodeId = node.getNodeId();
282 LOG.info("Deleting service setup on node {}", nodeId);
285 Long waveNumber = input.getWaveNumber().toJava();
286 if (node.getDestTp() == null) {
287 LOG.error("Destination termination point must not be null.");
290 destTp = node.getDestTp();
292 if (node.getSrcTp() != null) {
293 srcTp = node.getSrcTp();
296 otnNodesProvisioned.add(node);
298 // if the node is currently mounted then proceed.
299 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
300 interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp, waveNumber));
302 String result = nodeId + " is not mounted on the controller";
306 forkJoinPool.shutdown();
308 //TODO should deletion end here?
310 for (String interfaceId : interfacesToDelete) {
312 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
313 } catch (OpenRoadmInterfaceException e) {
314 String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
316 LOG.error(result, e);
323 } catch (InterruptedException | ExecutionException e) {
324 LOG.error("Error while deleting service paths!", e);
326 forkJoinPool.shutdown();
327 updateOtnTopology(otnNodesProvisioned, true);
328 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
329 LOG.error("Alarm suppresion node removal failed!!!!");
331 ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
332 delServBldr.setSuccess(success.get());
333 if (results.isEmpty()) {
334 return delServBldr.setResult("Request processed").build();
336 return delServBldr.setResult(String.join("\n", results)).build();
340 private List<String> getInterfaces2delete(
341 String nodeId, String srcTp, String destTp, Long waveNumber) {
342 List<String> interfacesToDelete = new LinkedList<>();
343 if (destTp.contains(StringConstants.NETWORK_TOKEN)
344 || srcTp.contains(StringConstants.CLIENT_TOKEN)
345 || srcTp.contains(StringConstants.NETWORK_TOKEN)
346 || destTp.contains(StringConstants.CLIENT_TOKEN)) {
347 if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
349 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
350 interfacesToDelete.add(destTp + "-ODU");
352 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) {
353 interfacesToDelete.add(destTp + ODU4);
356 catch (OpenRoadmInterfaceException e) {
357 LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e);
359 interfacesToDelete.add(destTp + "-OTU");
360 interfacesToDelete.add(
361 this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
363 if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
364 interfacesToDelete.add(srcTp + "-ODU");
365 interfacesToDelete.add(srcTp + "-OTU");
367 .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
369 if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
370 interfacesToDelete.add(srcTp + "-ETHERNET");
372 if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
373 interfacesToDelete.add(destTp + "-ETHERNET");
376 String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
377 List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
378 connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
379 if (intToDelete != null) {
380 for (String interf : intToDelete) {
381 if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber,
382 this.deviceTransactionManager)) {
383 interfacesToDelete.add(interf);
388 return interfacesToDelete;
392 public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
393 boolean success = true;
394 List<FailedToRollback> failedToRollbackList = new ArrayList<>();
395 for (NodeInterface nodeInterfaces : input.getNodeInterface()) {
396 List<String> failedInterfaces = new ArrayList<>();
397 String nodeId = nodeInterfaces.getNodeId();
398 for (String connectionId : nodeInterfaces.getConnectionId()) {
399 List<String> listInter = this.crossConnect.deleteCrossConnect(nodeId, connectionId, false);
400 if (listInter != null) {
401 LOG.info("Cross connect {} on node {} successfully deleted.", connectionId, nodeId);
403 LOG.error("Failed to delete cross connect {} on node {}!", connectionId, nodeId);
405 failedInterfaces.add(connectionId);
408 // Interfaces needs to be in specific order to delete. Order is:
413 LinkedList<String> interfacesToDelete = new LinkedList<>();
414 if (nodeInterfaces.getOduInterfaceId() != null) {
415 interfacesToDelete.addAll(nodeInterfaces.getOduInterfaceId());
417 if (nodeInterfaces.getOtuInterfaceId() != null) {
418 interfacesToDelete.addAll(nodeInterfaces.getOtuInterfaceId());
420 if (nodeInterfaces.getOchInterfaceId() != null) {
421 interfacesToDelete.addAll(nodeInterfaces.getOchInterfaceId());
423 if (nodeInterfaces.getEthInterfaceId() != null) {
424 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
426 LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
427 String.join(", ", interfacesToDelete));
428 for (String interfaceId : interfacesToDelete) {
430 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
431 LOG.info("Interface {} on node {} successfully deleted.", interfaceId, nodeId);
432 } catch (OpenRoadmInterfaceException e) {
433 LOG.error("Failed to delete interface {} on node {}!", interfaceId, nodeId);
435 failedInterfaces.add(interfaceId);
438 failedToRollbackList.add(new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
439 .setNodeId(nodeId).setInterface(failedInterfaces).build());
441 return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
445 private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
446 NodelistBuilder nodeListBuilder = new NodelistBuilder()
447 .withKey(new NodelistKey(input.getServiceName()))
448 .setServiceName(input.getServiceName());
449 List<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
450 .nodelist.nodelist.Nodes> nodeList =
452 for (Nodes node : input.getNodes()) {
454 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
455 .service.nodelist.nodelist.NodesBuilder()
456 .setNodeId(node.getNodeId()).build());
458 nodeListBuilder.setNodes(nodeList);
459 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
460 .service.nodelist.Nodelist> nodeListIID =
461 InstanceIdentifier.create(ServiceNodelist.class).child(
462 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
463 .rev171102.service.nodelist.Nodelist.class,
464 new NodelistKey(input.getServiceName()));
465 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
466 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
467 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
469 commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
470 LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
472 } catch (ExecutionException | InterruptedException | TimeoutException e) {
473 LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e);
478 private boolean alarmSuppressionNodeRemoval(String serviceName) {
479 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
480 .service.nodelist.Nodelist> nodeListIID =
481 InstanceIdentifier.create(ServiceNodelist.class).child(
482 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
483 .rev171102.service.nodelist.Nodelist.class,
484 new NodelistKey(serviceName));
485 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
486 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
487 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
489 commit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
490 LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
492 } catch (InterruptedException | TimeoutException | ExecutionException e) {
493 LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e);
498 private void setTopologyForService(String name, Topology topo)
499 throws InterruptedException, ExecutionException, TimeoutException {
500 ServicesBuilder servicesBuilder;
501 // Get the service from the service list inventory
502 ServicesKey serviceKey = new ServicesKey(name);
503 InstanceIdentifier<Services> iid =
504 InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
505 Optional<Services> services;
506 try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
507 Future<java.util.Optional<Services>> future =
508 readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
509 services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
510 } catch (InterruptedException | ExecutionException | TimeoutException e) {
513 if (services.isPresent()) {
514 LOG.info("service {} already exists", name);
515 servicesBuilder = new ServicesBuilder(services.get()).setTopology(topo);
516 WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
517 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
518 writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
520 LOG.warn("Service {} does not exist - topology can not be updated", name);
525 public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
526 CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
528 Boolean success = false;
529 // if the node is currently mounted then proceed.
530 if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
531 Mapping oldMapping = null;
532 Mapping newMapping = null;
533 oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
534 if (oldMapping != null) {
535 String otsInterface =
536 this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
537 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
539 Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
540 while (!isSupportingOtsPresent && (count < 6)) {
541 LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
544 this.portMapping.updateMapping(input.getNodeId(), oldMapping);
545 } catch (InterruptedException e) {
546 LOG.error("Failed to wait for post interface operation ");
548 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
549 isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
553 String omsInterface =
554 this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
555 if (omsInterface != null) {
556 result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
560 LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
561 result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
564 LOG.error("Unable to get ots interface from mapping {} for node {}",
565 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
566 result = String.format("Unable to get ots interface from mapping %s - %s",
567 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
570 result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
574 result = input.getNodeId() + " is not mounted on the controller";
575 LOG.warn("{} is not mounted on the controller",input.getNodeId());
577 return output.setResult(result).setSuccess(success).build();
580 private Boolean isSupportingOtsPresent(Mapping mapping) {
581 Boolean result = false;
582 if (mapping != null) {
583 if (mapping.getSupportingOts() != null) {
584 LOG.info("SupportingOts info is present in mapping {}", mapping);
587 LOG.warn("SupportingOts info not present in mapping {}", mapping);
593 private void updateOtnTopology(CopyOnWriteArrayList<Nodes> nodes, boolean isDeletion) {
594 if (nodes.size() != 2) {
595 LOG.error("Error with OTU4 links to update in otn-topology");
599 LOG.info("updating otn-topology removing OTU4 links");
600 this.networkModelService.deleteOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
601 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);
603 LOG.info("updating otn-topology adding OTU4 links");
604 this.networkModelService.createOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
605 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);