Renderer and OLM update
[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 java.util.concurrent.Future;
11 import org.opendaylight.transportpce.olm.service.OlmPowerService;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseInput;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossBaseOutput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossCurrentInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.CalculateSpanlossCurrentOutput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.GetPmOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerResetInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerResetOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerSetupOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.ServicePowerTurndownOutput;
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 OlmService {
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 Future<RpcResult<GetPmOutput>> getPm(GetPmInput input) {
57         return RpcResultBuilder.success(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 Future<org.opendaylight.yangtools.yang.common.RpcResult<ServicePowerSetupOutput>> servicePowerSetup(
82         ServicePowerSetupInput input) {
83         return RpcResultBuilder.success(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  Future<RpcResult<ServicePowerTurndownOutput>> servicePowerTurndown(ServicePowerTurndownInput input) {
108         return RpcResultBuilder.success(olmPowerService.servicePowerTurndown(input)).buildFuture();
109     }
110
111     /**
112      * This method calculates Spanloss for all Roadm to Roadm links,
113      * part of active inventory in Network Model or for newly added links
114      * based on input src-type.
115      *
116      * <p>
117      * 1. Calculate-Spanloss-Base: This operation performs following steps:
118      *    Step1: Read all Roadm-to-Roadm links from network model or get data for given linkID.
119      *    Step2: Retrieve PMs for each end point for OTS interface
120      *    Step3: Calculates Spanloss
121      *    Step4: Posts calculated spanloss in Device and in network model
122      *
123      * <p>
124      * The signature for this method was generated by yang tools from the
125      * renderer API model.
126      *
127      * @param input
128      *            Input parameter from the olm yang model
129      *            Input will contain SourceType and linkId if srcType is Link
130      *
131      * @return Result of the request
132      */
133     @Override
134     public Future<RpcResult<CalculateSpanlossBaseOutput>> calculateSpanlossBase(CalculateSpanlossBaseInput input) {
135         return RpcResultBuilder.success(olmPowerService.calculateSpanlossBase(input)).buildFuture();
136     }
137
138     @Override
139     public Future<RpcResult<CalculateSpanlossCurrentOutput>> calculateSpanlossCurrent(
140             CalculateSpanlossCurrentInput input) {
141         return RpcResultBuilder.success(olmPowerService.calculateSpanlossCurrent(input)).buildFuture();
142     }
143
144     @Override
145     public Future<RpcResult<ServicePowerResetOutput>> servicePowerReset(ServicePowerResetInput input) {
146         return RpcResultBuilder.success(olmPowerService.servicePowerReset(input)).buildFuture();
147     }
148 }