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