I have downloaded and compiled the VMware Infrastructure (VI) Perl Toolkit Packages (Latest Version: 1.5.0 | 1/17/2008 | Build: 67153).
I am trying to use the "vmcontrol.pl" as fencing script but it has limitations. Below are all the possible power states of a VM and wanted action/results.
1. If VM is powered on Hard power off the VM
2. If VM is powered off Dont error out, return VM is already off
3. If VM is suspend mode Dont error out, Hard power off the VM
As of now the below happens:
1. virtual machine 'TEST1_VM' under host X.X.X.X powered off
2. VM 'TEST1_VM' can't be powered off. The attempted operation cannot be performed in the current state (Powered Off) at /usr/lib/perl5/5.8.5/VMware/VIM2Runtime.pm line 1412
3. VM 'TEST1_VM' can't be powered off. The attempted operation cannot be performed in the current state (Suspended) at /usr/lib/perl5/5.8.5/VMware/VIM2Runtime.pm line 1412
#./vmcontrol.pl --username XXXXXX --password XXXXXX --url https://184.108.40.206:443/sdk/webService --vmname TEST1_VM --operation poweroff
Thanks in advance!
What you are seeing is a limitation of the SDK. If you see: http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.VirtualMachine.html#powerOff you will notice that it will fail to power off unless the state is on. I believe that suspended state is really off, but with information to allow VMware to quickly resume the system (RAM/swap/runtime information stored at suspend time). So, you could query the state before forcing a power off.