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;
42 LOG.debug("DeviceRendererRPCImpl instantiated");
46 * This method is the implementation of the 'service-path' RESTCONF service,
47 * which is one of the external APIs into the renderer application. The
48 * service provides two functions:
51 * 1. Create This operation results in provisioning the device for a given
52 * wavelength and a list of nodes with each node listing its termination
56 * 2. Delete This operation results in de-provisioning the device for a
57 * given wavelength and a list of nodes with each node listing its
61 * The signature for this method was generated by yang tools from the
65 * Input parameter from the service-path yang model
67 * @return Result of the request
70 public ListenableFuture<RpcResult<ServicePathOutput>> servicePath(ServicePathInput input) {
71 if (input.getOperation() != null) {
72 if (input.getOperation().getIntValue() == 1) {
73 LOG.info("Create operation request received");
74 return RpcResultBuilder.success(
75 this.deviceRenderer.setupServicePath(input, null))
77 } else if (input.getOperation().getIntValue() == 2) {
78 LOG.info("Delete operation request received");
79 return RpcResultBuilder
80 .success(this.deviceRenderer.deleteServicePath(input))
84 return RpcResultBuilder
85 .success(new ServicePathOutputBuilder().setResult("Invalid operation").build())
90 public ListenableFuture<RpcResult<OtnServicePathOutput>> otnServicePath(OtnServicePathInput input) {
91 if (input.getOperation() != null && input.getServiceFormat() != null && input.getServiceRate() != null) {
92 String serviceType = ServiceTypes.getOtnServiceType(input.getServiceFormat(), input.getServiceRate());
93 if (input.getOperation().getIntValue() == 1) {
94 LOG.info("Create operation request received");
95 return RpcResultBuilder.success(this.otnDeviceRendererService
96 .setupOtnServicePath(input, serviceType)).buildFuture();
97 } else if (input.getOperation().getIntValue() == 2) {
98 LOG.info("Delete operation request received");
99 return RpcResultBuilder.success(this.otnDeviceRendererService
100 .deleteOtnServicePath(input, serviceType)).buildFuture();
103 return RpcResultBuilder
104 .success(new OtnServicePathOutputBuilder().setResult("Invalid operation").build())
109 * Rollback created interfaces and cross connects specified by input.
112 * Lists of created interfaces and connections per node
113 * @return Success flag and nodes which failed to rollback
116 public ListenableFuture<RpcResult<RendererRollbackOutput>> rendererRollback(RendererRollbackInput input) {
117 return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture();
121 public ListenableFuture<RpcResult<CreateOtsOmsOutput>> createOtsOms(CreateOtsOmsInput input) {
122 LOG.info("Request received to create oms and ots interfaces on {}: {}", input.getNodeId(), input
123 .getLogicalConnectionPoint());
125 return RpcResultBuilder.success(deviceRenderer.createOtsOms(input)).buildFuture();
126 } catch (OpenRoadmInterfaceException e) {
127 LOG.error("failed to send request to create oms and ots interfaces on {}: {}", input.getNodeId(),
128 input.getLogicalConnectionPoint(),e);