2 * ============LICENSE_START=======================================================
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
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.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.aai.client.node;
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;
36 import org.apache.commons.lang3.StringUtils;
38 import org.onap.appc.aai.client.AppcAaiClientConstant;
39 import org.onap.appc.aai.client.aai.AaiService;
42 import com.att.eelf.configuration.EELFLogger;
43 import com.att.eelf.configuration.EELFManager;
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;
49 //import com.fasterxml.jackson.databind.ObjectMapper;
52 public class AAIResourceNode implements SvcLogicJavaPlugin {
54 private static final EELFLogger log = EELFManager.getInstance().getLogger(AAIResourceNode.class);
57 public AaiService getAaiService() {
58 return new AaiService();
60 /* Gets VNF Info and All VServers associated with Vnf */
61 public void getVnfInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
63 log.info("Received getVnfInfo call with params : " + inParams);
65 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
69 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
70 AaiService aai = getAaiService();
71 aai.getGenericVnfInfo(inParams,ctx);
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());
82 throw new SvcLogicException(e.getMessage());
87 public void getAllVServersVnfcsInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
89 log.info("Received getAllVServersVnfcsInfo call with params : " + inParams);
91 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
94 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
95 AaiService aai = getAaiService();
99 ArrayList<Map<String, String>> vservers = new ArrayList<Map<String, String>>();
101 int vmWithNoVnfcsCount = 0;
102 String vmCountStr = ctx.getAttribute(responsePrefix + "vm-count");
104 if ( vmCountStr == null )
105 throw new Exception("Unable to get VServers for the VNF");
107 int vmCount = Integer.parseInt(vmCountStr);
108 for ( int i = 0; i < vmCount; i++ ) {
110 SvcLogicContext vmServerCtx = new SvcLogicContext();
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));
121 aai.getVMInfo(paramsVm, vmServerCtx);
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"));
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"));
134 // as Per 17.07 requirements we are supporting only one VNFC per VM.
136 String vnfcName = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
137 vserverMap.put("vnfc-name", vnfcName);
140 String vnfcCount = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc-count");
141 if ( vnfcCount == null )
144 vserverMap.put("vnfc-count", vnfcCount);
146 if ( vnfcName != null ) {
147 Map<String, String> paramsVnfc = new HashMap<String, String>();
148 paramsVnfc.put("vnfcName", vnfcName);
150 paramsVnfc.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
152 SvcLogicContext vnfcCtx = new SvcLogicContext();
154 aai.getVnfcInfo(paramsVnfc, vnfcCtx);
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"));
163 vmWithNoVnfcsCount++;
164 vservers.add(vserverMap);
168 Collections.sort(vservers, new Comparator<Map<String, String>>() {
170 public int compare(Map<String, String> o1, Map<String, String> o2) {
171 return o1.get("vserver-name").compareTo(o2.get("vserver-name"));
175 log.info("SORTED VSERVERS " + vservers.toString());
177 populateContext(vservers, ctx, responsePrefix);
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));
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());
191 throw new SvcLogicException(e.getMessage());
195 public void populateContext(ArrayList<Map<String, String>> vservers, SvcLogicContext ctx, String prefix) {
198 log.info("Populating Final Context");
201 for (Map<String, String> entry : vservers) {
202 for (String key : entry.keySet()) {
203 String value = entry.get(key);
205 ctx.setAttribute(prefix+ "vm[" + ctr + "]."+ key, value);
206 log.info("Populating Context Key = " + prefix+ "vm[" + ctr + "]."+ key + " Value = " + value);
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);
226 public void addVnfcs(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
228 log.info("Received addVnfcs call with params : " + inParams);
230 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
234 int vmWithNoVnfcCount = 0;
238 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
239 AaiService aai = getAaiService();
241 String vnfcRefLenStr = ctx.getAttribute("vnfcReference_length");
243 if ( vnfcRefLenStr == null) {
244 log.info("Vnfc Reference data is missing");
245 throw new Exception("Vnfc Reference data is missing");
249 vnfcRefLen = Integer.parseInt(vnfcRefLenStr);
251 String vmWithNoVnfcCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-with-no-vnfcs-count");
253 //Commented for backward compatibility
255 /*if ( vmWithNoVnfcCountStr == null) {
256 throw new Exception("VNFCs to be added data from A&AI is missing");
257 //log.info("VNFCs to be added data from A&AI is missing");
260 vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr);
262 if ( vmWithNoVnfcCount!= vnfcRefLen )
263 throw new Exception("Unable to Add Vnfcs to A&AI. Reference data mismatch.");
265 String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
267 if ( vmCountStr == null)
268 throw new Exception("VM data from A&AI is missing");
270 vmCount = Integer.parseInt(vmCountStr);
273 log.info("VMCOUNT " + vmCount);
274 log.info("VNFCREFLEN " + vnfcRefLen);
275 aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount);
282 if ( vmWithNoVnfcCountStr == null) {
283 log.info("Parameter VM without VNFCs(vmWithNoVnfcCountStr) from A&AI is Null");
286 vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr);
288 log.info("No of VM without VNFCs(vmWithNoVnfcCount) from A&AI is " +vmWithNoVnfcCount);
290 String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
292 if ( vmCountStr == null)
293 throw new Exception("VM data from A&AI is missing");
295 vmCount = Integer.parseInt(vmCountStr);
296 if(vmCount<vnfcRefLen)
297 throw new Exception("Vnfc and VM count mismatch");
300 log.info("VMCOUNT " + vmCount);
301 log.info("VNFCREFLEN " + vnfcRefLen);
302 if(StringUtils.isBlank(ctx.getAttribute("vnfc-type"))){
303 aai.updateVnfStatusWithOAMAddress(inParams, ctx);
306 if ( vmWithNoVnfcCount!= vnfcRefLen ) {
307 //throw new Exception("Unable to Add Vnfcs to A&AI. Reference data mismatch.");
308 log.info("vmWithNoVnfcCount and vnfcRefLen data from table are not same ");
309 aai.checkAndUpdateVnfc(inParams,ctx, vnfcRefLen, vmCount);
314 aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount);
319 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
320 AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
322 log.info("addVnfcs Successful ");
323 } catch (Exception e) {
324 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
325 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
326 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
327 log.error("Failed in addVnfcs " + e.getMessage());
329 throw new SvcLogicException(e.getMessage());
334 public void updateVnfAndVServerStatus(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
336 log.info("Received updateVnfAndVServerStatus call with params : " + inParams);
338 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
346 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
347 AaiService aai = getAaiService();
351 String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count");
353 if ( vmCountStr == null)
354 throw new Exception("VM data from A&AI is missing");
356 vmCount = Integer.parseInt(vmCountStr);
359 log.info("VMCOUNT " + vmCount);
362 aai.updateVnfStatus(inParams, ctx);
363 aai.updateVServerStatus(inParams,ctx, vmCount);
365 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
366 AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
368 log.info("updateVnfAndVServerStatus Successful ");
369 } catch (Exception e) {
370 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
371 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
372 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
373 log.error("Failed in updateVnfAndVServerStatus " + e.getMessage());
375 throw new SvcLogicException(e.getMessage());
379 /*public void getDummyValues(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
381 log.info("Received getDummyValues call with params : " + inParams);
383 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
387 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
388 String instarKeys = inParams.get("instarKeys");
389 ObjectMapper mapper = new ObjectMapper();
390 if ( instarKeys != null ) {
392 List<String> keyList = mapper.readValue(instarKeys, ArrayList.class);
394 Map<String, String> instarParams =new HashMap<String, String>();
396 //System.out.println(keyList.toString());
399 for(int i=0;i<keyList.size();i++)
401 log.info(" -->"+keyList.get(i));
403 //ctx.setAttribute(keyList.get(i), "test" + i);
405 instarParams.put( keyList.get(i), "test" + i);
409 log.info("INSTARPARAMMAP " + instarParams);
410 String jsonString = mapper.writeValueAsString(instarParams);
411 log.info(jsonString);
412 ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString);
416 log.info("getDummyValues Successful ");
417 } catch (Exception e) {
418 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
419 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
420 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
421 log.error("Failed in getDummyValues " + e.getMessage());
423 throw new SvcLogicException(e.getMessage());
429 /*public void getRequestKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
431 log.info("Received getRequestKeys call with params : " + inParams);
433 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
437 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
438 String instarKeys = inParams.get("instarKeys");
440 ObjectMapper mapper = new ObjectMapper();
441 if ( instarKeys != null ) {
443 List<String> keyList = mapper.readValue(instarKeys, ArrayList.class);
445 //Map<String, String> instarParams =new HashMap<String, String>();
449 for(int i=0;i<keyList.size();i++)
451 log.info("INSTARKEY -->"+keyList.get(i));
454 String instarParameter = ctx.getAttribute("INSTAR." + keyList.get(i));
455 log.info("INSTARPARAMETER " + instarParameter);
456 Parameter param = parseParameterContent(instarParameter);
458 log.info("PARAMETER KEY SIZE " + param.getRequestKeys().size());
459 log.info("RULE TYPE " + param.getClassType());
461 for ( int j =0 ; j < param.getRequestKeys().size() ; j++ ) {
463 log.info(" PARAM KEY NAME " + param.getRequestKeys().get(j).getKeyName());
464 log.info(" PARAM KEY VALUE " + param.getRequestKeys().get(j).getKeyValue());
467 // instarParams.put( keyList.get(i), "test" + i);
471 //log.info("INSTARPARAMMAP " + instarParams);
472 //String jsonString = mapper.writeValueAsString(instarParams);
473 //log.info(jsonString);
474 //ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString);
478 log.info("getRequestKeys Successful ");
479 } catch (Exception e) {
480 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
481 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
482 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
483 log.error("Failed in getRequestKeys " + e.getMessage());
485 throw new SvcLogicException(e.getMessage());
491 public Parameter parseParameterContent(String parameter) throws JsonParseException, JsonMappingException, IOException{
492 Parameter parameterDefinition = null;
493 if(StringUtils.isNotBlank(parameter)){
494 ObjectMapper mapper = new ObjectMapper();
495 parameterDefinition = mapper.readValue(parameter, Parameter.class);
497 return parameterDefinition;
499 public void getVserverInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
500 log.info("getVserverInfo()::Retrieving vm and vnfc information for vserver:" + inParams.toString());
501 String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
503 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
504 AaiService aaiService = getAaiService();
505 String vServerId = inParams.get("vserverId");
506 Map<String, String> params = setVmParams(ctx, vServerId);
507 Map<String, String> vnfcParams = new HashMap<String, String>();
508 if (null == params) {
509 log.error("getVserverInfo()::No Vm Info found!!");
510 throw new SvcLogicException("No Vm Info in Context");
512 params.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
513 inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
514 SvcLogicContext newVmCtx = new SvcLogicContext();
515 aaiService.getVMInfo(params, newVmCtx);
517 String vnfcName = newVmCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name");
518 log.info("getVnfcFunctionCodeForVserver()::vnfcName=" + vnfcName);
519 SvcLogicContext newVnfcCtx = new SvcLogicContext();
520 if (StringUtils.isNotBlank(vnfcName)) {
521 vnfcParams.put("vnfcName", vnfcName);
523 log.info("getVserverInfo()::vnfc Name is blank, not setting vnfc info !!!!");
526 getVnfcInformationForVserver(vnfcParams, newVnfcCtx, inParams, ctx, aaiService, responsePrefix);
527 } catch (Exception e) {
528 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
529 AppcAaiClientConstant.OUTPUT_STATUS_FAILURE);
530 ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
531 log.error("Failed in getVserverInfo " + e.getMessage());
535 public void getVnfcInformationForVserver(Map<String, String> vnfcParams, SvcLogicContext newVnfcCtx,
536 Map<String, String> inParams, SvcLogicContext ctx, AaiService aaiService, String responsePrefix)
538 log.info("getVnfcInformationForVserver()::vnfcParams:" + vnfcParams.toString());
539 vnfcParams.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
540 inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
542 aaiService.getVnfcInfo(vnfcParams, newVnfcCtx);
544 String vnfcType = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type");
545 String vnfcFunctionCode = newVnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code");
546 String vnfcGroupNotation = newVnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation");
547 String vnfcV4OamIp = newVnfcCtx.getAttribute(responsePrefix + "vnfc.ipaddress-v4-oam-vip");
549 if (StringUtils.isBlank(vnfcType) || StringUtils.isBlank(vnfcFunctionCode)
550 || StringUtils.isBlank(vnfcGroupNotation) || StringUtils.isBlank(vnfcV4OamIp)) {
551 log.info("getVnfcInformationForVserver()::Some vnfc parameters are blank!!!!");
553 log.info("getVnfcInformationForVserver()::vnfcType=" + vnfcType + ",vnfcFunctionCode=" + vnfcFunctionCode,
554 ", vnfc-ipaddress-v4-oam-vip=" + vnfcV4OamIp);
555 ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-name", vnfcParams.get("vnfcName"));
556 ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-type", vnfcType);
557 ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-function-code", vnfcFunctionCode);
558 ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-group-notation", vnfcGroupNotation);
559 ctx.setAttribute(responsePrefix + "vm.vnfc.vnfc-ipaddress-v4-oam-vip", vnfcV4OamIp);
563 public Map<String, String> setVmParams(SvcLogicContext ctx, String vServerId) {
564 log.info("setVmParams()::setVmParamsVM level action:" + vServerId);
565 Map<String, String> params = new HashMap<String, String>();
566 int vmCount = 0, arrayIndex = -1;
567 String vmCountStr = ctx.getAttribute("tmp.vnfInfo.vm-count");
568 if (StringUtils.isNotBlank(vmCountStr))
569 vmCount = Integer.parseInt(vmCountStr);
570 for (int cnt = 0; cnt < vmCount; cnt++) {
571 String vsId = ctx.getAttribute("tmp.vnfInfo.vm[" + cnt + "].vserver-id");
572 log.info("setVmParams():::vserver details::" + cnt + ":" + vsId);
573 if (StringUtils.equals(vServerId, vsId)) {
577 if (arrayIndex < 0) {
578 log.info("setVmParams()::VserverId not found in context!! Returning null for params!!");
581 String tenantId = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].tenant-id");
582 String cloudOwner = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].cloud-region-id");
583 String cloudRegionId = ctx.getAttribute("tmp.vnfInfo.vm[" + arrayIndex + "].cloud-owner");
584 log.info("setVmParams()::tenantId=" + tenantId + " cloudOwner=" + cloudOwner + " cloudRegiodId= "
586 params.put("vserverId", vServerId);
587 params.put("tenantId", tenantId);
588 params.put("cloudOwner", cloudOwner);
589 params.put("cloudRegionId", cloudRegionId);
590 log.info("setVmParams()::setVmParamsVM level action:" + params.toString());