324e0eae147c0d3e950a7662449a10d6b3ec2688
[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  * Modifications Copyright (C) 2020 Nordix Foundation.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
24
25 import java.util.Properties;
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.rev191212.CreatePolicyInstanceOutputBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutputBuilder;
31 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutputBuilder;
32 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutputBuilder;
33 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutputBuilder;
34 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutputBuilder;
35 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutputBuilder;
36 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutputBuilder;
37 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutputBuilder;
38 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutputBuilder;
39 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutputBuilder;
40 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutputBuilder;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 public class A1AdapterClient {
45
46     private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
47
48     private SvcLogicService svcLogicService = null;
49
50     public A1AdapterClient(final SvcLogicService svcLogicService) {
51         this.svcLogicService = svcLogicService;
52     }
53
54     public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
55         return svcLogicService.hasGraph(module, rpc, version, mode);
56     }
57
58     // Client for GetNearRTRICs
59
60     public Properties execute(String module, String rpc, String version, String mode,
61             GetNearRTRICsOutputBuilder serviceData) throws SvcLogicException {
62
63         Properties parms = new Properties();
64
65         return execute(module, rpc, version, mode, serviceData, parms);
66     }
67
68     public Properties execute(String module, String rpc, String version, String mode,
69             GetNearRTRICsOutputBuilder serviceData, Properties parms) throws SvcLogicException {
70         Properties localProp;
71         localProp = MdsalHelper.toProperties(parms, serviceData);
72
73         if (LOG.isDebugEnabled()) {
74             LOG.debug("Parameters passed to SLI");
75
76             for (Object key : localProp.keySet()) {
77                 String parmName = (String) key;
78                 String parmValue = localProp.getProperty(parmName);
79
80                 LOG.debug(parmName + " = " + parmValue);
81
82             }
83         }
84
85         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
86
87         if (LOG.isDebugEnabled()) {
88             LOG.debug("Parameters returned by SLI");
89
90             for (Object key : respProps.keySet()) {
91                 String parmName = (String) key;
92                 String parmValue = respProps.getProperty(parmName);
93
94                 LOG.debug(parmName + " = " + parmValue);
95
96             }
97         }
98         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
99             return respProps;
100         }
101
102         MdsalHelper.toBuilder(respProps, serviceData);
103
104         return respProps;
105     }
106
107     // Client for GetHealthCheck
108
109     public Properties execute(String module, String rpc, String version, String mode,
110             GetHealthCheckOutputBuilder serviceData) throws SvcLogicException {
111
112         Properties parms = new Properties();
113
114         return execute(module, rpc, version, mode, serviceData, parms);
115     }
116
117     public Properties execute(String module, String rpc, String version, String mode,
118             GetHealthCheckOutputBuilder serviceData, Properties parms) throws SvcLogicException {
119         Properties localProp;
120         localProp = MdsalHelper.toProperties(parms, serviceData);
121
122         if (LOG.isDebugEnabled()) {
123             LOG.debug("Parameters passed to SLI");
124
125             for (Object key : localProp.keySet()) {
126                 String parmName = (String) key;
127                 String parmValue = localProp.getProperty(parmName);
128
129                 LOG.debug(parmName + " = " + parmValue);
130
131             }
132         }
133
134         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
135
136         if (LOG.isDebugEnabled()) {
137             LOG.debug("Parameters returned by SLI");
138
139             for (Object key : respProps.keySet()) {
140                 String parmName = (String) key;
141                 String parmValue = respProps.getProperty(parmName);
142
143                 LOG.debug(parmName + " = " + parmValue);
144
145             }
146         }
147         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
148             return respProps;
149         }
150
151         MdsalHelper.toBuilder(respProps, serviceData);
152
153         return respProps;
154     }
155
156
157     // Client for getPolicyTypes
158
159     public Properties execute(String module, String rpc, String version, String mode,
160             GetPolicyTypesOutputBuilder serviceData) throws SvcLogicException {
161
162         Properties parms = new Properties();
163
164         return execute(module, rpc, version, mode, serviceData, parms);
165     }
166
167     public Properties execute(String module, String rpc, String version, String mode,
168             GetPolicyTypesOutputBuilder serviceData, Properties parms) throws SvcLogicException {
169         Properties localProp;
170         localProp = MdsalHelper.toProperties(parms, serviceData);
171
172         if (LOG.isDebugEnabled()) {
173             LOG.debug("Parameters passed to SLI");
174
175             for (Object key : localProp.keySet()) {
176                 String parmName = (String) key;
177                 String parmValue = localProp.getProperty(parmName);
178
179                 LOG.debug(parmName + " = " + parmValue);
180
181             }
182         }
183
184         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
185
186         if (LOG.isDebugEnabled()) {
187             LOG.debug("Parameters returned by SLI");
188
189             for (Object key : respProps.keySet()) {
190                 String parmName = (String) key;
191                 String parmValue = respProps.getProperty(parmName);
192
193                 LOG.debug(parmName + " = " + parmValue);
194
195             }
196         }
197         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
198             return respProps;
199         }
200
201         MdsalHelper.toBuilder(respProps, serviceData);
202
203         return respProps;
204     }
205
206
207     // Client for createPolicyType
208
209
210     public Properties execute(String module, String rpc, String version, String mode,
211             CreatePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
212
213         Properties parms = new Properties();
214
215         return execute(module, rpc, version, mode, serviceData, parms);
216     }
217
218     public Properties execute(String module, String rpc, String version, String mode,
219             CreatePolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
220         Properties localProp;
221         localProp = MdsalHelper.toProperties(parms, serviceData);
222
223         if (LOG.isDebugEnabled()) {
224             LOG.debug("Parameters passed to SLI");
225
226             for (Object key : localProp.keySet()) {
227                 String parmName = (String) key;
228                 String parmValue = localProp.getProperty(parmName);
229
230                 LOG.debug(parmName + " = " + parmValue);
231
232             }
233         }
234
235         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
236
237         if (LOG.isDebugEnabled()) {
238             LOG.debug("Parameters returned by SLI");
239
240             for (Object key : respProps.keySet()) {
241                 String parmName = (String) key;
242                 String parmValue = respProps.getProperty(parmName);
243
244                 LOG.debug(parmName + " = " + parmValue);
245
246             }
247         }
248         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
249             return respProps;
250         }
251
252         MdsalHelper.toBuilder(respProps, serviceData);
253
254         return respProps;
255     }
256
257     // Client for getPolicyType
258
259     public Properties execute(String module, String rpc, String version, String mode,
260             GetPolicyTypeOutputBuilder serviceData) throws SvcLogicException {
261
262         Properties parms = new Properties();
263
264         return execute(module, rpc, version, mode, serviceData, parms);
265     }
266
267     public Properties execute(String module, String rpc, String version, String mode,
268             GetPolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
269         Properties localProp;
270         localProp = MdsalHelper.toProperties(parms, serviceData);
271
272         if (LOG.isDebugEnabled()) {
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             LOG.debug("Parameters returned by SLI");
288
289             for (Object key : respProps.keySet()) {
290                 String parmName = (String) key;
291                 String parmValue = respProps.getProperty(parmName);
292
293                 LOG.debug(parmName + " = " + parmValue);
294
295             }
296         }
297         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
298             return respProps;
299         }
300
301         MdsalHelper.toBuilder(respProps, serviceData);
302
303         return respProps;
304     }
305
306
307     // Client for deletePolicyType
308
309     public Properties execute(String module, String rpc, String version, String mode,
310             DeletePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
311
312         Properties parms = new Properties();
313
314         return execute(module, rpc, version, mode, serviceData, parms);
315     }
316
317     public Properties execute(String module, String rpc, String version, String mode,
318             DeletePolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
319         Properties localProp;
320         localProp = MdsalHelper.toProperties(parms, serviceData);
321
322         if (LOG.isDebugEnabled()) {
323             LOG.debug("Parameters passed to SLI");
324
325             for (Object key : localProp.keySet()) {
326                 String parmName = (String) key;
327                 String parmValue = localProp.getProperty(parmName);
328
329                 LOG.debug(parmName + " = " + parmValue);
330
331             }
332         }
333
334         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
335
336         if (LOG.isDebugEnabled()) {
337             LOG.debug("Parameters returned by SLI");
338
339             for (Object key : respProps.keySet()) {
340                 String parmName = (String) key;
341                 String parmValue = respProps.getProperty(parmName);
342
343                 LOG.debug(parmName + " = " + parmValue);
344
345             }
346         }
347         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
348             return respProps;
349         }
350
351         MdsalHelper.toBuilder(respProps, serviceData);
352
353         return respProps;
354     }
355
356
357     // Client for getPolicyInstances
358
359     public Properties execute(String module, String rpc, String version, String mode,
360             GetPolicyInstancesOutputBuilder serviceData) throws SvcLogicException {
361
362         Properties parms = new Properties();
363
364         return execute(module, rpc, version, mode, serviceData, parms);
365     }
366
367     public Properties execute(String module, String rpc, String version, String mode,
368             GetPolicyInstancesOutputBuilder serviceData, Properties parms) throws SvcLogicException {
369         Properties localProp;
370         localProp = MdsalHelper.toProperties(parms, serviceData);
371
372         if (LOG.isDebugEnabled()) {
373             LOG.debug("Parameters passed to SLI");
374
375             for (Object key : localProp.keySet()) {
376                 String parmName = (String) key;
377                 String parmValue = localProp.getProperty(parmName);
378
379                 LOG.debug(parmName + " = " + parmValue);
380
381             }
382         }
383
384         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
385
386         if (LOG.isDebugEnabled()) {
387             LOG.debug("Parameters returned by SLI");
388
389             for (Object key : respProps.keySet()) {
390                 String parmName = (String) key;
391                 String parmValue = respProps.getProperty(parmName);
392
393                 LOG.debug(parmName + " = " + parmValue);
394
395             }
396         }
397         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
398             return respProps;
399         }
400
401         MdsalHelper.toBuilder(respProps, serviceData);
402
403         return respProps;
404     }
405
406
407
408     // Client for createPolicyInstance
409
410     public Properties execute(String module, String rpc, String version, String mode,
411             CreatePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
412
413         Properties parms = new Properties();
414
415         return execute(module, rpc, version, mode, serviceData, parms);
416     }
417
418     public Properties execute(String module, String rpc, String version, String mode,
419             CreatePolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
420         Properties localProp;
421         localProp = MdsalHelper.toProperties(parms, serviceData);
422
423         if (LOG.isDebugEnabled()) {
424             LOG.debug("Parameters passed to SLI");
425
426             for (Object key : localProp.keySet()) {
427                 String parmName = (String) key;
428                 String parmValue = localProp.getProperty(parmName);
429
430                 LOG.debug(parmName + " = " + parmValue);
431
432             }
433         }
434
435         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
436
437         if (LOG.isDebugEnabled()) {
438             LOG.debug("Parameters returned by SLI");
439
440             for (Object key : respProps.keySet()) {
441                 String parmName = (String) key;
442                 String parmValue = respProps.getProperty(parmName);
443
444                 LOG.debug(parmName + " = " + parmValue);
445
446             }
447         }
448         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
449             return respProps;
450         }
451
452         MdsalHelper.toBuilder(respProps, serviceData);
453
454         return respProps;
455     }
456
457
458     // Client for getPolicyInstance
459
460     public Properties execute(String module, String rpc, String version, String mode,
461             GetPolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
462
463         Properties parms = new Properties();
464
465         return execute(module, rpc, version, mode, serviceData, parms);
466     }
467
468     public Properties execute(String module, String rpc, String version, String mode,
469             GetPolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
470         Properties localProp;
471         localProp = MdsalHelper.toProperties(parms, serviceData);
472
473         if (LOG.isDebugEnabled()) {
474             LOG.debug("Parameters passed to SLI");
475
476             for (Object key : localProp.keySet()) {
477                 String parmName = (String) key;
478                 String parmValue = localProp.getProperty(parmName);
479
480                 LOG.debug(parmName + " = " + parmValue);
481
482             }
483         }
484
485         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
486
487         if (LOG.isDebugEnabled()) {
488             LOG.debug("Parameters returned by SLI");
489
490             for (Object key : respProps.keySet()) {
491                 String parmName = (String) key;
492                 String parmValue = respProps.getProperty(parmName);
493
494                 LOG.debug(parmName + " = " + parmValue);
495
496             }
497         }
498         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
499             return respProps;
500         }
501
502         MdsalHelper.toBuilder(respProps, serviceData);
503
504         return respProps;
505     }
506
507     // Client for deletePolicyInstance
508
509     public Properties execute(String module, String rpc, String version, String mode,
510             DeletePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
511
512         Properties parms = new Properties();
513
514         return execute(module, rpc, version, mode, serviceData, parms);
515     }
516
517     public Properties execute(String module, String rpc, String version, String mode,
518             DeletePolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
519         Properties localProp;
520         localProp = MdsalHelper.toProperties(parms, serviceData);
521
522         if (LOG.isDebugEnabled()) {
523             LOG.debug("Parameters passed to SLI");
524
525             for (Object key : localProp.keySet()) {
526                 String parmName = (String) key;
527                 String parmValue = localProp.getProperty(parmName);
528
529                 LOG.debug(parmName + " = " + parmValue);
530
531             }
532         }
533
534         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
535
536         if (LOG.isDebugEnabled()) {
537             LOG.debug("Parameters returned by SLI");
538
539             for (Object key : respProps.keySet()) {
540                 String parmName = (String) key;
541                 String parmValue = respProps.getProperty(parmName);
542
543                 LOG.debug(parmName + " = " + parmValue);
544
545             }
546         }
547         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
548             return respProps;
549         }
550
551         MdsalHelper.toBuilder(respProps, serviceData);
552
553         return respProps;
554     }
555
556     // Client for getStatus
557
558
559     public Properties execute(String module, String rpc, String version, String mode,
560             GetStatusOutputBuilder serviceData) throws SvcLogicException {
561
562         Properties parms = new Properties();
563
564         return execute(module, rpc, version, mode, serviceData, parms);
565     }
566
567     public Properties execute(String module, String rpc, String version, String mode,
568             GetStatusOutputBuilder serviceData, Properties parms) throws SvcLogicException {
569         Properties localProp;
570         localProp = MdsalHelper.toProperties(parms, serviceData);
571
572         if (LOG.isDebugEnabled()) {
573             LOG.debug("Parameters passed to SLI");
574
575             for (Object key : localProp.keySet()) {
576                 String parmName = (String) key;
577                 String parmValue = localProp.getProperty(parmName);
578
579                 LOG.debug(parmName + " = " + parmValue);
580
581             }
582         }
583
584         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
585
586         if (LOG.isDebugEnabled()) {
587             LOG.debug("Parameters returned by SLI");
588
589             for (Object key : respProps.keySet()) {
590                 String parmName = (String) key;
591                 String parmValue = respProps.getProperty(parmName);
592
593                 LOG.debug(parmName + " = " + parmValue);
594
595             }
596         }
597         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
598             return respProps;
599         }
600
601         MdsalHelper.toBuilder(respProps, serviceData);
602
603         return respProps;
604     }
605
606
607     // Client for notifyPolicyEnforcementUpdate
608
609
610     public Properties execute(String module, String rpc, String version, String mode,
611             NotifyPolicyEnforcementUpdateOutputBuilder serviceData) throws SvcLogicException {
612
613         Properties parms = new Properties();
614
615         return execute(module, rpc, version, mode, serviceData, parms);
616     }
617
618     public Properties execute(String module, String rpc, String version, String mode,
619             NotifyPolicyEnforcementUpdateOutputBuilder serviceData, Properties parms) throws SvcLogicException {
620         Properties localProp;
621         localProp = MdsalHelper.toProperties(parms, serviceData);
622
623         if (LOG.isDebugEnabled()) {
624             LOG.debug("Parameters passed to SLI");
625
626             for (Object key : localProp.keySet()) {
627                 String parmName = (String) key;
628                 String parmValue = localProp.getProperty(parmName);
629
630                 LOG.debug(parmName + " = " + parmValue);
631
632             }
633         }
634
635         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
636
637         if (LOG.isDebugEnabled()) {
638             LOG.debug("Parameters returned by SLI");
639
640             for (Object key : respProps.keySet()) {
641                 String parmName = (String) key;
642                 String parmValue = respProps.getProperty(parmName);
643
644                 LOG.debug(parmName + " = " + parmValue);
645
646             }
647         }
648         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
649             return respProps;
650         }
651
652         MdsalHelper.toBuilder(respProps, serviceData);
653
654         return respProps;
655     }
656
657
658
659 }