92b74dac251d241903bc1d542473c87886899dc3
[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 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 java.io.IOException;
28 import java.util.ArrayList;
29 import java.util.Arrays;
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
36 import org.apache.commons.lang3.StringUtils;
37
38 import org.onap.appc.aai.client.AppcAaiClientConstant;
39 import org.onap.appc.aai.client.aai.AaiService;
40
41
42 import com.att.eelf.configuration.EELFLogger;
43 import com.att.eelf.configuration.EELFManager;
44
45 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
46 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
47 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
48
49 //import com.fasterxml.jackson.databind.ObjectMapper;
50
51
52 public class AAIResourceNode implements SvcLogicJavaPlugin {
53
54     private static final EELFLogger log = EELFManager.getInstance().getLogger(AAIResourceNode.class);
55
56
57     public AaiService getAaiService() {
58         return new AaiService();
59     }
60     /* Gets VNF Info and All VServers associated with Vnf */
61     public void getVnfInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
62
63         log.info("Received getVnfInfo call with params : " + inParams);
64
65         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
66
67         try {
68
69             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
70             AaiService aai = getAaiService();
71             aai.getGenericVnfInfo(inParams,ctx);
72
73             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
74                     AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
75             log.info("getVnfInfo Successful ");
76         } catch (Exception e) {
77             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
78                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
79             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
80             log.error("Failed in getVnfInfo " + e.getMessage());
81
82             throw new SvcLogicException(e.getMessage());
83         }
84     }
85
86
87     public void getAllVServersVnfcsInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
88
89         log.info("Received getAllVServersVnfcsInfo call with params : " + inParams);
90
91         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
92
93         try {
94             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
95             AaiService aai = getAaiService();
96
97
98
99             ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
100
101             int vmWithNoVnfcsCount = 0;
102             String  vmCountStr = ctx.getAttribute(responsePrefix + "vm-count");
103
104             if ( vmCountStr == null )
105                 throw new Exception("Unable to get VServers for the VNF");
106
107             int vmCount = Integer.parseInt(vmCountStr);
108             for ( int i = 0; i < vmCount; i++ ) {
109
110                 SvcLogicContext vmServerCtx = new SvcLogicContext();
111
112                 Map<String, String> paramsVm = new HashMap<String, String>();
113                 paramsVm.put("vserverId", ctx.getAttribute(responsePrefix + "vm[" + i + "].vserver-id"));
114                 paramsVm.put("tenantId", ctx.getAttribute(responsePrefix +"vm[" + i + "].tenant-id"));
115                 paramsVm.put("cloudOwner", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-owner"));
116                 paramsVm.put("cloudRegionId", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-region-id"));
117                 paramsVm.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
118
119
120
121                 aai.getVMInfo(paramsVm, vmServerCtx);
122
123                 HashMap<String, String> vserverMap = new HashMap<String, String>();
124                 vserverMap.put("vserver-id", ctx.getAttribute(responsePrefix + "vm[" + i + "].vserver-id"));
125                 vserverMap.put("tenant-id", ctx.getAttribute(responsePrefix +"vm[" + i + "].tenant-id"));
126                 vserverMap.put("cloud-owner", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-owner"));
127                 vserverMap.put("cloud-region-id", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-region-id"));
128
129                 // Parameters returned by getVMInfo
130                 vserverMap.put("vserver-name", vmServerCtx.getAttribute(responsePrefix + "vm.vserver-name"));
131                 vserverMap.put("vf-module-id", vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id"));
132
133
134                 // as Per 17.07 requirements we are supporting only one VNFC per VM.
135
136                 String vnfcName = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
137                 vserverMap.put("vnfc-name", vnfcName);
138
139
140                 String vnfcCount = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc-count");
141                 if ( vnfcCount == null )
142                     vnfcCount = "0";
143
144                 vserverMap.put("vnfc-count", vnfcCount);
145
146                 if ( vnfcName != null  ) {
147                     Map<String, String> paramsVnfc = new HashMap<String, String>();
148                     paramsVnfc.put("vnfcName", vnfcName);
149
150                     paramsVnfc.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
151
152                     SvcLogicContext vnfcCtx = new SvcLogicContext();
153
154                     aai.getVnfcInfo(paramsVnfc, vnfcCtx);
155
156                     vserverMap.put("vnfc-type", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type"));
157                     vserverMap.put("vnfc-function-code", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code"));
158                     vserverMap.put("group-notation", vnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation"));
159                     vserverMap.put("vnfc-ipaddress-v4-oam-vip", vnfcCtx.getAttribute(responsePrefix + "vnfc.ipaddress-v4-oam-vip"));
160
161                 }
162                 else
163                     vmWithNoVnfcsCount++;
164                 vservers.add(vserverMap);
165
166             } // vmCount
167
168             Collections.sort(vservers, new Comparator<Map<String, String>>() {
169                 @Override
170                 public int compare(Map<String, String> o1, Map<String, String> o2) {
171                     return o1.get("vserver-name").compareTo(o2.get("vserver-name"));
172                 }
173             });
174
175             log.info("SORTED VSERVERS " + vservers.toString());
176
177             populateContext(vservers, ctx, responsePrefix);
178
179             log.info("VMCOUNT IN GETALLVSERVERS " + vmCount);
180             log.info("VMSWITHNOVNFCSCOUNT IN GETALLVSERVERS " + vmWithNoVnfcsCount);
181             ctx.setAttribute(responsePrefix+"vnf.vm-count", String.valueOf(vmCount));
182             ctx.setAttribute(responsePrefix+"vnf.vm-with-no-vnfcs-count", String.valueOf(vmWithNoVnfcsCount));
183
184
185         } catch (Exception e) {
186             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
187                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
188             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
189             log.error("Failed in getAllVServersVnfcsInfo " + e.getMessage());
190
191             throw new SvcLogicException(e.getMessage());
192         }
193     }
194
195     public void populateContext(ArrayList<Map<String, String>> vservers, SvcLogicContext ctx, String prefix) {
196
197
198         log.info("Populating Final Context");
199         int ctr = 0;
200
201         for (Map<String, String> entry : vservers) {
202             for (String key : entry.keySet()) {
203                 String value = entry.get(key);
204
205                    ctx.setAttribute(prefix+ "vm[" + ctr + "]."+ key, value);
206                 log.info("Populating Context Key = " + prefix+ "vm[" + ctr + "]."+ key + " Value = " + value);
207
208             }
209             ctr++;
210         }
211
212         String firstVServerName = null;
213         for  ( int i =0; i < ctr; i++ ) {
214             String vnfcName = ctx.getAttribute(prefix + "vm[" + i + "].vnfc-name");
215             log.info("VNFCNAME " + i + vnfcName);
216             if (  vnfcName == null && firstVServerName == null ) {
217                    firstVServerName = ctx.getAttribute(prefix + "vm[" + i + "].vserver-name");
218                    ctx.setAttribute("vm-name" , firstVServerName);
219                    log.info("Populating Context Key = " +  "vm-name" + " Value = " + firstVServerName);
220             }
221         }
222     }
223
224
225
226     public void addVnfcs(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
227
228         log.info("Received addVnfcs call with params : " + inParams);
229
230         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
231
232         int vnfcRefLen =0 ;
233         int vmCount = 0;
234         int vmWithNoVnfcCount = 0;
235
236         try {
237
238             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
239             AaiService aai = getAaiService();
240
241             //no:of vnfcs from the vnfc_reference table          
242             String vnfcRefLenStr = ctx.getAttribute("vnfcReference_length");
243
244             if ( vnfcRefLenStr == null) {
245                 log.info("Vnfc Reference data is missing");
246                 throw new Exception("Vnfc Reference data is missing");
247
248             }
249             else
250                 vnfcRefLen = Integer.parseInt(vnfcRefLenStr);
251
252             //Vms without vnfc from A&AI
253             String vmWithNoVnfcCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-with-no-vnfcs-count");
254
255       //Commented  for backward compatibility
256
257             /*if ( vmWithNoVnfcCountStr == null) {
258             throw new Exception("VNFCs to be added data from A&AI is missing");
259             //log.info("VNFCs to be added data from A&AI is missing");
260              }
261             else
262                 vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr);
263
264             if ( vmWithNoVnfcCount!= vnfcRefLen )
265                 throw new Exception("Unable to Add Vnfcs to A&AI. Reference data mismatch.");
266
267             String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
268
269             if ( vmCountStr == null)
270                 throw new Exception("VM data from A&AI is missing");
271             else
272                 vmCount = Integer.parseInt(vmCountStr);
273
274
275             log.info("VMCOUNT " + vmCount);
276             log.info("VNFCREFLEN " + vnfcRefLen);
277             aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount);
278
279          */
280
281
282         // Modified for 1710
283
284             if ( vmWithNoVnfcCountStr == null) {
285                 log.info("Parameter VM without VNFCs(vmWithNoVnfcCountStr) from A&AI is Null");
286             }
287             else
288                 vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr);
289
290             log.info("No of VM without VNFCs(vmWithNoVnfcCount) from A&AI is " +vmWithNoVnfcCount);
291
292             String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
293
294             if ( vmCountStr == null)
295                 throw new Exception("VM data from A&AI is missing");
296             else
297                 vmCount = Integer.parseInt(vmCountStr);
298     if(vmCount<vnfcRefLen)
299                 throw new Exception("Vnfc and VM count mismatch");
300
301
302             log.info("VMCOUNT " + vmCount);
303             log.info("VNFCREFLEN " + vnfcRefLen);
304             if(StringUtils.isBlank(ctx.getAttribute("vnfc-type"))){
305                 aai.updateVnfStatusWithOAMAddress(inParams, ctx);
306             }
307
308             
309             aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount);
310             
311
312
313             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
314                     AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
315
316             log.info("addVnfcs Successful ");
317         } catch (Exception e) {
318             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
319                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
320             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
321             log.error("Failed in addVnfcs " + e.getMessage());
322
323             throw new SvcLogicException(e.getMessage());
324         }
325     }
326
327
328     public void updateVnfAndVServerStatus(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
329
330         log.info("Received updateVnfAndVServerStatus call with params : " + inParams);
331
332         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
333
334
335         int vmCount = 0;
336
337
338         try {
339
340             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
341             AaiService aai = getAaiService();
342
343
344
345             String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
346
347             if ( vmCountStr == null)
348                 throw new Exception("VM data from A&AI is missing");
349             else
350                 vmCount = Integer.parseInt(vmCountStr);
351
352
353             log.info("VMCOUNT " + vmCount);
354
355
356             aai.updateVnfStatus(inParams, ctx);
357             aai.updateVServerStatus(inParams,ctx, vmCount);
358
359             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
360                     AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
361
362             log.info("updateVnfAndVServerStatus Successful ");
363         } catch (Exception e) {
364             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
365                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
366             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
367             log.error("Failed in updateVnfAndVServerStatus " + e.getMessage());
368
369             throw new SvcLogicException(e.getMessage());
370         }
371     }
372
373     /*public void getDummyValues(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
374
375         log.info("Received getDummyValues call with params : " + inParams);
376
377         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
378
379         try {
380
381                 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
382                 String instarKeys = inParams.get("instarKeys");
383                 ObjectMapper mapper = new ObjectMapper();
384                 if ( instarKeys != null ) {
385
386                     List<String> keyList = mapper.readValue(instarKeys, ArrayList.class);
387
388                     Map<String, String> instarParams  =new HashMap<String, String>();
389                     if(keyList != null){
390                         //System.out.println(keyList.toString());
391
392
393                         for(int i=0;i<keyList.size();i++)
394                         {
395                             log.info(" -->"+keyList.get(i));
396
397                             //ctx.setAttribute(keyList.get(i), "test" + i);
398
399                             instarParams.put( keyList.get(i), "test" + i);
400                         }
401
402                     }
403                     log.info("INSTARPARAMMAP " + instarParams);
404                     String jsonString = mapper.writeValueAsString(instarParams);
405                     log.info(jsonString);
406                     ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString);
407
408                 }
409
410                 log.info("getDummyValues Successful ");
411             } catch (Exception e) {
412                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
413                         AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
414                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
415                 log.error("Failed in getDummyValues " + e.getMessage());
416
417                 throw new SvcLogicException(e.getMessage());
418             }
419
420     }
421
422     */
423     /*public void getRequestKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
424
425         log.info("Received getRequestKeys call with params : " + inParams);
426
427         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
428
429         try {
430
431                 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
432                 String instarKeys = inParams.get("instarKeys");
433
434                 ObjectMapper mapper = new ObjectMapper();
435                 if ( instarKeys != null ) {
436
437                     List<String> keyList = mapper.readValue(instarKeys, ArrayList.class);
438
439                     //Map<String, String> instarParams  =new HashMap<String, String>();
440                     if(keyList != null){
441
442
443                         for(int i=0;i<keyList.size();i++)
444                         {
445                             log.info("INSTARKEY -->"+keyList.get(i));
446
447
448                             String instarParameter = ctx.getAttribute("INSTAR." + keyList.get(i));
449                             log.info("INSTARPARAMETER " + instarParameter);
450                             Parameter param = parseParameterContent(instarParameter);
451
452                             log.info("PARAMETER KEY SIZE " + param.getRequestKeys().size());
453                             log.info("RULE TYPE " + param.getClassType());
454
455                             for ( int j =0 ; j < param.getRequestKeys().size() ; j++ ) {
456
457                                 log.info(" PARAM KEY NAME " + param.getRequestKeys().get(j).getKeyName());
458                                 log.info(" PARAM KEY VALUE " + param.getRequestKeys().get(j).getKeyValue());
459                             }
460
461                            // instarParams.put( keyList.get(i), "test" + i);
462                         }
463
464                     }
465                     //log.info("INSTARPARAMMAP " + instarParams);
466                     //String jsonString = mapper.writeValueAsString(instarParams);
467                     //log.info(jsonString);
468                     //ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString);
469
470                 }
471
472                 log.info("getRequestKeys Successful ");
473             } catch (Exception e) {
474                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
475                         AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
476                 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
477                 log.error("Failed in getRequestKeys " + e.getMessage());
478
479                 throw new SvcLogicException(e.getMessage());
480             }
481
482     }
483
484
485     public Parameter parseParameterContent(String parameter) throws JsonParseException, JsonMappingException, IOException{
486         Parameter parameterDefinition = null;
487         if(StringUtils.isNotBlank(parameter)){
488             ObjectMapper mapper = new ObjectMapper();
489             parameterDefinition = mapper.readValue(parameter, Parameter.class);
490         }
491         return parameterDefinition;
492     }*/
493     public void getVserverInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
494         log.info("getVserverInfo()::Retrieving vm and vnfc information for vserver:" + inParams.toString());
495         String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
496         try {
497             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
498             AaiService aaiService = getAaiService();
499             String vServerId = inParams.get("vserverId");
500             Map<String, String> params = setVmParams(ctx, vServerId);
501             Map<String, String> vnfcParams = new HashMap<String, String>();
502             if (null == params) {
503                 log.error("getVserverInfo()::No Vm Info found!!");
504                 throw new SvcLogicException("No Vm Info in Context");
505             }
506             params.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
507                     inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
508             SvcLogicContext newVmCtx = new SvcLogicContext();
509             aaiService.getVMInfo(params, newVmCtx);
510
511             String vnfcName = newVmCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
512             log.info("getVnfcFunctionCodeForVserver()::vnfcName=" + vnfcName);
513             SvcLogicContext newVnfcCtx = new SvcLogicContext();
514             if (StringUtils.isNotBlank(vnfcName)) {
515                 vnfcParams.put("vnfcName", vnfcName);
516             } else {
517                 log.info("getVserverInfo()::vnfc Name is blank, not setting vnfc info !!!!");
518                 return;
519             }
520             getVnfcInformationForVserver(vnfcParams, newVnfcCtx, inParams, ctx, aaiService, responsePrefix);
521         } catch (Exception e) {
522             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
523                     AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
524             ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
525             log.error("Failed in getVserverInfo " + e.getMessage());
526         }
527     }
528
529     public void getVnfcInformationForVserver(Map<String, String> vnfcParams, SvcLogicContext newVnfcCtx,
530             Map<String, String> inParams, SvcLogicContext ctx, AaiService aaiService, String responsePrefix)
531             throws Exception {
532         log.info("getVnfcInformationForVserver()::vnfcParams:" + vnfcParams.toString());
533         vnfcParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
534                 inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
535
536         aaiService.getVnfcInfo(vnfcParams, newVnfcCtx);
537
538         String vnfcType = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type");
539         String vnfcFunctionCode = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code");
540         String vnfcGroupNotation = newVnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation");
541         String vnfcV4OamIp = newVnfcCtx.getAttribute(responsePrefix + "vnfc.ipaddress-v4-oam-vip");
542
543         if (StringUtils.isBlank(vnfcType) || StringUtils.isBlank(vnfcFunctionCode)
544                 || StringUtils.isBlank(vnfcGroupNotation) || StringUtils.isBlank(vnfcV4OamIp)) {
545             log.info("getVnfcInformationForVserver()::Some vnfc parameters are blank!!!!");
546         }
547         log.info("getVnfcInformationForVserver()::vnfcType=" + vnfcType + ",vnfcFunctionCode=" + vnfcFunctionCode,
548                 ", vnfc-ipaddress-v4-oam-vip=" + vnfcV4OamIp);
549         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-name", vnfcParams.get("vnfcName"));
550         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-type", vnfcType);
551         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-function-code", vnfcFunctionCode);
552         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-group-notation", vnfcGroupNotation);
553         ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-ipaddress-v4-oam-vip", vnfcV4OamIp);
554
555     }
556
557     public Map<String, String> setVmParams(SvcLogicContext ctx, String vServerId) {
558         log.info("setVmParams()::setVmParamsVM level action:" + vServerId);
559         Map<String, String> params = new HashMap<String, String>();
560         int vmCount = 0, arrayIndex = -1;
561         String vmCountStr = ctx.getAttribute("tmp.vnfInfo.vm-count");
562         if (StringUtils.isNotBlank(vmCountStr))
563             vmCount = Integer.parseInt(vmCountStr);
564         for (int cnt = 0; cnt < vmCount; cnt++) {
565             String vsId = ctx.getAttribute("tmp.vnfInfo.vm[" + cnt + "].vserver-id");
566             log.info("setVmParams():::vserver details::" + cnt + ":" + vsId);
567             if (StringUtils.equals(vServerId, vsId)) {
568                 arrayIndex = cnt;
569             }
570         }
571         if (arrayIndex < 0) {
572             log.info("setVmParams()::VserverId not found in context!! Returning null for params!!");
573             return null;
574         }
575         String tenantId = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].tenant-id");
576         String cloudOwner = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].cloud-region-id");
577         String cloudRegionId = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].cloud-owner");
578         log.info("setVmParams()::tenantId=" + tenantId + " cloudOwner=" + cloudOwner + " cloudRegiodId= "
579                 + cloudRegionId);
580         params.put("vserverId", vServerId);
581         params.put("tenantId", tenantId);
582         params.put("cloudOwner", cloudOwner);
583         params.put("cloudRegionId", cloudRegionId);
584         log.info("setVmParams()::setVmParamsVM level action:" + params.toString());
585         return params;
586
587     }
588 }