Merge "Fix bug when creating SRG termination points"
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / rpcs / TransportPCEServicePathRPCImpl.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.renderer.rpcs;
9
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;
22
23 public class TransportPCEServicePathRPCImpl implements TransportpceRendererService {
24
25     private static final Logger LOG = LoggerFactory.getLogger(TransportPCEServicePathRPCImpl.class);
26
27     private final RendererServiceOperations rendererServiceOperations;
28
29     public TransportPCEServicePathRPCImpl(RendererServiceOperations rendererServiceOperations) {
30         this.rendererServiceOperations = rendererServiceOperations;
31     }
32
33     @Override
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;
38         try {
39             output = this.rendererServiceOperations.serviceDelete(input, null).get();
40         } catch (InterruptedException | ExecutionException e) {
41             LOG.error("RPC service delete failed !", e);
42         }
43         return ModelMappingUtils.createServiceDeleteRpcResponse(output);
44     }
45
46     @Override
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;
52         try {
53             output = this.rendererServiceOperations.serviceImplementation(input).get();
54         } catch (InterruptedException | ExecutionException e) {
55             LOG.error("RPC service implementation failed !", e);
56         }
57         return ModelMappingUtils.createServiceImplementationRpcResponse(output);
58     }
59
60 }
61