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.olm;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.transportpce.olm.service.OlmPowerService;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseInput;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBaseOutput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrentOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetInput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerResetOutput;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupOutput;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInput;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService;
26 import org.opendaylight.yangtools.yang.common.ErrorType;
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;
33 * The Class OlmPowerServiceRpcImpl.
35 public class OlmPowerServiceRpcImpl implements TransportpceOlmService {
36 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceRpcImpl.class);
37 private final OlmPowerService olmPowerService;
39 public OlmPowerServiceRpcImpl(OlmPowerService olmPowerService) {
40 this.olmPowerService = olmPowerService;
44 * This method is the implementation of the 'get-pm' RESTCONF service, which
45 * is one of the external APIs into the olm application.
48 * 1. get-pm This operation traverse through current PM list and gets PM for
49 * given NodeId and Resource name
52 * The signature for this method was generated by yang tools from the
56 * Input parameter from the olm yang model
58 * @return Result of the request
61 public ListenableFuture<RpcResult<GetPmOutput>> getPm(GetPmInput input) {
62 if (this.olmPowerService.getPm(input).getNodeId() == null) {
63 LOG.error("getPm: Error with input parameters");
64 return RpcResultBuilder.<GetPmOutput>failed()
65 .withError(ErrorType.RPC, "Error with input parameters")
68 return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture();
72 * This method is the implementation of the 'service-power-setup' RESTCONF service, which
73 * is one of the external APIs into the olm application.
76 * 1. service-power-setup: This operation performs following steps:
77 * Step1: Calculate Spanloss on all links which are part of service.
78 * TODO Step2: Calculate power levels for each Tp-Id
79 * TODO Step3: Post power values on roadm connections
82 * The signature for this method was generated by yang tools from the
86 * Input parameter from the olm yang model
87 * Input will contain nodeId and termination point
89 * @return Result of the request
92 public ListenableFuture<RpcResult<ServicePowerSetupOutput>> servicePowerSetup(
93 ServicePowerSetupInput input) {
94 return RpcResultBuilder.success(this.olmPowerService.servicePowerSetup(input)).buildFuture();
98 * This method is the implementation of the 'service-power-trundown' RESTCONF service, which
99 * is one of the external APIs into the olm application.
102 * 1. service-power-turndown: This operation performs following steps:
103 * Step1: For each TP within Node sets interface outofservice .
104 * Step2: For each roam-connection sets power to -60dbm
105 * Step3: Turns power mode off
108 * The signature for this method was generated by yang tools from the
112 * Input parameter from the olm yang model
113 * Input will contain nodeId and termination point
115 * @return Result of the request
118 public ListenableFuture<RpcResult<ServicePowerTurndownOutput>>
119 servicePowerTurndown(ServicePowerTurndownInput input) {
120 return RpcResultBuilder.success(this.olmPowerService.servicePowerTurndown(input)).buildFuture();
124 * This method calculates Spanloss for all Roadm to Roadm links,
125 * part of active inventory in Network Model or for newly added links
126 * based on input src-type.
129 * 1. Calculate-Spanloss-Base: This operation performs following steps:
130 * Step1: Read all Roadm-to-Roadm links from network model or get data for given linkID.
131 * Step2: Retrieve PMs for each end point for OTS interface
132 * Step3: Calculates Spanloss
133 * Step4: Posts calculated spanloss in Device and in network model
136 * The signature for this method was generated by yang tools from the
137 * renderer API model.
140 * Input parameter from the olm yang model
141 * Input will contain SourceType and linkId if srcType is Link
143 * @return Result of the request
146 public ListenableFuture<RpcResult<CalculateSpanlossBaseOutput>>
147 calculateSpanlossBase(CalculateSpanlossBaseInput input) {
148 return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossBase(input)).buildFuture();
152 public ListenableFuture<RpcResult<CalculateSpanlossCurrentOutput>> calculateSpanlossCurrent(
153 CalculateSpanlossCurrentInput input) {
154 return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossCurrent(input)).buildFuture();
158 public ListenableFuture<RpcResult<ServicePowerResetOutput>> servicePowerReset(ServicePowerResetInput input) {
159 return RpcResultBuilder.success(this.olmPowerService.servicePowerReset(input)).buildFuture();