• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Starting VMs and/or Vapps programmatically?

danswartz

2[H]4U
Joined
Feb 25, 2011
Messages
3,715
So I've been googling for a couple of hours now and not finding an answer to this. Is there a way to start VMs or Vapps from the CLI of a guest? The closest I can find is PowerCLI, but from everything I can see, that is Windows only. Everything I've found online about starting Vapps shows how to start them from the vsphere client or vsphere web client, which is not what I am looking for. Am I missing something here?
 
Hm, what version of ESXi are you using, 5? 4?
From what I understand, the concept is the same for any type of hypervisor whether it's type-1 or 2, whether it's virtualbox, VMware, Xen, HyperV or otherwise: the guest VM doesn't know of it's host other than what's exposed through the guest-tools drivers. it doesn't appear that you can do anything other than shut the guest down through, well, from within the guest. starting up HAS to come from the host.

I suppose the other way would be to script something up on the guest where you would:
- ssh to the IP of the host ESXi server
- run the "vim-cmd vmsvc/power.shutdown 2" command, where "2" is the ID of the VM you wanna shut down.

.. unless you still meant to programmatically be able to startup/shutdown vm's from the unix terminal of the ESXi server?
 
So I've been googling for a couple of hours now and not finding an answer to this. Is there a way to start VMs or Vapps from the CLI of a guest? The closest I can find is PowerCLI, but from everything I can see, that is Windows only. Everything I've found online about starting Vapps shows how to start them from the vsphere client or vsphere web client, which is not what I am looking for. Am I missing something here?

Are you looking for Linux based options?
 
Preferably, yes. I'd like to be able to start all the guests from the storage appliance...
 
To power on a virtual machine from the command line:

List the inventory ID of the virtual machine with the command:
vim-cmd vmsvc/getallvms |grep <vm name>

Note: The first column of the output shows the vmid.

Check the power state of the virtual machine with the command:
vim-cmd vmsvc/power.getstate <vmid>

Power-on the virtual machine with the command:
vim-cmd vmsvc/power.on <vmid>

http://kb.vmware.com/selfservice/mi...nguage=en_US&cmd=displayKC&externalId=1038043
 
Just what I was looking for, thanks! It's a little frustrating that hours googling for how to do this turned up nothing, including on vmware's docs :(
 
The only reason I knew what to search for is because I knew the command already. (I don't remember all of the switches/options though.) Glad this is what you were looking for.
 
Back
Top