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