eca01d990429def11033b427e9d218be8b6f7346
[ccsdk/features.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                      reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.features.sdnr.northbound.oofpcipoc;
23
24 import java.util.Properties;
25
26 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
27 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
28 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
29 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.GreetingOutputBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutputBuilder;
31 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.AddNeighborOutputBuilder;
32 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.DeleteNeighborOutputBuilder;
33 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.GenericNeighborConfigurationOutputBuilder;
34
35
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 public class OofpcipocClient {
40
41         private static final Logger LOG = LoggerFactory.getLogger(OofpcipocClient.class);
42
43         private SvcLogicService svcLogicService = null;
44
45         public OofpcipocClient(final SvcLogicService svcLogicService) {
46                 this.svcLogicService = svcLogicService;
47         }
48
49         public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
50         {
51                 return svcLogicService.hasGraph(module, rpc, version, mode);
52         }
53
54         public Properties execute(String module, String rpc, String version, String mode, GreetingOutputBuilder serviceData)
55                         throws SvcLogicException {
56
57                 Properties parms = new Properties();
58
59                 return execute(module,rpc,version, mode,serviceData,parms);
60         }
61
62         public Properties execute(String module, String rpc, String version, String mode, GreetingOutputBuilder serviceData, Properties parms)
63                                 throws SvcLogicException {
64         Properties localProp;
65         localProp = MdsalHelper.toProperties(parms, serviceData);
66
67                 if (LOG.isDebugEnabled())
68                 {
69                         LOG.debug("Parameters passed to SLI");
70
71                         for (Object key : localProp.keySet()) {
72                                 String parmName = (String) key;
73                                 String parmValue = localProp.getProperty(parmName);
74
75                                 LOG.debug(parmName+" = "+parmValue);
76
77                         }
78                 }
79
80                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
81
82                 if (LOG.isDebugEnabled())
83                 {
84                         LOG.debug("Parameters returned by SLI");
85
86                         for (Object key : respProps.keySet()) {
87                                 String parmName = (String) key;
88                                 String parmValue = respProps.getProperty(parmName);
89
90                                 LOG.debug(parmName+" = "+parmValue);
91
92                         }
93                 }
94                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
95                         return respProps;
96                 }
97
98                 MdsalHelper.toBuilder(respProps, serviceData);
99
100                 return respProps;
101         }
102
103         public Properties execute(String module, String rpc, String version, String mode, ConfigurationPhyCellIdOutputBuilder serviceData)
104                         throws SvcLogicException {
105
106                 Properties parms = new Properties();
107
108                 return execute(module,rpc,version, mode,serviceData,parms);
109         }
110
111         public Properties execute(String module, String rpc, String version, String mode, ConfigurationPhyCellIdOutputBuilder serviceData, Properties parms)
112                                 throws SvcLogicException {
113
114     Properties localProp;
115
116     localProp = MdsalHelper.toProperties(parms, serviceData);
117                 if (LOG.isDebugEnabled())
118                 {
119                         LOG.debug("Parameters passed to SLI");
120
121                         for (Object key : localProp.keySet()) {
122                                 String parmName = (String) key;
123                                 String parmValue = localProp.getProperty(parmName);
124
125                                 LOG.debug(parmName+" = "+parmValue);
126
127                         }
128                 }
129
130                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
131
132                 if (LOG.isDebugEnabled())
133                 {
134                         LOG.debug("Parameters returned by SLI");
135
136                         for (Object key : respProps.keySet()) {
137                                 String parmName = (String) key;
138                                 String parmValue = respProps.getProperty(parmName);
139
140                                 LOG.debug(parmName+" = "+parmValue);
141
142                         }
143                 }
144                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
145                         return respProps;
146                 }
147
148                 MdsalHelper.toBuilder(respProps, serviceData);
149
150                 return respProps;
151         }
152
153 // addNeighbor
154         public Properties execute(String module, String rpc, String version, String mode, AddNeighborOutputBuilder serviceData)
155                         throws SvcLogicException {
156
157                 Properties parms = new Properties();
158
159                 return execute(module,rpc,version, mode,serviceData,parms);
160         }
161
162         public Properties execute(String module, String rpc, String version, String mode, AddNeighborOutputBuilder serviceData, Properties parms)
163                                 throws SvcLogicException {
164                                 Properties localProp;
165                                 localProp = MdsalHelper.toProperties(parms, serviceData);
166
167                 if (LOG.isDebugEnabled())
168                 {
169                         LOG.debug("Parameters passed to SLI");
170
171                         for (Object key : localProp.keySet()) {
172                                 String parmName = (String) key;
173                                 String parmValue = localProp.getProperty(parmName);
174
175                                 LOG.debug(parmName+" = "+parmValue);
176
177                         }
178                 }
179
180                 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
181
182                 if (LOG.isDebugEnabled())
183                 {
184                         LOG.debug("Parameters returned by SLI");
185
186                         for (Object key : respProps.keySet()) {
187                                 String parmName = (String) key;
188                                 String parmValue = respProps.getProperty(parmName);
189
190                                 LOG.debug(parmName+" = "+parmValue);
191
192                         }
193                 }
194                 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
195                         return respProps;
196                 }
197
198                 MdsalHelper.toBuilder(respProps, serviceData);
199
200                 return respProps;
201         }
202
203
204 // deleteNeighbor
205
206 public Properties execute(String module, String rpc, String version, String mode, DeleteNeighborOutputBuilder serviceData)
207                 throws SvcLogicException {
208
209         Properties parms = new Properties();
210
211         return execute(module,rpc,version, mode,serviceData,parms);
212 }
213
214 public Properties execute(String module, String rpc, String version, String mode, DeleteNeighborOutputBuilder serviceData, Properties parms)
215                         throws SvcLogicException {
216                         Properties localProp;
217                         localProp = MdsalHelper.toProperties(parms, serviceData);
218
219         if (LOG.isDebugEnabled())
220         {
221                 LOG.debug("Parameters passed to SLI");
222
223                 for (Object key : localProp.keySet()) {
224                         String parmName = (String) key;
225                         String parmValue = localProp.getProperty(parmName);
226
227                         LOG.debug(parmName+" = "+parmValue);
228
229                 }
230         }
231
232         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
233
234         if (LOG.isDebugEnabled())
235         {
236                 LOG.debug("Parameters returned by SLI");
237
238                 for (Object key : respProps.keySet()) {
239                         String parmName = (String) key;
240                         String parmValue = respProps.getProperty(parmName);
241
242                         LOG.debug(parmName+" = "+parmValue);
243
244                 }
245         }
246         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
247                 return respProps;
248         }
249
250         MdsalHelper.toBuilder(respProps, serviceData);
251
252         return respProps;
253 }
254
255
256 // genericNeighborConfiguration
257
258 public Properties execute(String module, String rpc, String version, String mode, GenericNeighborConfigurationOutputBuilder serviceData)
259                 throws SvcLogicException {
260
261         Properties parms = new Properties();
262
263         return execute(module,rpc,version, mode,serviceData,parms);
264 }
265
266 public Properties execute(String module, String rpc, String version, String mode, GenericNeighborConfigurationOutputBuilder serviceData, Properties parms)
267                         throws SvcLogicException {
268                         Properties localProp;
269                         localProp = MdsalHelper.toProperties(parms, serviceData);
270
271         if (LOG.isDebugEnabled())
272         {
273                 LOG.debug("Parameters passed to SLI");
274
275                 for (Object key : localProp.keySet()) {
276                         String parmName = (String) key;
277                         String parmValue = localProp.getProperty(parmName);
278
279                         LOG.debug(parmName+" = "+parmValue);
280
281                 }
282         }
283
284         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
285
286         if (LOG.isDebugEnabled())
287         {
288                 LOG.debug("Parameters returned by SLI");
289
290                 for (Object key : respProps.keySet()) {
291                         String parmName = (String) key;
292                         String parmValue = respProps.getProperty(parmName);
293
294                         LOG.debug(parmName+" = "+parmValue);
295
296                 }
297         }
298         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
299                 return respProps;
300         }
301
302         MdsalHelper.toBuilder(respProps, serviceData);
303
304         return respProps;
305 }
306
307 }