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