Hi,
I would like to put the standalone host into maintenance mode and shut down all vms in the regular order (as they would be shutdown if I shutdown / restart the host). What are the preferred commands to do so?
Thank you!
So I would read the startup order, reverse it and then shutdown each machine? Something like this?
~ # for VM in $(vim-cmd hostsvc/autostartmanager/get_autostartseq | grep -Eo 'vim.VirtualMachine:[0-9]+' | sed 's#vim.VirtualMachine:\([0-9]*\)#\1#g' | sed '1!G;h;$!d'); do echo vim-cmd vmsvc/power.shutdown ${VM}; done
vim-cmd vmsvc/power.shutdown 16
vim-cmd vmsvc/power.shutdown 2
vim-cmd vmsvc/power.shutdown 6
vim-cmd vmsvc/power.shutdown 23
vim-cmd vmsvc/power.shutdown 22
vim-cmd vmsvc/power.shutdown 24
vim-cmd vmsvc/power.shutdown 25
vim-cmd vmsvc/power.shutdown 21
vim-cmd vmsvc/power.shutdown 12
vim-cmd vmsvc/power.shutdown 11
vim-cmd vmsvc/power.shutdown 10
vim-cmd vmsvc/power.shutdown 15
~ #
There is no "simpler" way?
Hi
You can use Virtual Machine Startup and Shutdown order, you can fins these setting on configuration tab esxi host Vcenter or Esxi Web client. Please remeber that if you have HA cluster this setting dosen't work.
I want to use ssh and not the web interface.
You can use ssh to reboot, but shutdown and startup policy you are able to configure using web client, It is not something you can configure using ssh.
You could always use PowerCLI to carry out this process.
OK, but what is the command to shutdown the vms? Like
but for ALL vms in the order configured in the web client.
You would have to script which order you wish to shutdown VMs, but you can use vim-cmd for that.
So I would read the startup order, reverse it and then shutdown each machine? Something like this?
~ # for VM in $(vim-cmd hostsvc/autostartmanager/get_autostartseq | grep -Eo 'vim.VirtualMachine:[0-9]+' | sed 's#vim.VirtualMachine:\([0-9]*\)#\1#g' | sed '1!G;h;$!d'); do echo vim-cmd vmsvc/power.shutdown ${VM}; done
vim-cmd vmsvc/power.shutdown 16
vim-cmd vmsvc/power.shutdown 2
vim-cmd vmsvc/power.shutdown 6
vim-cmd vmsvc/power.shutdown 23
vim-cmd vmsvc/power.shutdown 22
vim-cmd vmsvc/power.shutdown 24
vim-cmd vmsvc/power.shutdown 25
vim-cmd vmsvc/power.shutdown 21
vim-cmd vmsvc/power.shutdown 12
vim-cmd vmsvc/power.shutdown 11
vim-cmd vmsvc/power.shutdown 10
vim-cmd vmsvc/power.shutdown 15
~ #
There is no "simpler" way?
If you want simple then you need vCenter Server. You've got a standalone host here with no management capabilities. How much simpler do you want it?
I just do not want to reinvent the wheel, so if the is a command like
vim-cmd shutdown.all.in.the.reverse.order
I would prefer to use it.
Yeah, there's not. You don't get that with free