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.renderer.provisiondevice.DeviceRendererService;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsInput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.CreateOtsOmsOutput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathInput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathOutput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.OtnServicePathOutputBuilder;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackInput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.RendererRollbackOutput;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathInput;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutput;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.ServicePathOutputBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.device.rev200128.TransportpceDeviceRendererService;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
26 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class DeviceRendererRPCImpl implements TransportpceDeviceRendererService {
32 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class);
33 private DeviceRendererService deviceRenderer;
35 public DeviceRendererRPCImpl(DeviceRendererService deviceRenderer) {
36 this.deviceRenderer = deviceRenderer;
40 * This method is the implementation of the 'service-path' RESTCONF service,
41 * which is one of the external APIs into the renderer application. The
42 * service provides two functions:
45 * 1. Create This operation results in provisioning the device for a given
46 * wavelength and a list of nodes with each node listing its termination
50 * 2. Delete This operation results in de-provisioning the device for a
51 * given wavelength and a list of nodes with each node listing its
55 * The signature for this method was generated by yang tools from the
59 * Input parameter from the service-path yang model
61 * @return Result of the request
64 public ListenableFuture<RpcResult<ServicePathOutput>> servicePath(ServicePathInput input) {
65 if (input.getOperation().getIntValue() == 1) {
66 LOG.info("Create operation request received");
67 return RpcResultBuilder.success(this.deviceRenderer.setupServicePath(input, null)).buildFuture();
68 } else if (input.getOperation().getIntValue() == 2) {
69 LOG.info("Delete operation request received");
70 return RpcResultBuilder.success(this.deviceRenderer.deleteServicePath(input)).buildFuture();
72 return RpcResultBuilder.success(new ServicePathOutputBuilder().setResult("Invalid operation")).buildFuture();
76 public ListenableFuture<RpcResult<OtnServicePathOutput>> otnServicePath(OtnServicePathInput input) {
77 return RpcResultBuilder
78 .success(new OtnServicePathOutputBuilder().setResult("Unsupported operation"))
83 * Rollback created interfaces and cross connects specified by input.
86 * Lists of created interfaces and connections per node
87 * @return Success flag and nodes which failed to rollback
90 public ListenableFuture<RpcResult<RendererRollbackOutput>> rendererRollback(RendererRollbackInput input) {
91 return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture();
95 public ListenableFuture<RpcResult<CreateOtsOmsOutput>> createOtsOms(CreateOtsOmsInput input) {
96 LOG.info("Request received to create oms and ots interfaces on {}: {}", input.getNodeId(), input
97 .getLogicalConnectionPoint());
99 return RpcResultBuilder.success(deviceRenderer.createOtsOms(input)).buildFuture();
100 } catch (OpenRoadmInterfaceException e) {
101 LOG.error("failed to send request to create oms and ots interfaces on {}: {}", input.getNodeId(),
102 input.getLogicalConnectionPoint(),e);