New version of yang transportpce-renderer
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / rpcs / TransportPCEServicePathRPCImpl.java
index be29295f063a09a4b24c2bc5c3fa643f46e13df0..feec26f2655972263f946f5105355954e4d2760a 100644 (file)
@@ -8,22 +8,19 @@
 package org.opendaylight.transportpce.renderer.rpcs;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.transportpce.renderer.ModelMappingUtils;
 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceDeleteOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.ServiceImplementationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceDeleteOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceImplementationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.ServiceImplementationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.TransportpceRendererService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TransportPCEServicePathRPCImpl implements TransportpceServicepathService {
+public class TransportPCEServicePathRPCImpl implements TransportpceRendererService {
 
     private static final Logger LOG = LoggerFactory.getLogger(TransportPCEServicePathRPCImpl.class);
 
@@ -33,30 +30,31 @@ public class TransportPCEServicePathRPCImpl implements TransportpceServicepathSe
         this.rendererServiceOperations = rendererServiceOperations;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<CancelResourceReserveOutput>> cancelResourceReserve(CancelResourceReserveInput input) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     @Override
     public ListenableFuture<RpcResult<ServiceDeleteOutput>> serviceDelete(ServiceDeleteInput input) {
-        // TODO Auto-generated method stub
-        return null;
+        String serviceName = input.getServiceName();
+        LOG.info("Calling RPC service delete request {}", serviceName);
+        ServiceDeleteOutput output = null;
+        try {
+            output = this.rendererServiceOperations.serviceDelete(input, null).get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("RPC service delete failed !", e);
+        }
+        return ModelMappingUtils.createServiceDeleteRpcResponse(output);
     }
 
     @Override
     public ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> serviceImplementationRequest(
             ServiceImplementationRequestInput input) {
         String serviceName = input.getServiceName();
-        LOG.info("Calling RPC service impl request {} {}", serviceName);
-        return ModelMappingUtils.createRpcResponse(this.rendererServiceOperations.serviceImplementation(input));
-    }
-
-    @Override
-    public ListenableFuture<RpcResult<PathComputationRequestOutput>> pathComputationRequest(PathComputationRequestInput input) {
-        // TODO Auto-generated method stub
-        return null;
+        LOG.info("Calling RPC service impl request {}", serviceName);
+        ServiceImplementationRequestOutput output = null;
+        try {
+            output = this.rendererServiceOperations.serviceImplementation(input).get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("RPC service implementation failed !", e);
+        }
+        return ModelMappingUtils.createServiceImplementationRpcResponse(output);
     }
 
 }