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.HashMap;
14 import java.util.LinkedList;
15 import java.util.List;
17 import java.util.Optional;
19 import java.util.concurrent.ConcurrentHashMap;
20 import java.util.concurrent.ConcurrentLinkedQueue;
21 import java.util.concurrent.CopyOnWriteArrayList;
22 import java.util.concurrent.ExecutionException;
23 import java.util.concurrent.ForkJoinPool;
24 import java.util.concurrent.ForkJoinTask;
25 import java.util.concurrent.Future;
26 import java.util.concurrent.TimeUnit;
27 import java.util.concurrent.TimeoutException;
28 import java.util.concurrent.atomic.AtomicBoolean;
29 import org.eclipse.jdt.annotation.NonNull;
30 import org.opendaylight.mdsal.binding.api.DataBroker;
31 import org.opendaylight.mdsal.binding.api.ReadTransaction;
32 import org.opendaylight.mdsal.binding.api.WriteTransaction;
33 import org.opendaylight.mdsal.common.api.CommitInfo;
34 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
35 import org.opendaylight.transportpce.common.StringConstants;
36 import org.opendaylight.transportpce.common.Timeouts;
37 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
38 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
39 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
40 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
41 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
42 import org.opendaylight.transportpce.common.mapping.PortMapping;
43 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
44 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
45 import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
46 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
47 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
48 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.CreateOtsOmsInput;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.CreateOtsOmsOutput;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.CreateOtsOmsOutputBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.RendererRollbackInput;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.RendererRollbackOutput;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.RendererRollbackOutputBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.ServicePathInput;
59 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.ServicePathOutput;
60 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.ServicePathOutputBuilder;
61 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollback;
62 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollbackBuilder;
63 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev200128.renderer.rollback.output.FailedToRollbackKey;
64 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.Topology;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceList;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesKey;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.node.interfaces.NodeInterface;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.node.interfaces.NodeInterfaceBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.node.interfaces.NodeInterfaceKey;
73 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev201211.olm.renderer.input.Nodes;
74 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType;
75 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
80 public class DeviceRendererServiceImpl implements DeviceRendererService {
81 private static final String IS_NOT_MOUNTED_ON_THE_CONTROLLER = " is not mounted on the controller";
82 private static final String ODU4 = "-ODU4";
83 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
84 private final DataBroker dataBroker;
85 private final DeviceTransactionManager deviceTransactionManager;
86 private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
87 private final OpenRoadmInterfaces openRoadmInterfaces;
88 private final CrossConnect crossConnect;
89 private final PortMapping portMapping;
90 private final NetworkModelService networkModelService;
92 public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
93 OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
94 CrossConnect crossConnect, PortMapping portMapping, NetworkModelService networkModelService) {
95 this.dataBroker = dataBroker;
96 this.deviceTransactionManager = deviceTransactionManager;
97 this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
98 this.openRoadmInterfaces = openRoadmInterfaces;
99 this.crossConnect = crossConnect;
100 this.portMapping = portMapping;
101 this.networkModelService = networkModelService;
105 public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
106 LOG.info("setup service path for input {} and direction {}", input, direction);
107 List<Nodes> nodes = new ArrayList<>();
108 if (input.getNodes() != null) {
109 nodes.addAll(input.getNodes());
111 SpectrumInformation spectrumInformation = GridUtils.initSpectrumInformationFromServicePathInput(input);
112 // Register node for suppressing alarms
113 if (!alarmSuppressionNodeRegistration(input)) {
114 LOG.warn("Alarm suppresion node registration failed!!!!");
116 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
117 Map<NodeInterfaceKey,NodeInterface> nodeInterfaces = new ConcurrentHashMap<>();
118 Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
119 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
120 ServiceListTopology topology = new ServiceListTopology();
121 AtomicBoolean success = new AtomicBoolean(true);
122 ForkJoinPool forkJoinPool = new ForkJoinPool();
123 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
124 String nodeId = node.getNodeId();
125 // take the index of the node
126 int nodeIndex = nodes.indexOf(node);
127 LOG.info("Starting provisioning for node : {}", nodeId);
128 List<String> createdEthInterfaces = new ArrayList<>();
129 List<String> createdOtuInterfaces = new ArrayList<>();
130 List<String> createdOduInterfaces = new ArrayList<>();
131 List<String> createdOchInterfaces = new ArrayList<>();
132 List<String> createdConnections = new ArrayList<>();
133 int crossConnectFlag = 0;
135 // if the node is currently mounted then proceed
136 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
137 String srcTp = node.getSrcTp();
138 String destTp = node.getDestTp();
139 if ((destTp != null) && destTp.contains(StringConstants.NETWORK_TOKEN)) {
140 LOG.info("Adding supporting OCH interface for node {}, dest tp {}, spectrumInformation {}",
141 nodeId, destTp, spectrumInformation);
143 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
144 nodeId, destTp, spectrumInformation);
145 createdOchInterfaces.add(supportingOchInterface);
146 // Here we pass logical connection-point of z-end to set SAPI and DAPI
147 Nodes tgtNode = null;
148 if (nodeIndex + 1 == nodes.size()) {
149 // For the end node, tgtNode becomes the first node in the list
150 tgtNode = nodes.get(0);
152 tgtNode = nodes.get(nodeIndex + 1);
154 // tgtNode srcTp is null in this if cond
155 String supportingOtuInterface = this.openRoadmInterfaceFactory
156 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface,
157 tgtNode.getNodeId(), tgtNode.getDestTp());
158 createdOtuInterfaces.add(supportingOtuInterface);
160 otnNodesProvisioned.add(node);
162 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
163 destTp, supportingOtuInterface));
166 if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
167 LOG.info("Adding supporting EThernet interface for node {}, src tp {}", nodeId, srcTp);
169 // create OpenRoadm Xponder Client Interfaces
170 createdEthInterfaces.add(
171 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
173 if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
174 LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
175 nodeId, srcTp, spectrumInformation);
177 // create OpenRoadm Xponder Line Interfaces
178 String supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
179 nodeId, srcTp, spectrumInformation);
180 createdOchInterfaces.add(supportingOchInterface);
181 String supportingOtuInterface = this.openRoadmInterfaceFactory
182 .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
183 createdOtuInterfaces.add(supportingOtuInterface);
184 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
185 srcTp, supportingOtuInterface));
186 Mapping mapping = this.portMapping.getMapping(nodeId,srcTp);
187 if (mapping != null && mapping.getXponderType() != null
188 && (mapping.getXponderType().getIntValue() == 3
189 || mapping.getXponderType().getIntValue() == 2)) {
190 createdOduInterfaces.add(this.openRoadmInterfaceFactory
191 .createOpenRoadmOtnOdu4Interface(nodeId, destTp, supportingOtuInterface));
193 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
194 destTp, supportingOtuInterface));
197 if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
198 LOG.info("Adding supporting EThernet interface for node {}, dest tp {}", nodeId, destTp);
200 // create OpenRoadm Xponder Client Interfaces
201 createdEthInterfaces.add(
202 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
204 if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
205 || srcTp.contains(StringConstants.PP_TOKEN))) {
206 LOG.info("Adding supporting OCH interface for node {}, src tp {}, spectrumInformation {}",
207 nodeId, srcTp, spectrumInformation);
208 createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(nodeId,
209 srcTp, spectrumInformation));
211 if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
212 || destTp.contains(StringConstants.PP_TOKEN))) {
213 LOG.info("Adding supporting OCH interface for node {}, dest tp {}, spectrumInformation {}",
214 nodeId, destTp, spectrumInformation);
215 createdOchInterfaces.addAll(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaces(nodeId,
216 destTp, spectrumInformation));
218 if (crossConnectFlag < 1) {
219 LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
221 Optional<String> connectionNameOpt =
222 this.crossConnect.postCrossConnect(nodeId, srcTp, destTp, spectrumInformation);
223 if (connectionNameOpt.isPresent()) {
224 nodesProvisioned.add(nodeId);
225 createdConnections.add(connectionNameOpt.get());
227 processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
233 processErrorMessage(nodeId + IS_NOT_MOUNTED_ON_THE_CONTROLLER, forkJoinPool, results);
236 } catch (OpenRoadmInterfaceException ex) {
237 processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
240 NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
241 .withKey(new NodeInterfaceKey(nodeId))
243 .setConnectionId(createdConnections)
244 .setEthInterfaceId(createdEthInterfaces)
245 .setOtuInterfaceId(createdOtuInterfaces)
246 .setOduInterfaceId(createdOduInterfaces)
247 .setOchInterfaceId(createdOchInterfaces);
248 NodeInterface nodeInterface = nodeInterfaceBuilder.build();
249 nodeInterfaces.put(nodeInterface.key(),nodeInterface);
253 } catch (InterruptedException | ExecutionException e) {
254 LOG.error("Error while setting up service paths!", e);
256 forkJoinPool.shutdown();
259 results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
261 // setting topology in the service list data store
263 setTopologyForService(input.getServiceName(), topology.getTopology());
264 updateOtnTopology(otnNodesProvisioned, false);
265 } catch (InterruptedException | TimeoutException | ExecutionException e) {
266 LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e);
268 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
269 LOG.error("Alarm suppresion node removal failed!!!!");
271 ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
272 .setNodeInterface(nodeInterfaces)
273 .setSuccess(success.get())
274 .setResult(String.join("\n", results));
275 return setServBldr.build();
278 private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
279 ConcurrentLinkedQueue<String> messages) {
280 LOG.warn("Received error message {}", message);
281 messages.add(message);
282 forkJoinPool.shutdown();
287 public ServicePathOutput deleteServicePath(ServicePathInput input) {
288 List<Nodes> nodes = input.getNodes();
289 AtomicBoolean success = new AtomicBoolean(true);
290 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
291 if (!alarmSuppressionNodeRegistration(input)) {
292 LOG.warn("Alarm suppresion node registraion failed!!!!");
294 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
295 ForkJoinPool forkJoinPool = new ForkJoinPool();
296 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
297 List<String> interfacesToDelete = new LinkedList<>();
298 String nodeId = node.getNodeId();
299 LOG.info("Deleting service setup on node {}", nodeId);
302 if (node.getDestTp() == null) {
303 LOG.error("Destination termination point must not be null.");
306 destTp = node.getDestTp();
308 if (node.getSrcTp() != null) {
309 srcTp = node.getSrcTp();
312 otnNodesProvisioned.add(node);
314 // if the node is currently mounted then proceed.
315 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
316 interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp,
317 input.getLowerSpectralSlotNumber().intValue(),
318 input.getHigherSpectralSlotNumber().intValue()));
320 String result = nodeId + IS_NOT_MOUNTED_ON_THE_CONTROLLER;
324 forkJoinPool.shutdown();
326 //TODO should deletion end here?
328 for (String interfaceId : interfacesToDelete) {
330 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
331 } catch (OpenRoadmInterfaceException e) {
332 String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
334 LOG.error(result, e);
341 } catch (InterruptedException | ExecutionException e) {
342 LOG.error("Error while deleting service paths!", e);
344 forkJoinPool.shutdown();
345 updateOtnTopology(otnNodesProvisioned, true);
346 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
347 LOG.error("Alarm suppresion node removal failed!!!!");
349 ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
350 delServBldr.setSuccess(success.get());
351 if (results.isEmpty()) {
352 return delServBldr.setResult("Request processed").build();
354 return delServBldr.setResult(String.join("\n", results)).build();
358 private List<String> getInterfaces2delete(
359 String nodeId, String srcTp, String destTp, int lowerSpectralSlotNumber, int higherSpectralSlotNumber) {
360 String spectralSlotName = String.join(GridConstant.SPECTRAL_SLOT_SEPARATOR,
361 String.valueOf(lowerSpectralSlotNumber),
362 String.valueOf(higherSpectralSlotNumber));
363 List<String> interfacesToDelete = new LinkedList<>();
364 if (destTp.contains(StringConstants.NETWORK_TOKEN)
365 || srcTp.contains(StringConstants.CLIENT_TOKEN)
366 || srcTp.contains(StringConstants.NETWORK_TOKEN)
367 || destTp.contains(StringConstants.CLIENT_TOKEN)) {
368 if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
370 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
371 interfacesToDelete.add(destTp + "-ODU");
373 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) {
374 interfacesToDelete.add(destTp + ODU4);
377 catch (OpenRoadmInterfaceException e) {
378 LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e);
380 interfacesToDelete.add(destTp + "-OTU");
381 interfacesToDelete.add(
382 this.openRoadmInterfaceFactory
383 .createOpenRoadmOchInterfaceName(destTp,spectralSlotName));
385 if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
386 interfacesToDelete.add(srcTp + "-ODU");
387 interfacesToDelete.add(srcTp + "-OTU");
389 .add(this.openRoadmInterfaceFactory
390 .createOpenRoadmOchInterfaceName(srcTp,spectralSlotName));
392 if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
393 interfacesToDelete.add(srcTp + "-ETHERNET");
395 if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
396 interfacesToDelete.add(destTp + "-ETHERNET");
399 String connectionNumber = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, srcTp, destTp,
401 List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
402 connectionNumber = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, destTp, srcTp, spectralSlotName);
403 if (intToDelete != null) {
404 for (String interf : intToDelete) {
405 if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber,
406 this.deviceTransactionManager)) {
407 interfacesToDelete.add(interf);
412 return interfacesToDelete;
416 public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
417 boolean success = true;
418 Map<FailedToRollbackKey,FailedToRollback> failedToRollbackList = new HashMap<>();
419 for (NodeInterface nodeInterfaces : input.nonnullNodeInterface().values()) {
420 List<String> failedInterfaces = new ArrayList<>();
421 String nodeId = nodeInterfaces.getNodeId();
422 for (String connectionId : nodeInterfaces.getConnectionId()) {
423 List<String> listInter = this.crossConnect.deleteCrossConnect(nodeId, connectionId, false);
424 if (listInter != null) {
425 LOG.info("Cross connect {} on node {} successfully deleted.", connectionId, nodeId);
427 LOG.error("Failed to delete cross connect {} on node {}!", connectionId, nodeId);
429 failedInterfaces.add(connectionId);
432 // Interfaces needs to be in specific order to delete. Order is:
437 LinkedList<String> interfacesToDelete = new LinkedList<>();
438 if (nodeInterfaces.getOduInterfaceId() != null) {
439 interfacesToDelete.addAll(nodeInterfaces.getOduInterfaceId());
441 if (nodeInterfaces.getOtuInterfaceId() != null) {
442 interfacesToDelete.addAll(nodeInterfaces.getOtuInterfaceId());
444 if (nodeInterfaces.getOchInterfaceId() != null) {
445 interfacesToDelete.addAll(nodeInterfaces.getOchInterfaceId());
447 if (nodeInterfaces.getEthInterfaceId() != null) {
448 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
450 LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
451 String.join(", ", interfacesToDelete));
452 for (String interfaceId : interfacesToDelete) {
454 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
455 LOG.info("Interface {} on node {} successfully deleted.", interfaceId, nodeId);
456 } catch (OpenRoadmInterfaceException e) {
457 LOG.error("Failed to delete interface {} on node {}!", interfaceId, nodeId);
459 failedInterfaces.add(interfaceId);
462 FailedToRollback failedToRollack = new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
463 .setNodeId(nodeId).setInterface(failedInterfaces).build();
464 failedToRollbackList.put(failedToRollack.key(),failedToRollack);
466 return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
470 private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
471 NodelistBuilder nodeListBuilder = new NodelistBuilder()
472 .withKey(new NodelistKey(input.getServiceName()))
473 .setServiceName(input.getServiceName());
474 Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
475 .nodelist.nodelist.NodesKey,
476 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
477 .nodelist.nodelist.Nodes> nodeList =
479 if (input.getNodes() != null) {
480 for (Nodes node : input.getNodes()) {
481 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
482 .service.nodelist.nodelist.Nodes nodes =
483 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
484 .service.nodelist.nodelist.NodesBuilder().setNodeId(node.getNodeId()).build();
485 nodeList.put(nodes.key(),nodes);
488 nodeListBuilder.setNodes(nodeList);
489 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
490 .service.nodelist.Nodelist> nodeListIID =
491 InstanceIdentifier.create(ServiceNodelist.class)
492 .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
493 .service.nodelist.Nodelist.class, new NodelistKey(input.getServiceName()));
494 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
495 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
496 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
498 commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
499 LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
501 } catch (ExecutionException | InterruptedException | TimeoutException e) {
502 LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e);
507 private boolean alarmSuppressionNodeRemoval(String serviceName) {
508 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
509 .service.nodelist.Nodelist> nodeListIID =
510 InstanceIdentifier.create(ServiceNodelist.class)
511 .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
512 .service.nodelist.Nodelist.class, new NodelistKey(serviceName));
513 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
514 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
515 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
517 commit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
518 LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
520 } catch (InterruptedException | TimeoutException | ExecutionException e) {
521 LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e);
526 private void setTopologyForService(String name, Topology topo)
527 throws InterruptedException, ExecutionException, TimeoutException {
528 ServicesBuilder servicesBuilder;
529 // Get the service from the service list inventory
530 ServicesKey serviceKey = new ServicesKey(name);
531 InstanceIdentifier<Services> iid =
532 InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
533 Optional<Services> services;
534 try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
535 Future<java.util.Optional<Services>> future =
536 readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
537 services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
538 } catch (InterruptedException | ExecutionException | TimeoutException e) {
541 if (services.isPresent()) {
542 LOG.info("service {} already exists", name);
543 servicesBuilder = new ServicesBuilder(services.get()).setTopology(topo);
544 WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
545 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
546 writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
548 LOG.warn("Service {} does not exist - topology can not be updated", name);
553 public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
554 CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
556 Boolean success = false;
557 // if the node is currently mounted then proceed.
558 if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
559 Mapping oldMapping = null;
560 Mapping newMapping = null;
561 oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
562 if (oldMapping != null) {
563 String otsInterface =
564 this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
565 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
567 Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
568 while (!isSupportingOtsPresent && (count < 6)) {
569 LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
572 this.portMapping.updateMapping(input.getNodeId(), oldMapping);
573 } catch (InterruptedException e) {
574 LOG.error("Failed to wait for post interface operation ");
576 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
577 isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
581 String omsInterface =
582 this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
583 if (omsInterface != null) {
584 result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
588 LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
589 result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
592 LOG.error("Unable to get ots interface from mapping {} for node {}",
593 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
594 result = String.format("Unable to get ots interface from mapping %s - %s",
595 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
598 result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
602 result = input.getNodeId() + IS_NOT_MOUNTED_ON_THE_CONTROLLER;
603 LOG.warn("{} is not mounted on the controller",input.getNodeId());
605 return output.setResult(result).setSuccess(success).build();
608 private Boolean isSupportingOtsPresent(Mapping mapping) {
609 Boolean result = false;
610 if (mapping != null) {
611 if (mapping.getSupportingOts() != null) {
612 LOG.info("SupportingOts info is present in mapping {}", mapping);
615 LOG.warn("SupportingOts info not present in mapping {}", mapping);
621 private void updateOtnTopology(CopyOnWriteArrayList<Nodes> nodes, boolean isDeletion) {
622 if (nodes.size() != 2) {
623 LOG.error("Error with OTU4 links to update in otn-topology");
627 LOG.info("updating otn-topology removing OTU4 links");
628 this.networkModelService.deleteOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
629 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);
631 LOG.info("updating otn-topology adding OTU4 links");
632 this.networkModelService.createOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
633 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);