Translate

lunes, 24 de junio de 2013

Power On an ESX Virtual Machine from command line

You can power on a Virtual Machine directly from the command line without any vCenter Server or vSphere Client.
You can do it because the ESX Server basically is a RedHat Linux, so you can locally access to the shell, or remotely using SSH. To enable SSH access to a ESX Server you must configure it locally, or via SSH but with another user different than root. If you have done it via SSH, once you have logged, change to root user with:
su -

Using nano you could edit the file and search for PermitRootLogin wich has a default value of no, changing it to yes.
nano /etc/ssh/sshd_config

Save the file by first pressing Ctrl-O an then Enter, an close nano with Ctrl-X.

Finally restart the ssh service with:

service sshd restart

Once you have access to the comman line you could list the Virtual Machine hosted by the ESX Server with the following command

vim-cmd vmsvc/getallvms 

Then you will obtain a list and you must pay attention to the first column in wich you could find the VMid number for each virtual machine.


If you want to know the actual state (running, powered on, etc..) you could use:

vim-cmd vmsvc/power.getstate  "VMid_to_test"

And finally to power on your virtual machine:

vim-cmd vmsvc/power.on "VMid_to_start"

No hay comentarios: