2 * Copyright © 2024 Smartoptics 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
9 package org.opendaylight.transportpce.renderer.provisiondevice.tasks;
11 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
12 import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 public class NetworkDeviceRenderingRollbackTask extends RollbackTask {
20 private final History transactionHistory;
22 private final boolean isRollbackNecessary;
24 private final DeviceRendererService deviceRendererService;
26 private final ResultMessage message;
28 private static final Logger LOG = LoggerFactory.getLogger(NetworkDeviceRenderingRollbackTask.class);
30 public NetworkDeviceRenderingRollbackTask(String id, History transactionHistory,
31 boolean isRollbackNecessary,
32 DeviceRendererService deviceRendererService, ResultMessage message) {
34 this.transactionHistory = transactionHistory;
35 this.isRollbackNecessary = isRollbackNecessary;
36 this.deviceRendererService = deviceRendererService;
37 this.message = message;
41 public boolean isRollbackNecessary() {
42 return isRollbackNecessary;
46 public Void call() throws Exception {
48 RendererRollbackOutput rollbackOutput = deviceRendererService.rendererRollback(transactionHistory);
50 if (! rollbackOutput.getSuccess()) {
51 LOG.warn("Device rendering rollback of {} was not successful! Failed rollback on {}.", this.getId(),
52 message.createErrorMessage(rollbackOutput.nonnullFailedToRollback().values()));
54 LOG.info("Device rollback of {} successful.", this.getId());