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 static java.util.Objects.requireNonNull;
12 import java.util.concurrent.Callable;
13 import java.util.concurrent.Future;
14 import org.opendaylight.transportpce.common.ResponseCodes;
15 import org.opendaylight.transportpce.renderer.provisiondevice.OLMRenderingResult;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetup;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class OlmPowerSetupTask implements Callable<OLMRenderingResult> {
25 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerSetupTask.class);
27 private final ServicePowerSetup servicePowerSetup;
28 private final ServicePowerSetupInput input;
30 public OlmPowerSetupTask(ServicePowerSetup servicePowerSetup, ServicePowerSetupInput input) {
31 this.servicePowerSetup = requireNonNull(servicePowerSetup);
36 public OLMRenderingResult call() throws Exception {
37 Future<RpcResult<ServicePowerSetupOutput>> fr = servicePowerSetup.invoke(this.input);
38 RpcResult<ServicePowerSetupOutput> result = fr.get();
40 LOG.warn("Result is NULL");
41 return OLMRenderingResult.failed("Operation Failed");
44 LOG.debug("Result: {}", result.getResult());
45 if (ResponseCodes.SUCCESS_RESULT.equals(result.getResult().getResult())) {
46 LOG.info("OLM power setup finished successfully");
47 return OLMRenderingResult.ok();
49 LOG.warn("OLM power setup not successfully finished");
50 return OLMRenderingResult.failed("Operation Failed");