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