a9f051a274aab212fdf8f46a650c139107b1e662
[sdnc/northbound.git] / vnfapi / provider / src / main / java / org / onap / sdnc / vnfapi / VNFSDNSvcLogicServiceClient.java
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.sdnc.vnfapi;
23
24 import java.util.Properties;
25
26 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadDataBuilder;
27 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
28 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadDataBuilder;
29 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceDataBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadDataBuilder;
31 //1610
32 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceDataBuilder;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
34 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
35 import org.osgi.framework.BundleContext;
36 import org.osgi.framework.FrameworkUtil;
37 import org.osgi.framework.ServiceReference;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40
41 public class VNFSDNSvcLogicServiceClient {
42
43     private static final Logger LOG = LoggerFactory
44             .getLogger(VNFSDNSvcLogicServiceClient.class);
45
46     private final SvcLogicService svcLogic;
47
48     public VNFSDNSvcLogicServiceClient(final SvcLogicService svcLogicService)
49     {
50                 this.svcLogic = svcLogicService;
51
52     }
53
54     public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
55     {
56         return(svcLogic.hasGraph(module, rpc, version, mode));
57     }
58
59     public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData)
60             throws SvcLogicException {
61
62         Properties parms = new Properties();
63
64         return execute(module,rpc,version, mode,serviceData,parms);
65     }
66
67     public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData)
68             throws SvcLogicException {
69
70         Properties parms = new Properties();
71
72         return execute(module,rpc,version, mode,serviceData,parms);
73     }
74
75
76     public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData, Properties parms)
77                 throws SvcLogicException {
78
79         parms = VnfSdnUtil.toProperties(parms, serviceData);
80
81         if (LOG.isDebugEnabled())
82         {
83             LOG.debug("Parameters passed to SLI");
84
85             for (Object key : parms.keySet()) {
86                 String parmName = (String) key;
87                 String parmValue = parms.getProperty(parmName);
88
89                 LOG.debug(parmName+" = "+parmValue);
90
91             }
92         }
93
94         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
95
96         if (LOG.isDebugEnabled())
97         {
98             LOG.debug("Parameters returned by SLI");
99
100             for (Object key : respProps.keySet()) {
101                 String parmName = (String) key;
102                 String parmValue = respProps.getProperty(parmName);
103
104                 LOG.debug(parmName+" = "+parmValue);
105
106             }
107         }
108         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
109             return (respProps);
110         }
111
112         VnfSdnUtil.toBuilder(respProps, serviceData);
113
114         return (respProps);
115     }
116
117
118     public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData, Properties parms)
119                 throws SvcLogicException {
120
121         parms = VnfSdnUtil.toProperties(parms, serviceData);
122
123         if (LOG.isDebugEnabled())
124         {
125             LOG.debug("Parameters passed to SLI");
126
127             for (Object key : parms.keySet()) {
128                 String parmName = (String) key;
129                 String parmValue = parms.getProperty(parmName);
130
131                 LOG.debug(parmName+" = "+parmValue);
132
133             }
134         }
135
136         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
137
138         if (LOG.isDebugEnabled())
139         {
140             LOG.debug("Parameters returned by SLI");
141
142             for (Object key : respProps.keySet()) {
143                 String parmName = (String) key;
144                 String parmValue = respProps.getProperty(parmName);
145
146                 LOG.debug(parmName+" = "+parmValue);
147
148             }
149         }
150         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
151             return (respProps);
152         }
153
154         VnfSdnUtil.toBuilder(respProps, serviceData);
155
156         return (respProps);
157     }
158
159
160     //1610 vnf-instance
161     public Properties execute(String module, String rpc, String version, String mode, VnfInstanceServiceDataBuilder serviceData)
162             throws SvcLogicException {
163
164         Properties parms = new Properties();
165
166         return execute(module,rpc,version, mode,serviceData,parms);
167     }
168
169     //1610 vnf-instance
170     public Properties execute(String module, String rpc, String version, String mode, VnfInstanceServiceDataBuilder serviceData, Properties parms)
171                 throws SvcLogicException {
172
173         parms = VnfSdnUtil.toProperties(parms, serviceData);
174
175         if (LOG.isDebugEnabled())
176         {
177             LOG.debug("Parameters passed to SLI");
178
179             for (Object key : parms.keySet()) {
180                 String parmName = (String) key;
181                 String parmValue = parms.getProperty(parmName);
182
183                 LOG.debug(parmName+" = "+parmValue);
184
185             }
186         }
187
188         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
189
190         if (LOG.isDebugEnabled())
191         {
192             LOG.debug("Parameters returned by SLI");
193
194             for (Object key : respProps.keySet()) {
195                 String parmName = (String) key;
196                 String parmValue = respProps.getProperty(parmName);
197
198                 LOG.debug(parmName+" = "+parmValue);
199
200             }
201         }
202         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
203             return (respProps);
204         }
205
206         VnfSdnUtil.toBuilder(respProps, serviceData);
207
208         return (respProps);
209     }
210
211     //1610 vf-module
212     public Properties execute(String module, String rpc, String version, String mode, VfModuleServiceDataBuilder serviceData)
213             throws SvcLogicException {
214
215         Properties parms = new Properties();
216
217         return execute(module,rpc,version, mode,serviceData,parms);
218     }
219
220     //1610 vf-module
221     public Properties execute(String module, String rpc, String version, String mode, VfModuleServiceDataBuilder serviceData, Properties parms)
222                 throws SvcLogicException {
223
224         parms = VnfSdnUtil.toProperties(parms, serviceData);
225
226         if (LOG.isDebugEnabled())
227         {
228             LOG.debug("Parameters passed to SLI");
229
230             for (Object key : parms.keySet()) {
231                 String parmName = (String) key;
232                 String parmValue = parms.getProperty(parmName);
233
234                 LOG.debug(parmName+" = "+parmValue);
235
236             }
237         }
238
239         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
240
241         if (LOG.isDebugEnabled())
242         {
243             LOG.debug("Parameters returned by SLI");
244
245             for (Object key : respProps.keySet()) {
246                 String parmName = (String) key;
247                 String parmValue = respProps.getProperty(parmName);
248
249                 LOG.debug(parmName+" = "+parmValue);
250
251             }
252         }
253         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
254             return (respProps);
255         }
256
257         VnfSdnUtil.toBuilder(respProps, serviceData);
258
259         return (respProps);
260     }
261
262     //1610 vnf-instance-preload
263     public Properties execute(String module, String rpc, String version, String mode, VnfInstancePreloadDataBuilder serviceData)
264             throws SvcLogicException {
265
266         Properties parms = new Properties();
267
268         return execute(module,rpc,version, mode,serviceData,parms);
269     }
270
271
272     //1610 vnf-instance-preload
273     public Properties execute(String module, String rpc, String version, String mode, VnfInstancePreloadDataBuilder serviceData, Properties parms)
274                 throws SvcLogicException {
275
276         parms = VnfSdnUtil.toProperties(parms, serviceData);
277
278         if (LOG.isDebugEnabled())
279         {
280             LOG.debug("Parameters passed to SLI");
281
282             for (Object key : parms.keySet()) {
283                 String parmName = (String) key;
284                 String parmValue = parms.getProperty(parmName);
285
286                 LOG.debug(parmName+" = "+parmValue);
287
288             }
289         }
290
291         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
292
293         if (LOG.isDebugEnabled())
294         {
295             LOG.debug("Parameters returned by SLI");
296
297             for (Object key : respProps.keySet()) {
298                 String parmName = (String) key;
299                 String parmValue = respProps.getProperty(parmName);
300
301                 LOG.debug(parmName+" = "+parmValue);
302
303             }
304         }
305         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
306             return (respProps);
307         }
308
309         VnfSdnUtil.toBuilder(respProps, serviceData);
310
311         return (respProps);
312     }
313
314     //1610 vf-module-preload
315     public Properties execute(String module, String rpc, String version, String mode, VfModulePreloadDataBuilder serviceData)
316             throws SvcLogicException {
317
318         Properties parms = new Properties();
319
320         return execute(module,rpc,version, mode,serviceData,parms);
321     }
322
323
324     //1610 vf-module-preload
325     public Properties execute(String module, String rpc, String version, String mode, VfModulePreloadDataBuilder serviceData, Properties parms)
326                 throws SvcLogicException {
327
328         parms = VnfSdnUtil.toProperties(parms, serviceData);
329
330         if (LOG.isDebugEnabled())
331         {
332             LOG.debug("Parameters passed to SLI");
333
334             for (Object key : parms.keySet()) {
335                 String parmName = (String) key;
336                 String parmValue = parms.getProperty(parmName);
337
338                 LOG.debug(parmName+" = "+parmValue);
339
340             }
341         }
342
343         Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
344
345         if (LOG.isDebugEnabled())
346         {
347             LOG.debug("Parameters returned by SLI");
348
349             for (Object key : respProps.keySet()) {
350                 String parmName = (String) key;
351                 String parmValue = respProps.getProperty(parmName);
352
353                 LOG.debug(parmName+" = "+parmValue);
354
355             }
356         }
357         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
358             return (respProps);
359         }
360
361         VnfSdnUtil.toBuilder(respProps, serviceData);
362
363         return (respProps);
364     }
365
366
367 }