PaloAltoNetworks / pcs-sizing-scripts

Prisma Cloud sizing scripts
ISC License
46 stars 50 forks source link

Aliyun Sizing Script #44

Open billhoph opened 1 year ago

billhoph commented 1 year ago

Describe the bug

On testing, I found there is a bug in Aliyun CLI which affects the sizing tool. With the bug, the sizing script would just return all 0 in the counting.

Expected behavior

The Aliyun Sizing Script is reading the "Total Count" attribute from the json obtained by "aliyun ecs describeinstances". The "Total Count" should report the total ECS (VM) instances number.

Current behavior

But perhaps an API bug from Alicloud side, the "Total Count" is always 0 even there are vm listed. image

Possible solution

Amend the script function "get_instance_count()", skip relying on the "Total Count" attribute. Instead, add the new lines to count the instances number instead.

get_instance_count() { COUNT=0 RESULT=$(abc_compute_instances_list "${1}") // COUNT=$(echo "${RESULT}" | jq -r '.TotalCount' 2>/dev/null) //commented this original line INSTANCES=($(echo "${RESULT}" | jq -r '.Instances.Instance[].InstanceId' 2>/dev/null)) //add new line 1 COUNT=$((COUNT + ${#INSTANCES[@]})) //add new line 2 echo "${COUNT}" }

welcome-to-palo-alto-networks[bot] commented 1 year ago

:tada: Thanks for opening your first issue here! Welcome to the community!