Solved

acropolis CLI to shutdown all vms currently on


Badge +6
Hi All, I am trying to write a one (or few) liner to shutdown all non CVM vms found on the cluster. (AHV)

I know 'acli vm.list power_state=on' returns a list of vms across the cluster.... and I know i can do an 'acli vm.force_off [VM Name]' to shut those down.

Is there a bash script ninja out there that could help me write a one liner loop to take all VM names found in the first output, with the second command?

I'll keep on trying, maybe i have command-line haze happening and just need a break 🙂

thx, Brent

icon

Best answer by BrentHysop 11 April 2017, 19:24

Woohoo. replying to myself, just to update the community with the solution. As my colleauge often says, my problem was a loose nut at the keyboard.

Heres the one liner:

for vm_name in `acli vm.list power_state=on | grep -v ^'VM name' | awk '{print $1}'`; do acli vm.force_off $vm_name; done

hope someone finds that helpful. when you are scripting nutanix cluster shutdowns, the 'echo y | cluster stop' command will fail if there are running guest vms, so this is part of the forcing the cluster down, somewhat gracefully.

thx, Brent

View original

1 reply

Badge +6
Woohoo. replying to myself, just to update the community with the solution. As my colleauge often says, my problem was a loose nut at the keyboard.

Heres the one liner:

for vm_name in `acli vm.list power_state=on | grep -v ^'VM name' | awk '{print $1}'`; do acli vm.force_off $vm_name; done

hope someone finds that helpful. when you are scripting nutanix cluster shutdowns, the 'echo y | cluster stop' command will fail if there are running guest vms, so this is part of the forcing the cluster down, somewhat gracefully.

thx, Brent

Reply