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.rev210915.ServiceDeleteInput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestOutput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.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;
31 LOG.debug("TransportPCEServicePathRPCImpl instantiated");
35 public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
36 String serviceName = input.getServiceName();
37 LOG.info("Calling RPC service delete request {}", serviceName);
38 ServiceDeleteOutput output = null;
40 output = this.rendererServiceOperations.serviceDelete(input, null).get();
41 } catch (InterruptedException | ExecutionException e) {
42 LOG.error("RPC service delete failed !", e);
44 return ModelMappingUtils.createServiceDeleteRpcResponse(output);
48 public ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> serviceImplementationRequest(
49 ServiceImplementationRequestInput input) {
50 String serviceName = input.getServiceName();
51 LOG.info("Calling RPC service impl request {}", serviceName);
52 ServiceImplementationRequestOutput output = null;
54 output = this.rendererServiceOperations.serviceImplementation(input).get();
55 } catch (InterruptedException | ExecutionException e) {
56 LOG.error("RPC service implementation failed !", e);
58 return ModelMappingUtils.createServiceImplementationRpcResponse(output);