2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
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;
44 public class A1AdapterClient {
46 private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
48 private SvcLogicService svcLogicService = null;
50 public A1AdapterClient(final SvcLogicService svcLogicService) {
51 this.svcLogicService = svcLogicService;
54 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
55 return svcLogicService.hasGraph(module, rpc, version, mode);
58 // Client for GetNearRTRICs
60 public Properties execute(String module, String rpc, String version, String mode,
61 GetNearRTRICsOutputBuilder serviceData) throws SvcLogicException {
63 Properties parms = new Properties();
65 return execute(module, rpc, version, mode, serviceData, parms);
68 public Properties execute(String module, String rpc, String version, String mode,
69 GetNearRTRICsOutputBuilder serviceData, Properties parms) throws SvcLogicException {
71 localProp = MdsalHelper.toProperties(parms, serviceData);
73 if (LOG.isDebugEnabled()) {
74 LOG.debug("Parameters passed to SLI");
76 for (Object key : localProp.keySet()) {
77 String parmName = (String) key;
78 String parmValue = localProp.getProperty(parmName);
80 LOG.debug(parmName + " = " + parmValue);
85 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
87 if (LOG.isDebugEnabled()) {
88 LOG.debug("Parameters returned by SLI");
90 for (Object key : respProps.keySet()) {
91 String parmName = (String) key;
92 String parmValue = respProps.getProperty(parmName);
94 LOG.debug(parmName + " = " + parmValue);
98 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
102 MdsalHelper.toBuilder(respProps, serviceData);
107 // Client for GetHealthCheck
109 public Properties execute(String module, String rpc, String version, String mode,
110 GetHealthCheckOutputBuilder serviceData) throws SvcLogicException {
112 Properties parms = new Properties();
114 return execute(module, rpc, version, mode, serviceData, parms);
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);
122 if (LOG.isDebugEnabled()) {
123 LOG.debug("Parameters passed to SLI");
125 for (Object key : localProp.keySet()) {
126 String parmName = (String) key;
127 String parmValue = localProp.getProperty(parmName);
129 LOG.debug(parmName + " = " + parmValue);
134 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
136 if (LOG.isDebugEnabled()) {
137 LOG.debug("Parameters returned by SLI");
139 for (Object key : respProps.keySet()) {
140 String parmName = (String) key;
141 String parmValue = respProps.getProperty(parmName);
143 LOG.debug(parmName + " = " + parmValue);
147 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
151 MdsalHelper.toBuilder(respProps, serviceData);
157 // Client for getPolicyTypes
159 public Properties execute(String module, String rpc, String version, String mode,
160 GetPolicyTypesOutputBuilder serviceData) throws SvcLogicException {
162 Properties parms = new Properties();
164 return execute(module, rpc, version, mode, serviceData, parms);
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);
172 if (LOG.isDebugEnabled()) {
173 LOG.debug("Parameters passed to SLI");
175 for (Object key : localProp.keySet()) {
176 String parmName = (String) key;
177 String parmValue = localProp.getProperty(parmName);
179 LOG.debug(parmName + " = " + parmValue);
184 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
186 if (LOG.isDebugEnabled()) {
187 LOG.debug("Parameters returned by SLI");
189 for (Object key : respProps.keySet()) {
190 String parmName = (String) key;
191 String parmValue = respProps.getProperty(parmName);
193 LOG.debug(parmName + " = " + parmValue);
197 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
201 MdsalHelper.toBuilder(respProps, serviceData);
207 // Client for createPolicyType
210 public Properties execute(String module, String rpc, String version, String mode,
211 CreatePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
213 Properties parms = new Properties();
215 return execute(module, rpc, version, mode, serviceData, parms);
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);
223 if (LOG.isDebugEnabled()) {
224 LOG.debug("Parameters passed to SLI");
226 for (Object key : localProp.keySet()) {
227 String parmName = (String) key;
228 String parmValue = localProp.getProperty(parmName);
230 LOG.debug(parmName + " = " + parmValue);
235 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
237 if (LOG.isDebugEnabled()) {
238 LOG.debug("Parameters returned by SLI");
240 for (Object key : respProps.keySet()) {
241 String parmName = (String) key;
242 String parmValue = respProps.getProperty(parmName);
244 LOG.debug(parmName + " = " + parmValue);
248 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
252 MdsalHelper.toBuilder(respProps, serviceData);
257 // Client for getPolicyType
259 public Properties execute(String module, String rpc, String version, String mode,
260 GetPolicyTypeOutputBuilder serviceData) throws SvcLogicException {
262 Properties parms = new Properties();
264 return execute(module, rpc, version, mode, serviceData, parms);
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);
272 if (LOG.isDebugEnabled()) {
273 LOG.debug("Parameters passed to SLI");
275 for (Object key : localProp.keySet()) {
276 String parmName = (String) key;
277 String parmValue = localProp.getProperty(parmName);
279 LOG.debug(parmName + " = " + parmValue);
284 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
286 if (LOG.isDebugEnabled()) {
287 LOG.debug("Parameters returned by SLI");
289 for (Object key : respProps.keySet()) {
290 String parmName = (String) key;
291 String parmValue = respProps.getProperty(parmName);
293 LOG.debug(parmName + " = " + parmValue);
297 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
301 MdsalHelper.toBuilder(respProps, serviceData);
307 // Client for deletePolicyType
309 public Properties execute(String module, String rpc, String version, String mode,
310 DeletePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
312 Properties parms = new Properties();
314 return execute(module, rpc, version, mode, serviceData, parms);
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);
322 if (LOG.isDebugEnabled()) {
323 LOG.debug("Parameters passed to SLI");
325 for (Object key : localProp.keySet()) {
326 String parmName = (String) key;
327 String parmValue = localProp.getProperty(parmName);
329 LOG.debug(parmName + " = " + parmValue);
334 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
336 if (LOG.isDebugEnabled()) {
337 LOG.debug("Parameters returned by SLI");
339 for (Object key : respProps.keySet()) {
340 String parmName = (String) key;
341 String parmValue = respProps.getProperty(parmName);
343 LOG.debug(parmName + " = " + parmValue);
347 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
351 MdsalHelper.toBuilder(respProps, serviceData);
357 // Client for getPolicyInstances
359 public Properties execute(String module, String rpc, String version, String mode,
360 GetPolicyInstancesOutputBuilder serviceData) throws SvcLogicException {
362 Properties parms = new Properties();
364 return execute(module, rpc, version, mode, serviceData, parms);
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);
372 if (LOG.isDebugEnabled()) {
373 LOG.debug("Parameters passed to SLI");
375 for (Object key : localProp.keySet()) {
376 String parmName = (String) key;
377 String parmValue = localProp.getProperty(parmName);
379 LOG.debug(parmName + " = " + parmValue);
384 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
386 if (LOG.isDebugEnabled()) {
387 LOG.debug("Parameters returned by SLI");
389 for (Object key : respProps.keySet()) {
390 String parmName = (String) key;
391 String parmValue = respProps.getProperty(parmName);
393 LOG.debug(parmName + " = " + parmValue);
397 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
401 MdsalHelper.toBuilder(respProps, serviceData);
408 // Client for createPolicyInstance
410 public Properties execute(String module, String rpc, String version, String mode,
411 CreatePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
413 Properties parms = new Properties();
415 return execute(module, rpc, version, mode, serviceData, parms);
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);
423 if (LOG.isDebugEnabled()) {
424 LOG.debug("Parameters passed to SLI");
426 for (Object key : localProp.keySet()) {
427 String parmName = (String) key;
428 String parmValue = localProp.getProperty(parmName);
430 LOG.debug(parmName + " = " + parmValue);
435 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
437 if (LOG.isDebugEnabled()) {
438 LOG.debug("Parameters returned by SLI");
440 for (Object key : respProps.keySet()) {
441 String parmName = (String) key;
442 String parmValue = respProps.getProperty(parmName);
444 LOG.debug(parmName + " = " + parmValue);
448 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
452 MdsalHelper.toBuilder(respProps, serviceData);
458 // Client for getPolicyInstance
460 public Properties execute(String module, String rpc, String version, String mode,
461 GetPolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
463 Properties parms = new Properties();
465 return execute(module, rpc, version, mode, serviceData, parms);
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);
473 if (LOG.isDebugEnabled()) {
474 LOG.debug("Parameters passed to SLI");
476 for (Object key : localProp.keySet()) {
477 String parmName = (String) key;
478 String parmValue = localProp.getProperty(parmName);
480 LOG.debug(parmName + " = " + parmValue);
485 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
487 if (LOG.isDebugEnabled()) {
488 LOG.debug("Parameters returned by SLI");
490 for (Object key : respProps.keySet()) {
491 String parmName = (String) key;
492 String parmValue = respProps.getProperty(parmName);
494 LOG.debug(parmName + " = " + parmValue);
498 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
502 MdsalHelper.toBuilder(respProps, serviceData);
507 // Client for deletePolicyInstance
509 public Properties execute(String module, String rpc, String version, String mode,
510 DeletePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
512 Properties parms = new Properties();
514 return execute(module, rpc, version, mode, serviceData, parms);
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);
522 if (LOG.isDebugEnabled()) {
523 LOG.debug("Parameters passed to SLI");
525 for (Object key : localProp.keySet()) {
526 String parmName = (String) key;
527 String parmValue = localProp.getProperty(parmName);
529 LOG.debug(parmName + " = " + parmValue);
534 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
536 if (LOG.isDebugEnabled()) {
537 LOG.debug("Parameters returned by SLI");
539 for (Object key : respProps.keySet()) {
540 String parmName = (String) key;
541 String parmValue = respProps.getProperty(parmName);
543 LOG.debug(parmName + " = " + parmValue);
547 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
551 MdsalHelper.toBuilder(respProps, serviceData);
556 // Client for getStatus
559 public Properties execute(String module, String rpc, String version, String mode,
560 GetStatusOutputBuilder serviceData) throws SvcLogicException {
562 Properties parms = new Properties();
564 return execute(module, rpc, version, mode, serviceData, parms);
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);
572 if (LOG.isDebugEnabled()) {
573 LOG.debug("Parameters passed to SLI");
575 for (Object key : localProp.keySet()) {
576 String parmName = (String) key;
577 String parmValue = localProp.getProperty(parmName);
579 LOG.debug(parmName + " = " + parmValue);
584 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
586 if (LOG.isDebugEnabled()) {
587 LOG.debug("Parameters returned by SLI");
589 for (Object key : respProps.keySet()) {
590 String parmName = (String) key;
591 String parmValue = respProps.getProperty(parmName);
593 LOG.debug(parmName + " = " + parmValue);
597 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
601 MdsalHelper.toBuilder(respProps, serviceData);
607 // Client for notifyPolicyEnforcementUpdate
610 public Properties execute(String module, String rpc, String version, String mode,
611 NotifyPolicyEnforcementUpdateOutputBuilder serviceData) throws SvcLogicException {
613 Properties parms = new Properties();
615 return execute(module, rpc, version, mode, serviceData, parms);
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);
623 if (LOG.isDebugEnabled()) {
624 LOG.debug("Parameters passed to SLI");
626 for (Object key : localProp.keySet()) {
627 String parmName = (String) key;
628 String parmValue = localProp.getProperty(parmName);
630 LOG.debug(parmName + " = " + parmValue);
635 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
637 if (LOG.isDebugEnabled()) {
638 LOG.debug("Parameters returned by SLI");
640 for (Object key : respProps.keySet()) {
641 String parmName = (String) key;
642 String parmValue = respProps.getProperty(parmName);
644 LOG.debug(parmName + " = " + parmValue);
648 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
652 MdsalHelper.toBuilder(respProps, serviceData);