aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/db/DGGeneralDBService.java
blob: c1ef008947fbbdedd11e6c0eca930f4bf8ced862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
/*-
 * ============LICENSE_START=======================================================
 * ONAP : APPC
 * ================================================================================
 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Copyright (C) 2017 Amdocs
 * =============================================================================
 * Modifications Copyright (C) 2019 IBM.
 * =============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * ============LICENSE_END=========================================================
 */
package org.onap.appc.data.services.db;

import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;

public class DGGeneralDBService {

    private static final EELFLogger log = EELFManager.getInstance().getLogger(DGGeneralDBService.class);
    //private SvcLogicResource serviceLogic;
    private DbLibServiceQueries dblib;
    private static DGGeneralDBService dgGeneralDBService = null;

    public static DGGeneralDBService initialise() {

        if (dgGeneralDBService == null) {
            dgGeneralDBService = new DGGeneralDBService();
        }
        return dgGeneralDBService;
    }

    private DGGeneralDBService() {
        if (dblib == null) {
            dblib = new DbLibServiceQueries();
        }
    }

    protected DGGeneralDBService(DbLibService dbLibService) {
        if (dblib == null) {
            dblib = new DbLibServiceQueries(dbLibService);
        }
    }
    
    protected DGGeneralDBService(DbLibServiceQueries dbLibServiceQueries) {
        if (dblib == null) {
            dblib = dbLibServiceQueries;
        }
    }

    public QueryStatus getDeviceProtocolByVnfType(SvcLogicContext ctx, String prefix) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * FROM DEVICE_INTERFACE_PROTOCOL WHERE vnf_type = $vnf-type ;";
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getDeviceAuthenticationByVnfType(SvcLogicContext ctx, String prefix) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * FROM DEVICE_AUTHENTICATION WHERE vnf_type = $vnf-type ;";
            status = dblib.query(key, prefix, ctx);

        }
        return status;
    }

    public QueryStatus getConfigFileReferenceByVnfType(SvcLogicContext ctx, String prefix) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * FROM CONFIG_FILE_REFERENCE WHERE vnf_type = $vnf-type ;";
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getConfigFileReferenceByFileTypeNVnfType(SvcLogicContext ctx, String prefix, String fileType)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-type", fileType);
            String key = "SELECT * FROM CONFIG_FILE_REFERENCE  WHERE file_type = $file-type"
                    + " and vnf_type = $vnf-type ;";
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getTemplate(SvcLogicContext ctx, String prefix, String fileCategory) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = ( SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category AND action =  $request-action "
                    + " AND vnf_type =  $vnf-type  " + " AND vnfc_type =   $vnfc-type ) ; ";
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getTemplateByVnfTypeNAction(SvcLogicContext ctx, String prefix, String fileCategory)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = (SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category AND action =  $request-action "
                    + " AND vnf_type =  $vnf-type ) ; ";
            status = dblib.query(key, prefix, ctx);

        }
        return status;
    }

    public QueryStatus getTemplateByVnfType(SvcLogicContext ctx, String prefix, String fileCategory)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = (SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category AND vnf_type =  $vnf-type ) ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getTemplateByTemplateName(SvcLogicContext ctx, String prefix, String templateName)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("template-name", templateName);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = (SELECT MAX(asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS  " + " WHERE artifact_name = $template-name ) ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getConfigureActionDGByVnfTypeNAction(SvcLogicContext ctx, String prefix)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * " + " FROM CONFIGURE_ACTION_DG "
                    + " where vnf_type = $vnf-type and action = $request-action ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getConfigureActionDGByVnfType(SvcLogicContext ctx, String prefix) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * " + " FROM CONFIGURE_ACTION_DG "
                    + " where vnf_type = $vnf-type and action IS NULL ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getMaxConfigFileId(SvcLogicContext ctx, String prefix, String fileCategory)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            String key = "SELECT MAX(config_file_id) configfileid " + " FROM CONFIGFILES " + " WHERE file_category = "
                    + "$file-category AND vnf_id =  $vnf-id  AND vm_name = $vm-name ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus saveConfigFiles(SvcLogicContext ctx, String prefix) throws SvcLogicException {

        QueryStatus status = null;

        if (dblib != null && ctx != null) {
            String key = "INSERT INTO CONFIGFILES " + " SET data_source        = $data-source , "
                    + " service_instance_id =  $service-instance-id ," + " action              =   $request-action ,"
                    + " vnf_type            =     $vnf-type ," + " vnfc_type           =     $vnfc-type ,"
                    + " vnf_id              =   $vnf-id , " + " vnf_name            =   $vnf-name ,"
                    + " vm_name            =   $vm-name ," + " file_category         =  $file-category ,"
                    + " file_content        =  $file-content ; ";

            status = dblib.save(key, ctx);

        }
        return status;

    }

    public QueryStatus savePrepareRelationship(SvcLogicContext ctx, String prefix, String fileId, String sdcInd)
            throws SvcLogicException {

        QueryStatus status = null;
        String key = null;

        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-id", fileId);
            if ("Y".equals(sdcInd))

                key = "INSERT INTO PREPARE_FILE_RELATIONSHIP " + " SET service_instance_id =  $service-instance-id , "
                        + "   request_id         = $request-id , " + "  asdc_artifacts_id        =  $file-id ;";
            else
                key = "INSERT INTO PREPARE_FILE_RELATIONSHIP " + " SET service_instance_id =  $service-instance-id , "
                        + "   request_id         = $request-id , " + "  config_file_id        =  $file-id ;";

            status = dblib.save(key, ctx);

            log.info("DGGeneralDBService.savePrepareRelationship()" + ctx.getAttributeKeySet());
        }
        return status;

    }

    public void cleanContextPropertyByPrefix(SvcLogicContext ctx, String prefix) {
        if (ctx != null && ctx.getAttributeKeySet() != null && StringUtils.isNotBlank(prefix)) {

            Set<String> keySet = ctx.getAttributeKeySet();
            for (String key : keySet) {
              //By default, context property prefixed with dot.
                if (StringUtils.isNotBlank(key) && key.startsWith(".")) {
                    ctx.getAttributeKeySet().remove(key);
                }
            }
        }
    }

    public QueryStatus saveUploadConfig(SvcLogicContext ctx, String prefix) throws SvcLogicException {

        QueryStatus status = null;

        if (dblib != null && ctx != null) {
            String key = "INSERT INTO UPLOAD_CONFIG " + " SET request_id = $request-id , "
                    + " action = $request-action , " + " originator_id = $originator-id , " + " vnf_id =  $vnf-id , "
                    + " vnf_name = $vnf-name ,  " + " vm_name =  $vm-name ,  "
                    + " host_ip_address = $vnf-host-ip-address , " + " vnf_type            =     $vnf-type , "
                    + " vnfc_type           =     $vnfc-type , " + " config_indicator         =  'Current' , "
                    + " content        =  $tmp.escaped.devicerunningconfig ; ";

            status = dblib.save(key, ctx);

            log.info("DGGeneralDBService.saveUploadConfig()" + ctx.getAttributeKeySet());

        }
        return status;

    }

    /*public QueryStatus getMaxUploadConfigFileId(SvcLogicContext ctx, String prefix) throws SvcLogicException {
        QueryStatus status = null;
        if (serviceLogic != null && ctx != null) {
            String key = "SELECT MAX(upload_config_id) uploadconfigid " + " FROM UPLOAD_CONFIG "
                    + " WHERE vnf_id =  $vnf-id  AND vm_name = $vm-name ; ";

            status = serviceLogic.query("SQL", false, null, key, prefix, null, ctx);
            log.info("DGGeneralDBService.getMaxUploadConfigFileId()" + ctx.getAttributeKeySet());
        }
        return status;
    }*/

    public QueryStatus updateUploadConfig(SvcLogicContext ctx, String prefix, int maxId) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "UPDATE UPLOAD_CONFIG " + " SET  config_indicator         =  null "
                    + " WHERE upload_config_id != " + maxId + " AND config_indicator         =  'Current' "
                    + " AND vnf_id = $vnf-id " + " AND vnfc_type =  $vnfc-type ; ";

            status = dblib.save(key, ctx);

            log.info("DGGeneralDBService.updateUploadConfig()" + ctx.getAttributeKeySet());

        }
        return status;

    }


    public QueryStatus getTemplateByArtifactType(SvcLogicContext ctx, String prefix, String fileCategory, String artifactType)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            ctx.setAttribute("artifact-type", artifactType);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = (SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category  AND action =  $request-action "
                    + " AND artifactType =  $artifact-type  AND vnf_type =  $vnf-type ) ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }


    public QueryStatus getConfigFilesByVnfVmNCategory(SvcLogicContext ctx, String prefix, String fileCategory, String vnfId, String vmName)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            ctx.setAttribute("vnf-id", vnfId);
            ctx.setAttribute("vm-name", vmName);
            String key = "SELECT  file_content ,  config_file_id "
                    + " FROM CONFIGFILES "
                    + " WHERE config_file_id = ( SELECT MAX(config_file_id) configfileid " + " FROM CONFIGFILES "
                    + " WHERE file_category = $file-category"
                    + " AND vnf_id =  $vnf-id"
                    + " AND vm_name = $vm-name ) ; ";


            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }


    public QueryStatus getDownloadConfigTemplateByVnf(SvcLogicContext ctx, String prefix)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            String key = "SELECT * FROM DOWNLOAD_CONFIG_TEMPLATE  WHERE vnf_type = $vnf-type ; ";
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }



    public QueryStatus saveConfigTransactionLog(SvcLogicContext ctx, String prefix) throws SvcLogicException {

        QueryStatus status = null;

        if (dblib != null && ctx != null) {

                String key = "INSERT INTO CONFIG_TRANSACTION_LOG " + " SET request_id = $request-id , "
                + " message_type = $log-message-type , "
                + " message = $log-message ;";


                status = dblib.save(key, ctx);


        }
        return status;

    }


    public QueryStatus getVnfcReferenceByVnfcTypeNAction(SvcLogicContext ctx, String prefix)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {

            String key = "SELECT  * "
                    + " FROM VNFC_REFERENCE "
                    + " WHERE vnf_type =  $vnf-type "
                    + " AND vnfc_type = $vnfc-type "
                    + " AND action =  $request-action "
                    + " ORDER BY vm_instance, vnfc_instance ; ";


            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }


    public QueryStatus getVnfcReferenceByVnfTypeNAction(SvcLogicContext ctx, String prefix)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {

            String key = "SELECT  * "
                    + " FROM VNFC_REFERENCE "
                    + " WHERE vnf_type =  $vnf-type "
                    + " AND action =  $request-action   "
                    + " ORDER BY vm_instance, vnfc_instance ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }


    public QueryStatus getUploadConfigInfo(SvcLogicContext ctx, String prefix)
            throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {

            String key = "SELECT  * , UNIX_TIMESTAMP(UPLOAD_DATE) UPLOAD_TIMESTAMP "
                    + " FROM UPLOAD_CONFIG "
                    + " WHERE upload_config_id = " +
                    "( SELECT MAX(upload_config_id) uploadconfigid " + " FROM UPLOAD_CONFIG "
                    + " WHERE vnf_id =  $vnf-id  AND vm_name = $vm-name ) ; ";

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }
     public String getCapability(SvcLogicContext ctx, String vnf_type) throws SvcLogicException {

         //{"capabilities":{"vnfc":[],"vm":[],"vf-module":[],"vnf":["ConfigureTest","ConfigModify","HealthCheck"]}}
         String fn = "getCapability ";
         QueryStatus status = null;
         SvcLogicContext localContext = new SvcLogicContext();
         localContext.setAttribute("vnf-type", vnf_type);
         if (dblib != null) {
                 String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from ASDC_ARTIFACTS " +
                                  " where artifact_name in (select artifact_name from ASDC_REFERENCE  where vnf_type= $vnf-type "  +
                             " and file_category = 'capability' )" ;

                 log.info(fn + "Query String : " + queryString);
                 status = dblib.query(queryString, localContext);

                 if(status.toString().equals("FAILURE"))
                         throw new SvcLogicException("Error - while getting capabilitiesData ");

                 String queryString1 = "select artifact_content from ASDC_ARTIFACTS  "  +
                                 " where artifact_name = $artifactName  and internal_version = $maxInternalVersion ";

                 log.debug(fn + "Query String : " + queryString1);
                 status = dblib.query(queryString1, localContext);
                 if (status.toString().equals("NOT_FOUND"))
                     return null;
                 if(status.toString().equals("FAILURE"))
                         throw new SvcLogicException("Error - while getting capabilitiesData ");
         }

         return localContext.getAttribute("artifact-content");
 }

    public QueryStatus getTemplateWithTemplateModelId(SvcLogicContext ctx, String prefix, String fileCategory,
            String templateModelId) throws SvcLogicException {
        QueryStatus status = null;
        String templatePattern = "%_"+ templateModelId +"%";
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            ctx.setAttribute("template-pattern", templatePattern);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = ( SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category AND action =  $request-action "
                    + " AND vnf_type =  $vnf-type  " + " AND vnfc_type =   $vnfc-type ) and ASDC_ARTIFACTS.artifact_name like "
                    + "$template-pattern ; ";
            log.info("getTemplateWithTemplateModelId()::: with template:::"+ key);

            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

    public QueryStatus getTemplateByVnfTypeNActionWithTemplateModelId(SvcLogicContext ctx, String prefix,
            String fileCategory, String templateModelId) throws SvcLogicException {
        QueryStatus status = null;
        String templatePattern = "%_"+ templateModelId +"%";
        if (dblib != null && ctx != null) {
            ctx.setAttribute("file-category", fileCategory);
            ctx.setAttribute("template-pattern", templatePattern);
            String key = "SELECT artifact_content file_content , asdc_artifacts_id config_file_id "
                    + " FROM ASDC_ARTIFACTS "
                    + " WHERE asdc_artifacts_id = (SELECT MAX(a.asdc_artifacts_id) configfileid  "
                    + " FROM ASDC_ARTIFACTS a, ASDC_REFERENCE b " + " WHERE a.artifact_name = b.artifact_name "
                    + " AND file_category =  $file-category AND action =  $request-action "
                    + " AND vnf_type =  $vnf-type )  and ASDC_ARTIFACTS.artifact_name like "
                    + "$template-pattern ; ";
            log.info("getTemplateByVnfTypeNActionWithTemplateModelId()::: with template:::"+ key);

            status = dblib.query(key, prefix, ctx);
        }
        return status;

    }

    public QueryStatus getVnfcReferenceByVnfTypeNActionWithTemplateModelId(SvcLogicContext ctx, String prefix,
            String templateModelId) throws SvcLogicException {
        QueryStatus status = null;
        if (dblib != null && ctx != null) {
            ctx.setAttribute("template-model-id", templateModelId);
            String key = "SELECT  * "
                    + " FROM VNFC_REFERENCE "
                    + " WHERE vnf_type =  $vnf-type "
                    + " AND action =  $request-action   "
                    + " AND template_id = "
                    + "$template-model-id"
                    + " ORDER BY vm_instance, vnfc_instance ; ";

            log.info("getVnfcReferenceByVnfTypeNActionWithTemplateModelId()::: with template:::"+ key);
            status = dblib.query(key, prefix, ctx);
        }
        return status;
    }

}