0e28727bcae49c7da23ac11bd579fbe4c1ff5815
[appc.git] / appc-outbound / appc-aai-client / provider / src / main / java / org / onap / appc / aai / client / node / AAIResourceNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
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  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.aai.client.node;
26
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import java.util.ArrayList;
30 import java.util.Collections;
31 import java.util.Comparator;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Map.Entry;
36 import org.apache.commons.lang3.StringUtils;
37 import org.onap.appc.aai.client.AppcAaiClientConstant;
38 import org.onap.appc.aai.client.aai.AaiService;
39 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
42
43 public class AAIResourceNode implements SvcLogicJavaPlugin {
44
45     private static final EELFLogger log = EELFManager.getInstance().getLogger(AAIResourceNode.class);
46
47     private static final String STR_VSERVER_ID = "].vserver-id";
48     private static final String STR_TENANT_ID = "].tenant-id";
49     private static final String STR_CLOUD_OWNER = "].cloud-owner";
50     private static final String STR_CLOUD_REGION_ID = "].cloud-region-id";
51     private static final String STR_TMP_VNF_INFO = "tmp.vnfInfo.vm[";
52
53     private static final String PARAM_VSERVER_ID = "vserverId";
54     private static final String PARAM_TENANT_ID = "tenantId";
55     private static final String PARAM_CLOUD_OWNER = "cloudOwner";
56     private static final String PARAM_CLOUD_REGION_ID = "cloudRegionId";
57     private static final String PARAM_VSERVER_NAME = "vserver-name";
58     private static final String PARAM_VNFC_NAME = "vnfcName";
59
60     private static final String ATTR_VNF_VM_COUNT = "vnf.vm-count";
61
62     public AaiService getAaiService() {
63         return new AaiService();
64     }
65
66     /* Gets VNF Info and All VServers associated with Vnf */
67     public void getVnfInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
68
69         log.info("Received getVnfInfo call with params : " + inParams);
70
71         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
72
73         try {
74
75             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
76             AaiService aai = getAaiService();
77             aai.getGenericVnfInfo(inParams, ctx);
78
79             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
80                 AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
81             log.info("getVnfInfo Successful ");
82         } catch (Exception e) {
83             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
84                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
85             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
86             log.error("Failed in getVnfInfo", e);
87
88             throw new SvcLogicException(e.getMessage());
89         }
90     }
91
92
93     public void getAllVServersVnfcsInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
94
95         log.info("Received getAllVServersVnfcsInfo call with params : " + inParams);
96
97         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
98
99         try {
100             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
101             AaiService aai = getAaiService();
102
103             ArrayList<Map<String, String>> vservers = new ArrayList<>();
104
105             int vmWithNoVnfcsCount = 0;
106             String vmCountStr = ctx.getAttribute(responsePrefix + "vm-count");
107
108             if (vmCountStr == null) {
109                 throw new ResourceNodeInternalException("Unable to get VServers for the VNF");
110             }
111
112             int vmCount = Integer.parseInt(vmCountStr);
113             for (int i = 0; i < vmCount; i++) {
114
115                 SvcLogicContext vmServerCtx = new SvcLogicContext();
116
117                 Map<String, String> paramsVm = new HashMap<String, String>();
118                 paramsVm.put(PARAM_VSERVER_ID, ctx.getAttribute(responsePrefix + "vm[" + i + STR_VSERVER_ID));
119                 paramsVm.put(PARAM_TENANT_ID, ctx.getAttribute(responsePrefix + "vm[" + i + STR_TENANT_ID));
120                 paramsVm.put(PARAM_CLOUD_OWNER, ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_OWNER));
121                 paramsVm.put(PARAM_CLOUD_REGION_ID, ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_REGION_ID));
122                 paramsVm.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
123                     inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
124
125                 aai.getVMInfo(paramsVm, vmServerCtx);
126
127                 HashMap<String, String> vserverMap = new HashMap<String, String>();
128                 vserverMap.put("vserver-id", ctx.getAttribute(responsePrefix + "vm[" + i + STR_VSERVER_ID));
129                 vserverMap.put("tenant-id", ctx.getAttribute(responsePrefix + "vm[" + i + STR_TENANT_ID));
130                 vserverMap.put("cloud-owner", ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_OWNER));
131                 vserverMap.put("cloud-region-id", ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_REGION_ID));
132
133                 // Parameters returned by getVMInfo
134                 vserverMap.put(PARAM_VSERVER_NAME, vmServerCtx.getAttribute(responsePrefix + "vm.vserver-name"));
135                 vserverMap.put("vf-module-id", vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id"));
136
137                 // as Per 17.07 requirements we are supporting only one VNFC per VM.
138
139                 String vnfcName = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
140                 vserverMap.put("vnfc-name", vnfcName);
141
142                 String vnfcCount = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc-count");
143                 if (vnfcCount == null) {
144                     vnfcCount = "0";
145                 }
146
147                 vserverMap.put("vnfc-count", vnfcCount);
148
149                 if (vnfcName != null) {
150                     Map<String, String> paramsVnfc = new HashMap<String, String>();
151                     paramsVnfc.put(PARAM_VNFC_NAME, vnfcName);
152
153                     paramsVnfc.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
154                         inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
155
156                     SvcLogicContext vnfcCtx = new SvcLogicContext();
157
158                     aai.getVnfcInfo(paramsVnfc, vnfcCtx);
159
160                     vserverMap.put("vnfc-type", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type"));
161                     vserverMap
162                         .put("vnfc-function-code", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code"));
163                     vserverMap.put("group-notation", vnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation"));
164                     vserverMap.put("vnfc-ipaddress-v4-oam-vip",
165                         vnfcCtx.getAttribute(responsePrefix + "vnfc.ipaddress-v4-oam-vip"));
166
167                 } else {
168                     vmWithNoVnfcsCount++;
169                 }
170                 vservers.add(vserverMap);
171
172             } // vmCount
173
174             Collections.sort(vservers, Comparator.comparing(o -> o.get(PARAM_VSERVER_NAME)));
175
176             log.info("SORTED VSERVERS " + vservers.toString());
177
178             populateContext(vservers, ctx, responsePrefix);
179
180             log.info("VMCOUNT IN GETALLVSERVERS " + vmCount);
181             log.info("VMSWITHNOVNFCSCOUNT IN GETALLVSERVERS " + vmWithNoVnfcsCount);
182             ctx.setAttribute(responsePrefix + ATTR_VNF_VM_COUNT, String.valueOf(vmCount));
183             ctx.setAttribute(responsePrefix + "vnf.vm-with-no-vnfcs-count", String.valueOf(vmWithNoVnfcsCount));
184
185
186         } catch (Exception e) {
187             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
188                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
189             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
190             log.error("Failed in getAllVServersVnfcsInfo", e);
191
192             throw new SvcLogicException(e.getMessage());
193         }
194     }
195
196     public void populateContext(List<Map<String, String>> vservers, SvcLogicContext ctx, String prefix) {
197
198         log.info("Populating Final Context");
199         int counter = 0;
200
201         for (Map<String, String> input : vservers) {
202             for (Entry<String, String> entry : input.entrySet()) {
203
204                 ctx.setAttribute(prefix + "vm[" + counter + "]." + entry.getKey(), entry.getValue());
205                 log.info("Populating Context Key = " + prefix + "vm[" + counter + "]." + entry.getKey() + " Value = " + entry.getValue());
206             }
207             counter++;
208         }
209
210         String firstVServerName = null;
211         for (int i = 0; i < counter; i++) {
212             String vnfcName = ctx.getAttribute(prefix + "vm[" + i + "].vnfc-name");
213             log.info("VNFCNAME " + i + vnfcName);
214             if (vnfcName == null && firstVServerName == null) {
215                 firstVServerName = ctx.getAttribute(prefix + "vm[" + i + "].vserver-name");
216                 ctx.setAttribute("vm-name", firstVServerName);
217                 log.info("Populating Context Key = " + "vm-name" + " Value = " + firstVServerName);
218             }
219         }
220     }
221
222
223     public void addVnfcs(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
224
225         log.info("Received addVnfcs call with params : " + inParams);
226
227         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
228
229         int vnfcRefLen;
230         int vmCount;
231         int vmWithNoVnfcCount = 0;
232
233         try {
234
235             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
236             AaiService aai = getAaiService();
237
238             //no:of vnfcs from the vnfc_reference table
239             String vnfcRefLenStr = ctx.getAttribute("vnfcReference_length");
240
241             vnfcRefLen = trySetVnfcRefLen(vnfcRefLenStr);
242
243             //Vms without vnfc from A&AI
244             String vmWithNoVnfcCountStr = ctx.getAttribute(responsePrefix + "vnf.vm-with-no-vnfcs-count");
245
246             // Modified for 1710
247             if (vmWithNoVnfcCountStr == null) {
248                 log.info("Parameter VM without VNFCs(vmWithNoVnfcCountStr) from A&AI is Null");
249             } else {
250                 vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr);
251             }
252
253             log.info("No of VM without VNFCs(vmWithNoVnfcCount) from A&AI is " + vmWithNoVnfcCount);
254
255             String vmCountStr = ctx.getAttribute(responsePrefix + ATTR_VNF_VM_COUNT);
256
257             if (vmCountStr == null) {
258                 throw new ResourceNodeInternalException("VM data from A&AI is missing");
259             } else {
260                 vmCount = Integer.parseInt(vmCountStr);
261             }
262             if (vmCount < vnfcRefLen) {
263                 throw new ResourceNodeInternalException("Vnfc and VM count mismatch");
264             }
265
266             log.info("VMCOUNT " + vmCount);
267             log.info("VNFCREFLEN " + vnfcRefLen);
268             if (StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) {
269                 aai.updateVnfStatusWithOAMAddress(inParams, ctx);
270             }
271
272             aai.insertVnfcs(inParams, ctx, vnfcRefLen, vmCount);
273
274             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
275                 AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
276
277             log.info("addVnfcs Successful ");
278         } catch (Exception e) {
279             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
280                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
281             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
282             log.error("Failed in addVnfcs", e);
283
284             throw new SvcLogicException(e.getMessage());
285         }
286     }
287
288     private int trySetVnfcRefLen(String vnfcRefLenStr) throws ResourceNodeInternalException {
289
290         if (vnfcRefLenStr == null) {
291             log.info("Vnfc Reference data is missing");
292             throw new ResourceNodeInternalException("Vnfc Reference data is missing");
293
294         } else {
295             return Integer.parseInt(vnfcRefLenStr);
296         }
297     }
298
299
300     public void updateVnfAndVServerStatus(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
301
302         log.info("Received updateVnfAndVServerStatus call with params : " + inParams);
303
304         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
305
306         int vmCount;
307
308         try {
309
310             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
311             AaiService aai = getAaiService();
312
313             String vmCountStr = ctx.getAttribute(responsePrefix + ATTR_VNF_VM_COUNT);
314
315             if (vmCountStr == null) {
316                 throw new ResourceNodeInternalException("VM data from A&AI is missing");
317             } else {
318                 vmCount = Integer.parseInt(vmCountStr);
319             }
320
321             log.info("VMCOUNT " + vmCount);
322
323             aai.updateVnfStatus(inParams, ctx);
324             aai.updateVServerStatus(inParams, ctx, vmCount);
325
326             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
327                 AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
328
329             log.info("updateVnfAndVServerStatus Successful ");
330         } catch (Exception e) {
331             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
332                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
333             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
334             log.error("Failed in updateVnfAndVServerStatus", e);
335
336             throw new SvcLogicException(e.getMessage());
337         }
338     }
339
340     public void getVserverInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
341         log.info("getVserverInfo()::Retrieving vm and vnfc information for vserver:" + inParams.toString());
342         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
343         try {
344             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
345             AaiService aaiService = getAaiService();
346             String vServerId = inParams.get(PARAM_VSERVER_ID);
347             Map<String, String> params = setVmParams(ctx, vServerId);
348             Map<String, String> vnfcParams = new HashMap<>();
349             if (null == params) {
350                 log.error("getVserverInfo()::No Vm Info found!!");
351                 throw new SvcLogicException("No Vm Info in Context");
352             }
353             params.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
354                 inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
355             SvcLogicContext newVmCtx = new SvcLogicContext();
356             aaiService.getVMInfo(params, newVmCtx);
357
358             String vnfcName = newVmCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
359             log.info("getVnfcFunctionCodeForVserver()::vnfcName=" + vnfcName);
360             SvcLogicContext newVnfcCtx = new SvcLogicContext();
361             if (StringUtils.isNotBlank(vnfcName)) {
362                 vnfcParams.put(PARAM_VNFC_NAME, vnfcName);
363             } else {
364                 log.info("getVserverInfo()::vnfc Name is blank, not setting vnfc info !!!!");
365                 return;
366             }
367             getVnfcInformationForVserver(vnfcParams, newVnfcCtx, inParams, ctx, aaiService, responsePrefix);
368         } catch (Exception e) {
369             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
370                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
371             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
372             log.error("Failed in getVserverInfo", e);
373         }
374     }
375
376     private void getVnfcInformationForVserver(Map<String, String> vnfcParams, SvcLogicContext newVnfcCtx,
377         Map<String, String> inParams, SvcLogicContext ctx, AaiService aaiService, String responsePrefix)
378         throws Exception {
379         log.info("getVnfcInformationForVserver()::vnfcParams:" + vnfcParams.toString());
380         vnfcParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
381             inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
382
383         aaiService.getVnfcInfo(vnfcParams, newVnfcCtx);
384
385         String vnfcType = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type");
386         String vnfcFunctionCode = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code");
387         String vnfcGroupNotation = newVnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation");
388         String vnfcV4OamIp = newVnfcCtx.getAttribute(responsePrefix + "vnfc.ipaddress-v4-oam-vip");
389
390         if (StringUtils.isBlank(vnfcType) || StringUtils.isBlank(vnfcFunctionCode)
391             || StringUtils.isBlank(vnfcGroupNotation) || StringUtils.isBlank(vnfcV4OamIp)) {
392             log.info("getVnfcInformationForVserver()::Some vnfc parameters are blank!!!!");
393         }
394         log.info("getVnfcInformationForVserver()::vnfcType=" + vnfcType + ",vnfcFunctionCode=" + vnfcFunctionCode,
395             ", vnfc-ipaddress-v4-oam-vip=" + vnfcV4OamIp);
396         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-name", vnfcParams.get(PARAM_VNFC_NAME));
397         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-type", vnfcType);
398         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-function-code", vnfcFunctionCode);
399         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-group-notation", vnfcGroupNotation);
400         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-ipaddress-v4-oam-vip", vnfcV4OamIp);
401     }
402
403     private Map<String, String> setVmParams(SvcLogicContext ctx, String vServerId) {
404         log.info("setVmParams()::setVmParamsVM level action:" + vServerId);
405         Map<String, String> params = new HashMap<>();
406         int vmCount = 0;
407         int arrayIndex = -1;
408         String vmCountStr = ctx.getAttribute("tmp.vnfInfo.vm-count");
409         if (StringUtils.isNotBlank(vmCountStr)) {
410             vmCount = Integer.parseInt(vmCountStr);
411         }
412         for (int cnt = 0; cnt < vmCount; cnt++) {
413             String vsId = ctx.getAttribute(STR_TMP_VNF_INFO + cnt + STR_VSERVER_ID);
414             log.info("setVmParams():::vserver details::" + cnt + ":" + vsId);
415             if (StringUtils.equals(vServerId, vsId)) {
416                 arrayIndex = cnt;
417             }
418         }
419         if (arrayIndex < 0) {
420             log.info("setVmParams()::VserverId not found in context!! Returning null for params!!");
421             return null;
422         }
423         String tenantId = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_TENANT_ID);
424         String cloudOwner = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_CLOUD_OWNER);
425         String cloudRegionId = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_CLOUD_REGION_ID);
426         log.info("setVmParams()::tenantId=" + tenantId + " cloudOwner=" + cloudOwner + " cloudRegiodId= "
427             + cloudRegionId);
428         params.put(PARAM_VSERVER_ID, vServerId);
429         params.put(PARAM_TENANT_ID, tenantId);
430         params.put(PARAM_CLOUD_OWNER, cloudOwner);
431         params.put(PARAM_CLOUD_REGION_ID, cloudRegionId);
432         log.info("setVmParams()::setVmParamsVM level action:" + params.toString());
433         return params;
434     }
435
436     public void getVfModuleModelInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
437         log.info("vfModuleInfo()::Retrieving vf-module information :" + inParams.toString());
438         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
439         try {
440             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
441             AaiService aaiService = getAaiService();
442             processForVfModuleModelInfo(aaiService,inParams,ctx);
443         } catch (Exception e) {
444             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
445                 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
446             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
447             log.error("Failed in vfModuleInfo", e);
448         }
449     }
450
451     public void processForVfModuleModelInfo(AaiService aaiService, Map<String, String> inParams, SvcLogicContext ctx) {
452         log.info("processForVfModuleModelInfo()::Retrieving vf-module information :" + inParams.toString());
453         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
454         try {
455             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
456             Map<String, String> params = new HashMap<>();
457             params.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
458                 inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
459             params.put("vnfId", inParams.get("vnf-id"));
460             params.put("vfModuleId", inParams.get("vf-module-id"));
461             SvcLogicContext vfModuleCtx = new SvcLogicContext();
462             aaiService.getVfModuleInfo(params, vfModuleCtx);
463
464             String modelInvariantId = vfModuleCtx.getAttribute(responsePrefix + "vfModule.model-invariant-id");
465             String modelVersionId = vfModuleCtx.getAttribute(responsePrefix + "vfModule.model-version-id");
466             log.info("processForVfModuleModelInfo()::modelInvariantId=" + modelInvariantId+",modelVersionId="+modelVersionId);
467
468             Map<String, String> modelParams = new HashMap<>();
469             modelParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
470                     inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
471             SvcLogicContext modelCtx = new SvcLogicContext();
472             if (StringUtils.isNotBlank(modelInvariantId) && StringUtils.isNotBlank(modelVersionId)) {
473                 modelParams.put("model-invariant-id", modelInvariantId);
474                 modelParams.put("model-version-id", modelVersionId);
475
476             } else {
477                 log.info("processForVfModuleModelInfo()::model-invariant-id or model-version-id is blank, not getting model info !!!!");
478                 return;
479             }
480             aaiService.getModelVersionInfo(modelParams,modelCtx);
481             String modelName = modelCtx.getAttribute(responsePrefix+"vfModule.model-name");
482             log.info("processForVfModuleModelInfo()::modelName for vfModule:::"+modelName);
483             log.info("Setting context template-model-id as :::"+modelName);
484             ctx.setAttribute("template-model-id", modelName);
485             log.info("processForVfModuleModelInfo() ::: End");
486             }
487             catch (Exception e) {
488                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
489                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
490                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
491                 log.error("Failed in vfModuleInfo", e);
492             }
493
494 }
495 }