2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.sdnc.vnfapi;
24 import java.util.Properties;
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;
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;
41 public class VNFSDNSvcLogicServiceClient {
43 private static final Logger LOG = LoggerFactory
44 .getLogger(VNFSDNSvcLogicServiceClient.class);
46 private SvcLogicService svcLogic = null;
48 public VNFSDNSvcLogicServiceClient()
50 BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
52 // Get SvcLogicService reference
53 ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
56 svcLogic = (SvcLogicService) bctx.getService(sref);
61 LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
66 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
68 return(svcLogic.hasGraph(module, rpc, version, mode));
71 public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData)
72 throws SvcLogicException {
74 Properties parms = new Properties();
76 return execute(module,rpc,version, mode,serviceData,parms);
79 public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData)
80 throws SvcLogicException {
82 Properties parms = new Properties();
84 return execute(module,rpc,version, mode,serviceData,parms);
88 public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData, Properties parms)
89 throws SvcLogicException {
91 parms = VnfSdnUtil.toProperties(parms, serviceData);
93 if (LOG.isDebugEnabled())
95 LOG.debug("Parameters passed to SLI");
97 for (Object key : parms.keySet()) {
98 String parmName = (String) key;
99 String parmValue = parms.getProperty(parmName);
101 LOG.debug(parmName+" = "+parmValue);
106 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
108 if (LOG.isDebugEnabled())
110 LOG.debug("Parameters returned by SLI");
112 for (Object key : respProps.keySet()) {
113 String parmName = (String) key;
114 String parmValue = respProps.getProperty(parmName);
116 LOG.debug(parmName+" = "+parmValue);
120 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
124 VnfSdnUtil.toBuilder(respProps, serviceData);
130 public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData, Properties parms)
131 throws SvcLogicException {
133 parms = VnfSdnUtil.toProperties(parms, serviceData);
135 if (LOG.isDebugEnabled())
137 LOG.debug("Parameters passed to SLI");
139 for (Object key : parms.keySet()) {
140 String parmName = (String) key;
141 String parmValue = parms.getProperty(parmName);
143 LOG.debug(parmName+" = "+parmValue);
148 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
150 if (LOG.isDebugEnabled())
152 LOG.debug("Parameters returned by SLI");
154 for (Object key : respProps.keySet()) {
155 String parmName = (String) key;
156 String parmValue = respProps.getProperty(parmName);
158 LOG.debug(parmName+" = "+parmValue);
162 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
166 VnfSdnUtil.toBuilder(respProps, serviceData);
173 public Properties execute(String module, String rpc, String version, String mode, VnfInstanceServiceDataBuilder serviceData)
174 throws SvcLogicException {
176 Properties parms = new Properties();
178 return execute(module,rpc,version, mode,serviceData,parms);
182 public Properties execute(String module, String rpc, String version, String mode, VnfInstanceServiceDataBuilder serviceData, Properties parms)
183 throws SvcLogicException {
185 parms = VnfSdnUtil.toProperties(parms, serviceData);
187 if (LOG.isDebugEnabled())
189 LOG.debug("Parameters passed to SLI");
191 for (Object key : parms.keySet()) {
192 String parmName = (String) key;
193 String parmValue = parms.getProperty(parmName);
195 LOG.debug(parmName+" = "+parmValue);
200 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
202 if (LOG.isDebugEnabled())
204 LOG.debug("Parameters returned by SLI");
206 for (Object key : respProps.keySet()) {
207 String parmName = (String) key;
208 String parmValue = respProps.getProperty(parmName);
210 LOG.debug(parmName+" = "+parmValue);
214 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
218 VnfSdnUtil.toBuilder(respProps, serviceData);
224 public Properties execute(String module, String rpc, String version, String mode, VfModuleServiceDataBuilder serviceData)
225 throws SvcLogicException {
227 Properties parms = new Properties();
229 return execute(module,rpc,version, mode,serviceData,parms);
233 public Properties execute(String module, String rpc, String version, String mode, VfModuleServiceDataBuilder serviceData, Properties parms)
234 throws SvcLogicException {
236 parms = VnfSdnUtil.toProperties(parms, serviceData);
238 if (LOG.isDebugEnabled())
240 LOG.debug("Parameters passed to SLI");
242 for (Object key : parms.keySet()) {
243 String parmName = (String) key;
244 String parmValue = parms.getProperty(parmName);
246 LOG.debug(parmName+" = "+parmValue);
251 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
253 if (LOG.isDebugEnabled())
255 LOG.debug("Parameters returned by SLI");
257 for (Object key : respProps.keySet()) {
258 String parmName = (String) key;
259 String parmValue = respProps.getProperty(parmName);
261 LOG.debug(parmName+" = "+parmValue);
265 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
269 VnfSdnUtil.toBuilder(respProps, serviceData);
274 //1610 vnf-instance-preload
275 public Properties execute(String module, String rpc, String version, String mode, VnfInstancePreloadDataBuilder serviceData)
276 throws SvcLogicException {
278 Properties parms = new Properties();
280 return execute(module,rpc,version, mode,serviceData,parms);
284 //1610 vnf-instance-preload
285 public Properties execute(String module, String rpc, String version, String mode, VnfInstancePreloadDataBuilder serviceData, Properties parms)
286 throws SvcLogicException {
288 parms = VnfSdnUtil.toProperties(parms, serviceData);
290 if (LOG.isDebugEnabled())
292 LOG.debug("Parameters passed to SLI");
294 for (Object key : parms.keySet()) {
295 String parmName = (String) key;
296 String parmValue = parms.getProperty(parmName);
298 LOG.debug(parmName+" = "+parmValue);
303 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
305 if (LOG.isDebugEnabled())
307 LOG.debug("Parameters returned by SLI");
309 for (Object key : respProps.keySet()) {
310 String parmName = (String) key;
311 String parmValue = respProps.getProperty(parmName);
313 LOG.debug(parmName+" = "+parmValue);
317 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
321 VnfSdnUtil.toBuilder(respProps, serviceData);
326 //1610 vf-module-preload
327 public Properties execute(String module, String rpc, String version, String mode, VfModulePreloadDataBuilder serviceData)
328 throws SvcLogicException {
330 Properties parms = new Properties();
332 return execute(module,rpc,version, mode,serviceData,parms);
336 //1610 vf-module-preload
337 public Properties execute(String module, String rpc, String version, String mode, VfModulePreloadDataBuilder serviceData, Properties parms)
338 throws SvcLogicException {
340 parms = VnfSdnUtil.toProperties(parms, serviceData);
342 if (LOG.isDebugEnabled())
344 LOG.debug("Parameters passed to SLI");
346 for (Object key : parms.keySet()) {
347 String parmName = (String) key;
348 String parmValue = parms.getProperty(parmName);
350 LOG.debug(parmName+" = "+parmValue);
355 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
357 if (LOG.isDebugEnabled())
359 LOG.debug("Parameters returned by SLI");
361 for (Object key : respProps.keySet()) {
362 String parmName = (String) key;
363 String parmValue = respProps.getProperty(parmName);
365 LOG.debug(parmName+" = "+parmValue);
369 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
373 VnfSdnUtil.toBuilder(respProps, serviceData);