X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Frpcs%2FDeviceRendererRPCImpl.java;h=005a32a5aef0f6319bb6cad0e6028ade56ca01f9;hb=d9ef75efa4ff5164c84d1d1e62ac1d4a7e21ab6a;hp=78bd06c327224624176a42c089242752c26161b4;hpb=d9ffad0ed3e046a5ad890c65bb0e8c0a1e611002;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java index 78bd06c32..005a32a5a 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/rpcs/DeviceRendererRPCImpl.java @@ -8,125 +8,42 @@ package org.opendaylight.transportpce.renderer.rpcs; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException; -import org.opendaylight.transportpce.common.service.ServiceTypes; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService; import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.TransportpceDeviceRendererService; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.concepts.Registration; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DeviceRendererRPCImpl implements TransportpceDeviceRendererService { +@Component(immediate = true) +public class DeviceRendererRPCImpl { private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class); - private DeviceRendererService deviceRenderer; - private OtnDeviceRendererService otnDeviceRendererService; - - public DeviceRendererRPCImpl(DeviceRendererService deviceRenderer, - OtnDeviceRendererService otnDeviceRendererService) { - this.deviceRenderer = deviceRenderer; - this.otnDeviceRendererService = otnDeviceRendererService; - LOG.debug("DeviceRendererRPCImpl instantiated"); - } - - /** - * This method is the implementation of the 'service-path' RESTCONF service, - * which is one of the external APIs into the renderer application. The - * service provides two functions: - * - *

- * 1. Create This operation results in provisioning the device for a given - * wavelength and a list of nodes with each node listing its termination - * points. - * - *

- * 2. Delete This operation results in de-provisioning the device for a - * given wavelength and a list of nodes with each node listing its - * termination points. - * - *

- * The signature for this method was generated by yang tools from the - * renderer API model. - * - * @param input - * Input parameter from the service-path yang model - * - * @return Result of the request - */ - @Override - public ListenableFuture> servicePath(ServicePathInput input) { - if (input.getOperation() != null) { - if (input.getOperation().getIntValue() == 1) { - LOG.info("Create operation request received"); - return RpcResultBuilder.success( - this.deviceRenderer.setupServicePath(input, null)) - .buildFuture(); - } else if (input.getOperation().getIntValue() == 2) { - LOG.info("Delete operation request received"); - return RpcResultBuilder - .success(this.deviceRenderer.deleteServicePath(input)) - .buildFuture(); - } - } - return RpcResultBuilder - .success(new ServicePathOutputBuilder().setResult("Invalid operation").build()) - .buildFuture(); - } - - @Override - public ListenableFuture> otnServicePath(OtnServicePathInput input) { - if (input.getOperation() != null && input.getServiceFormat() != null && input.getServiceRate() != null) { - String serviceType = ServiceTypes.getOtnServiceType(input.getServiceFormat(), input.getServiceRate()); - if (input.getOperation().getIntValue() == 1) { - LOG.info("Create operation request received"); - return RpcResultBuilder.success(this.otnDeviceRendererService - .setupOtnServicePath(input, serviceType)).buildFuture(); - } else if (input.getOperation().getIntValue() == 2) { - LOG.info("Delete operation request received"); - return RpcResultBuilder.success(this.otnDeviceRendererService - .deleteOtnServicePath(input, serviceType)).buildFuture(); - } - } - return RpcResultBuilder - .success(new OtnServicePathOutputBuilder().setResult("Invalid operation").build()) - .buildFuture(); + private Registration reg; + + @Activate + public DeviceRendererRPCImpl(@Reference RpcProviderService rpcProviderService, + @Reference DeviceRendererService deviceRenderer, + @Reference OtnDeviceRendererService otnDeviceRendererService) { + this.reg = rpcProviderService.registerRpcImplementations( + new ServicePathImpl(deviceRenderer), + new OtnServicePathImpl(otnDeviceRendererService), + new RendererRollbackImpl(deviceRenderer), + new CreateOtsOmsImpl(deviceRenderer)); + LOG.debug("RPC of DeviceRendererRPCImpl instantiated"); } - /** - * Rollback created interfaces and cross connects specified by input. - * - * @param input - * Lists of created interfaces and connections per node - * @return Success flag and nodes which failed to rollback - */ - @Override - public ListenableFuture> rendererRollback(RendererRollbackInput input) { - return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture(); + @Deactivate + public void close() { + this.reg.close(); + LOG.info("DeviceRendererRPCImpl Closed"); } - @Override - public ListenableFuture> createOtsOms(CreateOtsOmsInput input) { - LOG.info("Request received to create oms and ots interfaces on {}: {}", input.getNodeId(), input - .getLogicalConnectionPoint()); - try { - return RpcResultBuilder.success(deviceRenderer.createOtsOms(input)).buildFuture(); - } catch (OpenRoadmInterfaceException e) { - LOG.error("failed to send request to create oms and ots interfaces on {}: {}", input.getNodeId(), - input.getLogicalConnectionPoint(),e); - } - return null; + public Registration getRegisteredRpc() { + return reg; } }