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
9 package org.opendaylight.transportpce.renderer.rpcs;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
13 import org.opendaylight.transportpce.common.service.ServiceTypes;
14 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
15 import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsInput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOmsOutput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutputBuilder;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackInput;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollbackOutput;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathInput;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutputBuilder;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.TransportpceDeviceRendererService;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
28 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class DeviceRendererRPCImpl implements TransportpceDeviceRendererService {
34 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class);
35 private DeviceRendererService deviceRenderer;
36 private OtnDeviceRendererService otnDeviceRendererService;
38 public DeviceRendererRPCImpl(DeviceRendererService deviceRenderer,
39 OtnDeviceRendererService otnDeviceRendererService) {
40 this.deviceRenderer = deviceRenderer;
41 this.otnDeviceRendererService = otnDeviceRendererService;
45 * This method is the implementation of the 'service-path' RESTCONF service,
46 * which is one of the external APIs into the renderer application. The
47 * service provides two functions:
50 * 1. Create This operation results in provisioning the device for a given
51 * wavelength and a list of nodes with each node listing its termination
55 * 2. Delete This operation results in de-provisioning the device for a
56 * given wavelength and a list of nodes with each node listing its
60 * The signature for this method was generated by yang tools from the
64 * Input parameter from the service-path yang model
66 * @return Result of the request
69 public ListenableFuture<RpcResult<ServicePathOutput>> servicePath(ServicePathInput input) {
70 if (input.getOperation() != null) {
71 if (input.getOperation().getIntValue() == 1) {
72 LOG.info("Create operation request received");
73 return RpcResultBuilder.success(
74 this.deviceRenderer.setupServicePath(input, null))
76 } else if (input.getOperation().getIntValue() == 2) {
77 LOG.info("Delete operation request received");
78 return RpcResultBuilder
79 .success(this.deviceRenderer.deleteServicePath(input))
83 return RpcResultBuilder
84 .success(new ServicePathOutputBuilder().setResult("Invalid operation").build())
89 public ListenableFuture<RpcResult<OtnServicePathOutput>> otnServicePath(OtnServicePathInput input) {
90 if (input.getOperation() != null && input.getServiceFormat() != null && input.getServiceRate() != null) {
91 String serviceType = ServiceTypes.getOtnServiceType(input.getServiceFormat(), input.getServiceRate());
92 if (input.getOperation().getIntValue() == 1) {
93 LOG.info("Create operation request received");
94 return RpcResultBuilder.success(this.otnDeviceRendererService
95 .setupOtnServicePath(input, serviceType)).buildFuture();
96 } else if (input.getOperation().getIntValue() == 2) {
97 LOG.info("Delete operation request received");
98 return RpcResultBuilder.success(this.otnDeviceRendererService
99 .deleteOtnServicePath(input, serviceType)).buildFuture();
102 return RpcResultBuilder
103 .success(new OtnServicePathOutputBuilder().setResult("Invalid operation").build())
108 * Rollback created interfaces and cross connects specified by input.
111 * Lists of created interfaces and connections per node
112 * @return Success flag and nodes which failed to rollback
115 public ListenableFuture<RpcResult<RendererRollbackOutput>> rendererRollback(RendererRollbackInput input) {
116 return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture();
120 public ListenableFuture<RpcResult<CreateOtsOmsOutput>> createOtsOms(CreateOtsOmsInput input) {
121 LOG.info("Request received to create oms and ots interfaces on {}: {}", input.getNodeId(), input
122 .getLogicalConnectionPoint());
124 return RpcResultBuilder.success(deviceRenderer.createOtsOms(input)).buildFuture();
125 } catch (OpenRoadmInterfaceException e) {
126 LOG.error("failed to send request to create oms and ots interfaces on {}: {}", input.getNodeId(),
127 input.getLogicalConnectionPoint(),e);