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 java.util.concurrent.Callable;
12 import java.util.concurrent.Future;
13 import org.opendaylight.transportpce.common.ResponseCodes;
14 import org.opendaylight.transportpce.renderer.ServicePathInputData;
15 import org.opendaylight.transportpce.renderer.provisiondevice.OLMRenderingResult;
16 import org.opendaylight.transportpce.renderer.provisiondevice.notification.Notification;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInputBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService;
20 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
21 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes;
22 import org.opendaylight.yangtools.yang.common.RpcResult;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class OlmPowerTurnDownTask implements Callable<OLMRenderingResult> {
28 private final String serviceName;
30 private final String path;
32 private final TransportpceOlmService olmService;
34 private final ServicePathInputData servicePathInputData;
36 private final Notification notification;
38 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerTurnDownTask.class);
41 * Task used to power down OLM.
44 * Intended to be used for parallel execution.
46 public OlmPowerTurnDownTask(String serviceName,
48 TransportpceOlmService olmService,
49 ServicePathInputData servicePathInputData,
50 Notification notification) {
52 this.serviceName = serviceName;
54 this.olmService = olmService;
55 this.servicePathInputData = servicePathInputData;
56 this.notification = notification;
60 public OLMRenderingResult call() throws Exception {
62 LOG.debug("Turning down power on {} path for service {}", path, serviceName);
64 Future<RpcResult<ServicePowerTurndownOutput>> fr = this.olmService.servicePowerTurndown(
65 new ServicePowerTurndownInputBuilder(
66 servicePathInputData.getServicePathInput()
70 ServicePathNotificationTypes.ServiceDelete,
73 String.format("Turning down power on %s path for service %s", path, serviceName)
76 RpcResult<ServicePowerTurndownOutput> result = fr.get();
78 if (result == null || !ResponseCodes.SUCCESS_RESULT.equals(result.getResult().getResult())) {
80 ServicePathNotificationTypes.ServiceDelete,
83 String.format("Service power turn down failed on %s path for service %s", path, serviceName)
85 return OLMRenderingResult.failed(
86 String.format("Service power turn down failed on %s path for service %s", path, serviceName)
89 LOG.debug("OLM power turn down finished successfully on {} for service {}", path, serviceName);
90 return OLMRenderingResult.ok();