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.renderer.provisiondevice.DeviceRendererService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererRollbackOutput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.ServicePathOutputBuilder;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class DeviceRendererRPCImpl implements RendererService {
26 private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class);
27 private DeviceRendererService deviceRenderer;
29 public DeviceRendererRPCImpl(DeviceRendererService deviceRenderer) {
30 this.deviceRenderer = deviceRenderer;
34 * This method is the implementation of the 'service-path' RESTCONF service,
35 * which is one of the external APIs into the renderer application. The
36 * service provides two functions:
39 * 1. Create This operation results in provisioning the device for a given
40 * wavelength and a list of nodes with each node listing its termination
44 * 2. Delete This operation results in de-provisioning the device for a
45 * given wavelength and a list of nodes with each node listing its
49 * The signature for this method was generated by yang tools from the
53 * Input parameter from the service-path yang model
55 * @return Result of the request
58 public ListenableFuture<RpcResult<ServicePathOutput>> servicePath(ServicePathInput input) {
59 if (input.getOperation().getIntValue() == 1) {
60 LOG.info("Create operation request received");
61 return RpcResultBuilder.success(this.deviceRenderer.setupServicePath(input, null)).buildFuture();
62 } else if (input.getOperation().getIntValue() == 2) {
63 LOG.info("Delete operation request received");
64 return RpcResultBuilder.success(this.deviceRenderer.deleteServicePath(input)).buildFuture();
66 return RpcResultBuilder.success(new ServicePathOutputBuilder().setResult("Invalid operation")).buildFuture();
70 * Rollback created interfaces and cross connects specified by input.
72 * @param input Lists of created interfaces and connections per node
73 * @return Success flag and nodes which failed to rollback
76 public ListenableFuture<RpcResult<RendererRollbackOutput>> rendererRollback(RendererRollbackInput input) {
77 return RpcResultBuilder.success(this.deviceRenderer.rendererRollback(input)).buildFuture();