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.osgi.service.component.annotations.Activate;
30 import org.osgi.service.component.annotations.Component;
31 import org.osgi.service.component.annotations.Reference;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
36 * The Class OlmPowerServiceRpcImpl.
39 public class OlmPowerServiceRpcImpl implements TransportpceOlmService {
40 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceRpcImpl.class);
41 private final OlmPowerService olmPowerService;
44 public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService) {
45 this.olmPowerService = olmPowerService;
49 * This method is the implementation of the 'get-pm' RESTCONF service, which
50 * is one of the external APIs into the olm application.
53 * 1. get-pm This operation traverse through current PM list and gets PM for
54 * given NodeId and Resource name
57 * The signature for this method was generated by yang tools from the
61 * Input parameter from the olm yang model
63 * @return Result of the request
66 public ListenableFuture<RpcResult<GetPmOutput>> getPm(GetPmInput input) {
67 if (this.olmPowerService.getPm(input).getNodeId() == null) {
68 LOG.error("getPm: Error with input parameters");
69 return RpcResultBuilder.<GetPmOutput>failed()
70 .withError(ErrorType.RPC, "Error with input parameters")
73 return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture();
77 * This method is the implementation of the 'service-power-setup' RESTCONF service, which
78 * is one of the external APIs into the olm application.
81 * 1. service-power-setup: This operation performs following steps:
82 * Step1: Calculate Spanloss on all links which are part of service.
83 * TODO Step2: Calculate power levels for each Tp-Id
84 * TODO Step3: Post power values on roadm connections
87 * The signature for this method was generated by yang tools from the
91 * Input parameter from the olm yang model
92 * Input will contain nodeId and termination point
94 * @return Result of the request
97 public ListenableFuture<RpcResult<ServicePowerSetupOutput>> servicePowerSetup(
98 ServicePowerSetupInput input) {
99 return RpcResultBuilder.success(this.olmPowerService.servicePowerSetup(input)).buildFuture();
103 * This method is the implementation of the 'service-power-trundown' RESTCONF service, which
104 * is one of the external APIs into the olm application.
107 * 1. service-power-turndown: This operation performs following steps:
108 * Step1: For each TP within Node sets interface outofservice .
109 * Step2: For each roam-connection sets power to -60dbm
110 * Step3: Turns power mode off
113 * The signature for this method was generated by yang tools from the
117 * Input parameter from the olm yang model
118 * Input will contain nodeId and termination point
120 * @return Result of the request
123 public ListenableFuture<RpcResult<ServicePowerTurndownOutput>>
124 servicePowerTurndown(ServicePowerTurndownInput input) {
125 return RpcResultBuilder.success(this.olmPowerService.servicePowerTurndown(input)).buildFuture();
129 * This method calculates Spanloss for all Roadm to Roadm links,
130 * part of active inventory in Network Model or for newly added links
131 * based on input src-type.
134 * 1. Calculate-Spanloss-Base: This operation performs following steps:
135 * Step1: Read all Roadm-to-Roadm links from network model or get data for given linkID.
136 * Step2: Retrieve PMs for each end point for OTS interface
137 * Step3: Calculates Spanloss
138 * Step4: Posts calculated spanloss in Device and in network model
141 * The signature for this method was generated by yang tools from the
142 * renderer API model.
145 * Input parameter from the olm yang model
146 * Input will contain SourceType and linkId if srcType is Link
148 * @return Result of the request
151 public ListenableFuture<RpcResult<CalculateSpanlossBaseOutput>>
152 calculateSpanlossBase(CalculateSpanlossBaseInput input) {
153 return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossBase(input)).buildFuture();
157 public ListenableFuture<RpcResult<CalculateSpanlossCurrentOutput>> calculateSpanlossCurrent(
158 CalculateSpanlossCurrentInput input) {
159 return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossCurrent(input)).buildFuture();
163 public ListenableFuture<RpcResult<ServicePowerResetOutput>> servicePowerReset(ServicePowerResetInput input) {
164 return RpcResultBuilder.success(this.olmPowerService.servicePowerReset(input)).buildFuture();