fix deprecated openroadm interfaces/objects
[transportpce.git] / olm / src / main / java / org / opendaylight / transportpce / olm / OlmPowerServiceRpcImpl.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.olm;
10
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.rev170418.CalculateSpanlossBaseInput;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossBaseOutput;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentInput;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.CalculateSpanlossCurrentOutput;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.GetPmOutput;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetInput;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerResetOutput;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupInput;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerSetupOutput;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownInput;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.ServicePowerTurndownOutput;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev170418.TransportpceOlmService;
26 import org.opendaylight.yangtools.yang.common.RpcResult;
27 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
28
29 /**
30  * The Class OlmPowerServiceRpcImpl.
31  */
32 public class OlmPowerServiceRpcImpl implements TransportpceOlmService {
33     private final OlmPowerService olmPowerService;
34
35     public OlmPowerServiceRpcImpl(OlmPowerService olmPowerService) {
36         this.olmPowerService = olmPowerService;
37     }
38
39     /**
40      * This method is the implementation of the 'get-pm' RESTCONF service, which
41      * is one of the external APIs into the olm application.
42      *
43      * <p>
44      * 1. get-pm This operation traverse through current PM list and gets PM for
45      * given NodeId and Resource name
46      *
47      * <p>
48      * The signature for this method was generated by yang tools from the
49      * olm API model.
50      *
51      * @param input
52      *            Input parameter from the olm yang model
53      *
54      * @return Result of the request
55      */
56     @Override
57     public ListenableFuture<RpcResult<GetPmOutput>> getPm(GetPmInput input) {
58         return RpcResultBuilder.success(this.olmPowerService.getPm(input)).buildFuture();
59     }
60
61     /**
62      * This method is the implementation of the 'service-power-setup' RESTCONF service, which
63      * is one of the external APIs into the olm application.
64      *
65      * <p>
66      * 1. service-power-setup: This operation performs following steps:
67      *    Step1: Calculate Spanloss on all links which are part of service.
68      *    TODO Step2: Calculate power levels for each Tp-Id
69      *    TODO Step3: Post power values on roadm connections
70      *
71      * <p>
72      * The signature for this method was generated by yang tools from the
73      * olm API model.
74      *
75      * @param input
76      *            Input parameter from the olm yang model
77      *            Input will contain nodeId and termination point
78      *
79      * @return Result of the request
80      */
81     @Override
82     public ListenableFuture<RpcResult<ServicePowerSetupOutput>> servicePowerSetup(
83             ServicePowerSetupInput input) {
84         return RpcResultBuilder.success(this.olmPowerService.servicePowerSetup(input)).buildFuture();
85     }
86
87     /**
88      * This method is the implementation of the 'service-power-trundown' RESTCONF service, which
89      * is one of the external APIs into the olm application.
90      *
91      * <p>
92      * 1. service-power-turndown: This operation performs following steps:
93      *    Step1: For each TP within Node sets interface outofservice .
94      *    Step2: For each roam-connection sets power to -60dbm
95      *    Step3: Turns power mode off
96      *
97      * <p>
98      * The signature for this method was generated by yang tools from the
99      * olm API model.
100      *
101      * @param input
102      *            Input parameter from the olm yang model
103      *            Input will contain nodeId and termination point
104      *
105      * @return Result of the request
106      */
107     @Override
108     public ListenableFuture<RpcResult<ServicePowerTurndownOutput>>
109         servicePowerTurndown(ServicePowerTurndownInput input) {
110         return RpcResultBuilder.success(this.olmPowerService.servicePowerTurndown(input)).buildFuture();
111     }
112
113     /**
114      * This method calculates Spanloss for all Roadm to Roadm links,
115      * part of active inventory in Network Model or for newly added links
116      * based on input src-type.
117      *
118      * <p>
119      * 1. Calculate-Spanloss-Base: This operation performs following steps:
120      *    Step1: Read all Roadm-to-Roadm links from network model or get data for given linkID.
121      *    Step2: Retrieve PMs for each end point for OTS interface
122      *    Step3: Calculates Spanloss
123      *    Step4: Posts calculated spanloss in Device and in network model
124      *
125      * <p>
126      * The signature for this method was generated by yang tools from the
127      * renderer API model.
128      *
129      * @param input
130      *            Input parameter from the olm yang model
131      *            Input will contain SourceType and linkId if srcType is Link
132      *
133      * @return Result of the request
134      */
135     @Override
136     public ListenableFuture<RpcResult<CalculateSpanlossBaseOutput>>
137         calculateSpanlossBase(CalculateSpanlossBaseInput input) {
138         return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossBase(input)).buildFuture();
139     }
140
141     @Override
142     public ListenableFuture<RpcResult<CalculateSpanlossCurrentOutput>> calculateSpanlossCurrent(
143             CalculateSpanlossCurrentInput input) {
144         return RpcResultBuilder.success(this.olmPowerService.calculateSpanlossCurrent(input)).buildFuture();
145     }
146
147     @Override
148     public ListenableFuture<RpcResult<ServicePowerResetOutput>> servicePowerReset(ServicePowerResetInput input) {
149         return RpcResultBuilder.success(this.olmPowerService.servicePowerReset(input)).buildFuture();
150     }
151 }