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.math.BigDecimal;
13 import java.util.ArrayList;
14 import java.util.HashMap;
15 import java.util.LinkedList;
16 import java.util.List;
18 import java.util.Optional;
20 import java.util.concurrent.ConcurrentHashMap;
21 import java.util.concurrent.ConcurrentLinkedQueue;
22 import java.util.concurrent.CopyOnWriteArrayList;
23 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.ForkJoinPool;
25 import java.util.concurrent.ForkJoinTask;
26 import java.util.concurrent.Future;
27 import java.util.concurrent.TimeUnit;
28 import java.util.concurrent.TimeoutException;
29 import java.util.concurrent.atomic.AtomicBoolean;
30 import org.eclipse.jdt.annotation.NonNull;
31 import org.opendaylight.mdsal.binding.api.DataBroker;
32 import org.opendaylight.mdsal.binding.api.ReadTransaction;
33 import org.opendaylight.mdsal.binding.api.WriteTransaction;
34 import org.opendaylight.mdsal.common.api.CommitInfo;
35 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
36 import org.opendaylight.transportpce.common.StringConstants;
37 import org.opendaylight.transportpce.common.Timeouts;
38 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
39 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
40 import org.opendaylight.transportpce.common.mapping.PortMapping;
41 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
42 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
43 import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
44 import org.opendaylight.transportpce.renderer.openroadminterface.OpenRoadmInterfaceFactory;
45 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServiceListTopology;
46 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
47 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.ServiceNodelist;
48 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service.nodelist.NodelistKey;
50 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200827.network.nodes.Mapping;
51 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsInput;
52 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsOutput;
53 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsOutputBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackInput;
55 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackOutput;
56 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackOutputBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathInput;
58 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutput;
59 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutputBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollback;
61 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollbackBuilder;
62 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.renderer.rollback.output.FailedToRollbackKey;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.Topology;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceList;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesBuilder;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.ServicesKey;
69 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterface;
70 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.node.interfaces.NodeInterfaceKey;
72 import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev200615.olm.renderer.input.Nodes;
73 import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType;
74 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
79 public class DeviceRendererServiceImpl implements DeviceRendererService {
80 private static final String ODU4 = "-ODU4";
81 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererServiceImpl.class);
82 private final DataBroker dataBroker;
83 private final DeviceTransactionManager deviceTransactionManager;
84 private final OpenRoadmInterfaceFactory openRoadmInterfaceFactory;
85 private final OpenRoadmInterfaces openRoadmInterfaces;
86 private final CrossConnect crossConnect;
87 private final PortMapping portMapping;
88 private final NetworkModelService networkModelService;
90 public DeviceRendererServiceImpl(DataBroker dataBroker, DeviceTransactionManager deviceTransactionManager,
91 OpenRoadmInterfaceFactory openRoadmInterfaceFactory, OpenRoadmInterfaces openRoadmInterfaces,
92 CrossConnect crossConnect, PortMapping portMapping, NetworkModelService networkModelService) {
93 this.dataBroker = dataBroker;
94 this.deviceTransactionManager = deviceTransactionManager;
95 this.openRoadmInterfaceFactory = openRoadmInterfaceFactory;
96 this.openRoadmInterfaces = openRoadmInterfaces;
97 this.crossConnect = crossConnect;
98 this.portMapping = portMapping;
99 this.networkModelService = networkModelService;
103 public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
104 List<Nodes> nodes = new ArrayList<>();
105 if (input.getNodes() != null) {
106 nodes.addAll(input.getNodes());
108 // Register node for suppressing alarms
109 if (!alarmSuppressionNodeRegistration(input)) {
110 LOG.warn("Alarm suppresion node registration failed!!!!");
112 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
113 Map<NodeInterfaceKey,NodeInterface> nodeInterfaces = new ConcurrentHashMap<>();
114 Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
115 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
116 ServiceListTopology topology = new ServiceListTopology();
117 AtomicBoolean success = new AtomicBoolean(true);
118 ForkJoinPool forkJoinPool = new ForkJoinPool();
119 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
120 String nodeId = node.getNodeId();
121 // take the index of the node
122 int nodeIndex = nodes.indexOf(node);
123 LOG.info("Starting provisioning for node : {}", nodeId);
124 List<String> createdEthInterfaces = new ArrayList<>();
125 List<String> createdOtuInterfaces = new ArrayList<>();
126 List<String> createdOduInterfaces = new ArrayList<>();
127 List<String> createdOchInterfaces = new ArrayList<>();
128 List<String> createdConnections = new ArrayList<>();
129 int crossConnectFlag = 0;
131 // if the node is currently mounted then proceed
132 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
133 // TODO: In the case of flex-grid, the wave-number becomes bitmap index
134 // TODO: need to update transportpce-common-types accordingly, to a more, generic-term
135 Long waveNumber = input.getWaveNumber().toJava();
136 BigDecimal centerFreq = null;
137 BigDecimal slotWidth = null;
138 if (input.getCenterFreq() != null) {
139 centerFreq = input.getCenterFreq().getValue();
141 if (input.getSlotWidth() != null) {
142 slotWidth = input.getSlotWidth().getValue();
144 String srcTp = node.getSrcTp();
145 String destTp = node.getDestTp();
146 if ((destTp != null) && destTp.contains(StringConstants.NETWORK_TOKEN)) {
148 String supportingOchInterface;
149 if ((centerFreq != null) && (slotWidth != null)) {
150 supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
151 nodeId, destTp, waveNumber, ModulationFormat.DpQpsk, centerFreq, slotWidth);
154 supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
155 nodeId, destTp, waveNumber, ModulationFormat.DpQpsk);
157 createdOchInterfaces.add(supportingOchInterface);
158 // Here we pass logical connection-point of z-end to set SAPI and DAPI
159 Nodes tgtNode = null;
160 if (nodeIndex + 1 == nodes.size()) {
161 // For the end node, tgtNode becomes the first node in the list
162 tgtNode = nodes.get(0);
164 tgtNode = nodes.get(nodeIndex + 1);
166 // tgtNode srcTp is null in this if cond
167 String supportingOtuInterface = this.openRoadmInterfaceFactory
168 .createOpenRoadmOtu4Interface(nodeId, destTp, supportingOchInterface,
169 tgtNode.getNodeId(), tgtNode.getDestTp());
170 createdOtuInterfaces.add(supportingOtuInterface);
172 otnNodesProvisioned.add(node);
174 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
175 destTp, supportingOtuInterface));
178 if ((srcTp != null) && srcTp.contains(StringConstants.CLIENT_TOKEN)) {
180 // create OpenRoadm Xponder Client Interfaces
181 createdEthInterfaces.add(
182 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, srcTp));
184 if ((srcTp != null) && srcTp.contains(StringConstants.NETWORK_TOKEN)) {
186 // create OpenRoadm Xponder Line Interfaces
187 String supportingOchInterface;
188 if ((centerFreq != null) && (slotWidth != null)) {
189 supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
190 nodeId, srcTp, waveNumber, ModulationFormat.DpQpsk, centerFreq, slotWidth);
193 supportingOchInterface = this.openRoadmInterfaceFactory.createOpenRoadmOchInterface(
194 nodeId, srcTp, waveNumber, ModulationFormat.DpQpsk);
196 createdOchInterfaces.add(supportingOchInterface);
197 String supportingOtuInterface = this.openRoadmInterfaceFactory
198 .createOpenRoadmOtu4Interface(nodeId, srcTp, supportingOchInterface);
199 createdOtuInterfaces.add(supportingOtuInterface);
200 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
201 srcTp, supportingOtuInterface));
202 Mapping mapping = this.portMapping.getMapping(nodeId,srcTp);
203 if (mapping != null && mapping.getXponderType() != null
204 && (mapping.getXponderType().getIntValue() == 3
205 || mapping.getXponderType().getIntValue() == 2)) {
206 createdOduInterfaces.add(this.openRoadmInterfaceFactory
207 .createOpenRoadmOtnOdu4Interface(nodeId, destTp, supportingOtuInterface));
209 createdOduInterfaces.add(this.openRoadmInterfaceFactory.createOpenRoadmOdu4Interface(nodeId,
210 destTp, supportingOtuInterface));
213 if ((destTp != null) && destTp.contains(StringConstants.CLIENT_TOKEN)) {
215 // create OpenRoadm Xponder Client Interfaces
216 createdEthInterfaces.add(
217 this.openRoadmInterfaceFactory.createOpenRoadmEthInterface(nodeId, destTp));
219 if ((srcTp != null) && (srcTp.contains(StringConstants.TTP_TOKEN)
220 || srcTp.contains(StringConstants.PP_TOKEN))) {
221 if ((centerFreq != null) && (slotWidth != null)) {
222 createdOchInterfaces.addAll(
223 this.openRoadmInterfaceFactory
224 .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber, centerFreq, slotWidth));
227 createdOchInterfaces.addAll(
228 this.openRoadmInterfaceFactory
229 .createOpenRoadmOchInterface(nodeId, srcTp, waveNumber));
232 if ((destTp != null) && (destTp.contains(StringConstants.TTP_TOKEN)
233 || destTp.contains(StringConstants.PP_TOKEN))) {
235 if ((centerFreq != null) && (slotWidth != null)) {
236 createdOchInterfaces.addAll(
237 this.openRoadmInterfaceFactory
238 .createOpenRoadmOchInterface(nodeId, destTp, waveNumber, centerFreq, slotWidth));
241 createdOchInterfaces.addAll(
242 this.openRoadmInterfaceFactory
243 .createOpenRoadmOchInterface(nodeId, destTp, waveNumber));
247 if (crossConnectFlag < 1) {
248 LOG.info("Creating cross connect between source {} and destination {} for node {}", srcTp,
250 Optional<String> connectionNameOpt =
251 this.crossConnect.postCrossConnect(nodeId, waveNumber, srcTp, destTp);
252 if (connectionNameOpt.isPresent()) {
253 nodesProvisioned.add(nodeId);
254 createdConnections.add(connectionNameOpt.get());
256 processErrorMessage("Unable to post Roadm-connection for node " + nodeId, forkJoinPool,
262 processErrorMessage(nodeId + " is not mounted on the controller", forkJoinPool, results);
265 } catch (OpenRoadmInterfaceException ex) {
266 processErrorMessage("Setup service path failed! Exception:" + ex.toString(), forkJoinPool, results);
269 NodeInterfaceBuilder nodeInterfaceBuilder = new NodeInterfaceBuilder()
270 .withKey(new NodeInterfaceKey(nodeId))
272 .setConnectionId(createdConnections)
273 .setEthInterfaceId(createdEthInterfaces)
274 .setOtuInterfaceId(createdOtuInterfaces)
275 .setOduInterfaceId(createdOduInterfaces)
276 .setOchInterfaceId(createdOchInterfaces);
277 NodeInterface nodeInterface = nodeInterfaceBuilder.build();
278 nodeInterfaces.put(nodeInterface.key(),nodeInterface);
282 } catch (InterruptedException | ExecutionException e) {
283 LOG.error("Error while setting up service paths!", e);
285 forkJoinPool.shutdown();
288 results.add("Roadm-connection successfully created for nodes: " + String.join(", ", nodesProvisioned));
290 // setting topology in the service list data store
292 setTopologyForService(input.getServiceName(), topology.getTopology());
293 updateOtnTopology(otnNodesProvisioned, false);
294 } catch (InterruptedException | TimeoutException | ExecutionException e) {
295 LOG.warn("Failed to write topologies for service {}.", input.getServiceName(), e);
297 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
298 LOG.error("Alarm suppresion node removal failed!!!!");
300 ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
301 .setNodeInterface(nodeInterfaces)
302 .setSuccess(success.get())
303 .setResult(String.join("\n", results));
304 return setServBldr.build();
307 private ConcurrentLinkedQueue<String> processErrorMessage(String message, ForkJoinPool forkJoinPool,
308 ConcurrentLinkedQueue<String> messages) {
309 LOG.warn("Received error message {}", message);
310 messages.add(message);
311 forkJoinPool.shutdown();
316 public ServicePathOutput deleteServicePath(ServicePathInput input) {
317 List<Nodes> nodes = input.getNodes();
318 AtomicBoolean success = new AtomicBoolean(true);
319 ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
320 if (!alarmSuppressionNodeRegistration(input)) {
321 LOG.warn("Alarm suppresion node registraion failed!!!!");
323 CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
324 ForkJoinPool forkJoinPool = new ForkJoinPool();
325 ForkJoinTask forkJoinTask = forkJoinPool.submit(() -> nodes.parallelStream().forEach(node -> {
326 List<String> interfacesToDelete = new LinkedList<>();
327 String nodeId = node.getNodeId();
328 LOG.info("Deleting service setup on node {}", nodeId);
331 Long waveNumber = input.getWaveNumber().toJava();
332 if (node.getDestTp() == null) {
333 LOG.error("Destination termination point must not be null.");
336 destTp = node.getDestTp();
338 if (node.getSrcTp() != null) {
339 srcTp = node.getSrcTp();
342 otnNodesProvisioned.add(node);
344 // if the node is currently mounted then proceed.
345 if (this.deviceTransactionManager.isDeviceMounted(nodeId)) {
346 interfacesToDelete.addAll(getInterfaces2delete(nodeId, srcTp, destTp, waveNumber));
348 String result = nodeId + " is not mounted on the controller";
352 forkJoinPool.shutdown();
354 //TODO should deletion end here?
356 for (String interfaceId : interfacesToDelete) {
358 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
359 } catch (OpenRoadmInterfaceException e) {
360 String result = String.format("Failed to delete interface %s on node %s!", interfaceId, nodeId);
362 LOG.error(result, e);
369 } catch (InterruptedException | ExecutionException e) {
370 LOG.error("Error while deleting service paths!", e);
372 forkJoinPool.shutdown();
373 updateOtnTopology(otnNodesProvisioned, true);
374 if (!alarmSuppressionNodeRemoval(input.getServiceName())) {
375 LOG.error("Alarm suppresion node removal failed!!!!");
377 ServicePathOutputBuilder delServBldr = new ServicePathOutputBuilder();
378 delServBldr.setSuccess(success.get());
379 if (results.isEmpty()) {
380 return delServBldr.setResult("Request processed").build();
382 return delServBldr.setResult(String.join("\n", results)).build();
386 private List<String> getInterfaces2delete(
387 String nodeId, String srcTp, String destTp, Long waveNumber) {
388 List<String> interfacesToDelete = new LinkedList<>();
389 if (destTp.contains(StringConstants.NETWORK_TOKEN)
390 || srcTp.contains(StringConstants.CLIENT_TOKEN)
391 || srcTp.contains(StringConstants.NETWORK_TOKEN)
392 || destTp.contains(StringConstants.CLIENT_TOKEN)) {
393 if (destTp.contains(StringConstants.NETWORK_TOKEN)) {
395 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + "-ODU").isPresent()) {
396 interfacesToDelete.add(destTp + "-ODU");
398 if (this.openRoadmInterfaces.getInterface(nodeId, destTp + ODU4).isPresent()) {
399 interfacesToDelete.add(destTp + ODU4);
402 catch (OpenRoadmInterfaceException e) {
403 LOG.error("impossible to get interface {} or {}", destTp + "-ODU", destTp + ODU4, e);
405 interfacesToDelete.add(destTp + "-OTU");
406 interfacesToDelete.add(
407 this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(destTp, waveNumber));
409 if (srcTp.contains(StringConstants.NETWORK_TOKEN)) {
410 interfacesToDelete.add(srcTp + "-ODU");
411 interfacesToDelete.add(srcTp + "-OTU");
413 .add(this.openRoadmInterfaceFactory.createOpenRoadmOchInterfaceName(srcTp, waveNumber));
415 if (srcTp.contains(StringConstants.CLIENT_TOKEN)) {
416 interfacesToDelete.add(srcTp + "-ETHERNET");
418 if (destTp.contains(StringConstants.CLIENT_TOKEN)) {
419 interfacesToDelete.add(destTp + "-ETHERNET");
422 String connectionNumber = srcTp + "-" + destTp + "-" + waveNumber;
423 List<String> intToDelete = this.crossConnect.deleteCrossConnect(nodeId, connectionNumber, false);
424 connectionNumber = destTp + "-" + srcTp + "-" + waveNumber;
425 if (intToDelete != null) {
426 for (String interf : intToDelete) {
427 if (!this.openRoadmInterfaceFactory.isUsedByXc(nodeId, interf, connectionNumber,
428 this.deviceTransactionManager)) {
429 interfacesToDelete.add(interf);
434 return interfacesToDelete;
438 public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
439 boolean success = true;
440 Map<FailedToRollbackKey,FailedToRollback> failedToRollbackList = new HashMap<>();
441 for (NodeInterface nodeInterfaces : input.nonnullNodeInterface().values()) {
442 List<String> failedInterfaces = new ArrayList<>();
443 String nodeId = nodeInterfaces.getNodeId();
444 for (String connectionId : nodeInterfaces.getConnectionId()) {
445 List<String> listInter = this.crossConnect.deleteCrossConnect(nodeId, connectionId, false);
446 if (listInter != null) {
447 LOG.info("Cross connect {} on node {} successfully deleted.", connectionId, nodeId);
449 LOG.error("Failed to delete cross connect {} on node {}!", connectionId, nodeId);
451 failedInterfaces.add(connectionId);
454 // Interfaces needs to be in specific order to delete. Order is:
459 LinkedList<String> interfacesToDelete = new LinkedList<>();
460 if (nodeInterfaces.getOduInterfaceId() != null) {
461 interfacesToDelete.addAll(nodeInterfaces.getOduInterfaceId());
463 if (nodeInterfaces.getOtuInterfaceId() != null) {
464 interfacesToDelete.addAll(nodeInterfaces.getOtuInterfaceId());
466 if (nodeInterfaces.getOchInterfaceId() != null) {
467 interfacesToDelete.addAll(nodeInterfaces.getOchInterfaceId());
469 if (nodeInterfaces.getEthInterfaceId() != null) {
470 interfacesToDelete.addAll(nodeInterfaces.getEthInterfaceId());
472 LOG.info("Going to execute rollback on node {}. Interfaces to rollback: {}", nodeId,
473 String.join(", ", interfacesToDelete));
474 for (String interfaceId : interfacesToDelete) {
476 this.openRoadmInterfaces.deleteInterface(nodeId, interfaceId);
477 LOG.info("Interface {} on node {} successfully deleted.", interfaceId, nodeId);
478 } catch (OpenRoadmInterfaceException e) {
479 LOG.error("Failed to delete interface {} on node {}!", interfaceId, nodeId);
481 failedInterfaces.add(interfaceId);
484 FailedToRollback failedToRollack = new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
485 .setNodeId(nodeId).setInterface(failedInterfaces).build();
486 failedToRollbackList.put(failedToRollack.key(),failedToRollack);
488 return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
492 private boolean alarmSuppressionNodeRegistration(ServicePathInput input) {
493 NodelistBuilder nodeListBuilder = new NodelistBuilder()
494 .withKey(new NodelistKey(input.getServiceName()))
495 .setServiceName(input.getServiceName());
496 Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
497 .nodelist.nodelist.NodesKey,
498 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
499 .nodelist.nodelist.Nodes> nodeList =
501 if (input.getNodes() != null) {
502 for (Nodes node : input.getNodes()) {
503 org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
504 .service.nodelist.nodelist.Nodes nodes =
505 new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
506 .service.nodelist.nodelist.NodesBuilder().setNodeId(node.getNodeId()).build();
507 nodeList.put(nodes.key(),nodes);
510 nodeListBuilder.setNodes(nodeList);
511 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
512 .service.nodelist.Nodelist> nodeListIID =
513 InstanceIdentifier.create(ServiceNodelist.class)
514 .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
515 .service.nodelist.Nodelist.class, new NodelistKey(input.getServiceName()));
516 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
517 writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
518 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
520 commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
521 LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
523 } catch (ExecutionException | InterruptedException | TimeoutException e) {
524 LOG.warn("Failed to alarm suppresslist for service: {}", input.getServiceName(), e);
529 private boolean alarmSuppressionNodeRemoval(String serviceName) {
530 InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
531 .service.nodelist.Nodelist> nodeListIID =
532 InstanceIdentifier.create(ServiceNodelist.class)
533 .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
534 .service.nodelist.Nodelist.class, new NodelistKey(serviceName));
535 final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
536 writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
537 FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
539 commit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
540 LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
542 } catch (InterruptedException | TimeoutException | ExecutionException e) {
543 LOG.warn("Failed to alarm suppresslist for service: {}", serviceName, e);
548 private void setTopologyForService(String name, Topology topo)
549 throws InterruptedException, ExecutionException, TimeoutException {
550 ServicesBuilder servicesBuilder;
551 // Get the service from the service list inventory
552 ServicesKey serviceKey = new ServicesKey(name);
553 InstanceIdentifier<Services> iid =
554 InstanceIdentifier.create(ServiceList.class).child(Services.class, serviceKey);
555 Optional<Services> services;
556 try (ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction()) {
557 Future<java.util.Optional<Services>> future =
558 readTx.read(LogicalDatastoreType.OPERATIONAL, iid);
559 services = future.get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS);
560 } catch (InterruptedException | ExecutionException | TimeoutException e) {
563 if (services.isPresent()) {
564 LOG.info("service {} already exists", name);
565 servicesBuilder = new ServicesBuilder(services.get()).setTopology(topo);
566 WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
567 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
568 writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
570 LOG.warn("Service {} does not exist - topology can not be updated", name);
575 public CreateOtsOmsOutput createOtsOms(CreateOtsOmsInput input) throws OpenRoadmInterfaceException {
576 CreateOtsOmsOutputBuilder output = new CreateOtsOmsOutputBuilder();
578 Boolean success = false;
579 // if the node is currently mounted then proceed.
580 if (this.deviceTransactionManager.isDeviceMounted(input.getNodeId())) {
581 Mapping oldMapping = null;
582 Mapping newMapping = null;
583 oldMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
584 if (oldMapping != null) {
585 String otsInterface =
586 this.openRoadmInterfaceFactory.createOpenRoadmOtsInterface(input.getNodeId(), oldMapping);
587 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
589 Boolean isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
590 while (!isSupportingOtsPresent && (count < 6)) {
591 LOG.info("waiting for post interface operation on node '{}'...", input.getNodeId());
594 this.portMapping.updateMapping(input.getNodeId(), oldMapping);
595 } catch (InterruptedException e) {
596 LOG.error("Failed to wait for post interface operation ");
598 newMapping = this.portMapping.getMapping(input.getNodeId(), input.getLogicalConnectionPoint());
599 isSupportingOtsPresent = isSupportingOtsPresent(newMapping);
603 String omsInterface =
604 this.openRoadmInterfaceFactory.createOpenRoadmOmsInterface(input.getNodeId(), newMapping);
605 if (omsInterface != null) {
606 result = "Interfaces " + otsInterface + " - " + omsInterface + " successfully created on node "
610 LOG.error("Fail to create OpenRoadmOms Interface for node '{}'", input.getNodeId());
611 result = "Fail to create OpenRoadmOms Interface for node : " + input.getNodeId();
614 LOG.error("Unable to get ots interface from mapping {} for node {}",
615 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
616 result = String.format("Unable to get ots interface from mapping %s - %s",
617 oldMapping.getLogicalConnectionPoint(), input.getNodeId());
620 result = "Logical Connection point " + input.getLogicalConnectionPoint() + " does not exist for "
624 result = input.getNodeId() + " is not mounted on the controller";
625 LOG.warn("{} is not mounted on the controller",input.getNodeId());
627 return output.setResult(result).setSuccess(success).build();
630 private Boolean isSupportingOtsPresent(Mapping mapping) {
631 Boolean result = false;
632 if (mapping != null) {
633 if (mapping.getSupportingOts() != null) {
634 LOG.info("SupportingOts info is present in mapping {}", mapping);
637 LOG.warn("SupportingOts info not present in mapping {}", mapping);
643 private void updateOtnTopology(CopyOnWriteArrayList<Nodes> nodes, boolean isDeletion) {
644 if (nodes.size() != 2) {
645 LOG.error("Error with OTU4 links to update in otn-topology");
649 LOG.info("updating otn-topology removing OTU4 links");
650 this.networkModelService.deleteOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
651 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);
653 LOG.info("updating otn-topology adding OTU4 links");
654 this.networkModelService.createOtnLinks(nodes.get(0).getNodeId(), nodes.get(0).getDestTp(),
655 nodes.get(1).getNodeId(), nodes.get(1).getDestTp(), OtnLinkType.OTU4);