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.rpcs;
10 import com.google.common.util.concurrent.ListenableFuture;
12 import java.util.concurrent.ExecutionException;
14 import org.opendaylight.transportpce.renderer.ModelMappingUtils;
15 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteInput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceDeleteOutput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestInput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceImplementationRequestOutput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.TransportpceRendererService;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class TransportPCEServicePathRPCImpl implements TransportpceRendererService {
27 private static final Logger LOG = LoggerFactory.getLogger(TransportPCEServicePathRPCImpl.class);
29 private final RendererServiceOperations rendererServiceOperations;
31 public TransportPCEServicePathRPCImpl(RendererServiceOperations rendererServiceOperations) {
32 this.rendererServiceOperations = rendererServiceOperations;
36 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
37 String serviceName = input.getServiceName();
38 LOG.info("Calling RPC service delete request {}", serviceName);
39 ServiceDeleteOutput output = null;
41 output = this.rendererServiceOperations.serviceDelete(input).get();
42 } catch (InterruptedException | ExecutionException e) {
43 LOG.error("RPC service delete failed !", e);
45 return ModelMappingUtils.createServiceDeleteRpcResponse(output);
49 public ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> serviceImplementationRequest(
50 ServiceImplementationRequestInput input) {
51 String serviceName = input.getServiceName();
52 LOG.info("Calling RPC service impl request {}", serviceName);
53 ServiceImplementationRequestOutput output = null;
55 output = this.rendererServiceOperations.serviceImplementation(input).get();
56 } catch (InterruptedException | ExecutionException e) {
57 LOG.error("RPC service implementation failed !", e);
59 return ModelMappingUtils.createServiceImplementationRpcResponse(output);