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.tasks;
10 import java.util.concurrent.Future;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInput;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownInputBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutput;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class OlmPowerSetupRollbackTask extends RollbackTask {
22 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerSetupRollbackTask.class);
23 private static final String FAILED = "Failed";
24 private final boolean isRollbackNecessary;
25 private final OlmService olmService;
26 private final ServicePowerSetupInput powerSetupInput;
28 public OlmPowerSetupRollbackTask(String id, boolean isRollbackNecessary, OlmService olmService,
29 ServicePowerSetupInput powerSetupInput) {
31 this.isRollbackNecessary = isRollbackNecessary;
32 this.olmService = olmService;
33 this.powerSetupInput = powerSetupInput;
37 public boolean isRollbackNecessary() {
38 return isRollbackNecessary;
42 public Void call() throws Exception {
43 ServicePowerTurndownInput powerTurndownInput = new ServicePowerTurndownInputBuilder()
44 .setNodes(this.powerSetupInput.getNodes())
45 .setServiceName(this.powerSetupInput.getServiceName())
46 .setWaveNumber(this.powerSetupInput.getWaveNumber())
49 Future<RpcResult<ServicePowerTurndownOutput>> powerTurndownResultFuture =
50 this.olmService.servicePowerTurndown(powerTurndownInput);
51 RpcResult<ServicePowerTurndownOutput> powerTurndownResult = powerTurndownResultFuture.get();
52 if (FAILED.equals(powerTurndownResult.getResult().getResult())) {
53 LOG.warn("Olmp power setup rollback for {} was not successful!", this.getId());
55 LOG.info("Olm power setup rollback for {} was successful.");