Yesterday’s installment ended with a list of power related vim-cmd vmsvc
commands:
Usage: power.getstate vmid Usage: power.hibernate vmid Usage: power.off vmid Usage: power.on vmid Usage: power.reboot vmid Usage: power.reset vmid Usage: power.shutdown vmid Usage: power.suspend vmid Usage: power.suspendResume vmid
Getting vmid
values
These all have a vmid
parameter, so let’s create a small statement that gives the list of vmid
on an ESXi system:
vim-cmd vmsvc/getallvms | sed -n -E -e "s/^([[:digit:]]+)\s+((\S.+\S)?)\s+(\[\S+\])\s+(.+\.vmx)\s+(\S+)\s+(vmx-[[:digit:]]+)\s*?((\S.+)?)$/\1/p"
On my system the relevant VMs it returns are these:
10 5
The various power commands
The outcome of the various power commands are not as simple as one might think as they often do not just depend on the current power state of the VM, but also on either VMware Tools or open-vm-tools to be running.
Basically these tools do the same, but their origin is different: open-vm-tools is often included as part of Linux distributions; VMware Tools is often installed separately, see:
- [Wayback] VMware Tools or open-vm-tools – Thomas-Krenn-Wiki
- [Wayback/Archive.is] vmware/open-vm-tools: Official repository of VMware open-vm-tools project
I have made a table for this hoping it makes reading easier, the explanations are by empirical usage, as the documentation in the help dump (see [Wayback] delimited vim-cmd help for each vmsvc command.txt) does not seem to match behaviour.
Command Explanation vim-cmd vmsvc/power.getstate vmid
Gets the power state of the VM, returning a line Retrieved runtime info
followed by lines indicating the power state:
Powered off
Powered on
Suspended
vim-cmd vmsvc/power.hibernate vmid
When neither VMware Tools or open-vm-tools to be running, you get an error: (vim.fault.ToolsUnavailable) { faultCause = (vmodl.MethodFault) null, faultMessage = msg = "Received SOAP response fault from []: standbyGuest Cannot complete operation because VMware Tools is not running in this virtual machine." }
When a hibernate/suspend task is already running, you get an error:
(vim.fault.TaskInProgress) { faultCause = (vmodl.MethodFault) null, faultMessage = , task = 'vim.Task:haTask-12-vim.VirtualMachine.suspend-1006072588' msg = "Received SOAP response fault from []: standbyGuest Another task is already in progress." }
Otherwise, depends on the power state of the VM if vmware tools:
Powered off
: keeps the power state of the VM asPowered off
and shows an error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "poweredOff" msg = "Received SOAP response fault from []: standbyGuest The attempted operation cannot be performed in the current state (Powered off)." }
Powered on
: sets the power state of the VM toSuspended
and shows no output, unless neither VMware Tools, nor open-vm-tools can be communicated with, then you get this error:
(vmodl.fault.SystemError) { faultCause = (vmodl.MethodFault) null, faultMessage = , reason = "Invalid fault" msg = "Received SOAP response fault from []: standbyGuest vim.fault.GenericVmConfigFault" }
Suspended
: keeps the power state of the VM asSuspended
and shows an error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "suspended" msg = "Received SOAP response fault from []: standbyGuest The attempted operation cannot be performed in the current state (Suspended)." }
vim-cmd vmsvc/power.off vmid
Depends on the power state of the VM and either VMware Tools or open-vm-tools to be running:
Powered off
: keeps the power state of the VM asPowered off
and shows two lines
Powering off VM: Power off failed
Powered on
: powers off the VM (bypasses any VMware Tools or open-vm-tools) and sets power state of the VM toPowered off
showing one line
Powering off VM:
Suspended
: Hardware powers off the VM (bypasses any VMware Tools or open-vm-tools) and sets power state of the VM toPowered off
showing one line
Powering off VM:
vim-cmd vmsvc/power.on vmid
Depends on the power state of the VM:
Powered on
: keeps power state of the VM asPowered off
showing two lines
Powering on VM: Power on failed
Powered off
: keeps the power state of the VM asPowered off
and shows one line
Powering ofn VM:
Suspended
: keeps the power state of the VM asSuspended
showing two lines
Powering on VM: Power on failed
This also undoes a
vim-cmd vmsvc/power.hibernate vmid
,vim-cmd vmsvc/power.shutdown vmid
orvim-cmd vmsvc/power.suspend vmid
.vim-cmd vmsvc/power.reboot vmid
Depends on the power state of the VM and either VMware Tools or open-vm-tools to be running:
Powered off
: keeps the power state of the VM asPowered off
and shows the error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "poweredOff" msg = "Received SOAP response fault from []: rebootGuest The attempted operation cannot be performed in the current state (Powered off)." }
Powered on
and either VMware Tools or open-vm-tools are running: uses VMware Tools or open-vm-tools to reboot the VM: keeps the power state of the VM asPowered on
.Powered on
, but neither VMware Tools nor open-vm-tools are running: keeps the power state of the VM asPowered on
and shows the error
(vim.fault.ToolsUnavailable) { faultCause = (vmodl.MethodFault) null, faultMessage = msg = "Received SOAP response fault from []: rebootGuest Cannot complete operation because VMware Tools is not running in this virtual machine." }
Suspended
: keeps the power state of the VM asSuspended
and shows the error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "suspended" msg = "Received SOAP response fault from []: rebootGuest The attempted operation cannot be performed in the current state (Suspended)." }
vim-cmd vmsvc/power.reset vmid
Depends on the power state of the VM:
Powered off
: keeps the power state of the VM asPowered off
and shows two lines
Reset VM: Reset failed
Powered on
: keeps the power state of the VM asPowered on
, bypasses running VMware Tools or open-vm-tools (basically like a hardware reset button) and shows one line
Reset VM:
Suspended
: keeps the power state of the VM asSuspended
and shows two lines
Reset VM: Reset failed
vim-cmd vmsvc/power.shutdown vmid
Depends on the power state of the VM and either VMware Tools or open-vm-tools to be running:
Powered off
: keeps the power state of the VM asPowered off
and shows the error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "poweredOff" msg = "Received SOAP response fault from []: shutdownGuest The attempted operation cannot be performed in the current state (Powered off)." }
Powered on
and either VMware Tools or open-vm-tools are running: uses VMware Tools or open-vm-tools to shutdown the VM and sets the power state of the VM toPowered off
without showing any output.Powered on
, but neither VMware Tools nor open-vm-tools are running: keeps the power state of the VM asPowered on
and shows the error
(vim.fault.ToolsUnavailable) { faultCause = (vmodl.MethodFault) null, faultMessage = msg = "Received SOAP response fault from []: shutdownGuest Cannot complete operation because VMware Tools is not running in this virtual machine." }
Suspended
: keeps the power state of the VM asSuspended
and shows the error
(vim.fault.InvalidPowerState) { faultCause = (vmodl.MethodFault) null, faultMessage = , requestedState = "poweredOn", existingState = "suspended" msg = "Received SOAP response fault from []: shutdownGuest The attempted operation cannot be performed in the current state (Suspended)." }
vim-cmd vmsvc/power.suspend vmid
When neither VMware Tools or open-vm-tools to be running, you get an error: (vim.fault.ToolsUnavailable) { faultCause = (vmodl.MethodFault) null, faultMessage = msg = "Received SOAP response fault from []: standbyGuest Cannot complete operation because VMware Tools is not running in this virtual machine." }
When a hibernate/suspend task is already running, you get an error:
(vim.fault.TaskInProgress) { faultCause = (vmodl.MethodFault) null, faultMessage = , task = 'vim.Task:haTask-12-vim.VirtualMachine.suspend-1006072588' msg = "Received SOAP response fault from []: standbyGuest Another task is already in progress." }
Otherwise, depends on the power state of the VM:
Powered off
: keeps the power state of the VM asPowered off
and shows two lines
Suspending VM: Suspend failed
Powered on
: keeps the power state of the VM asPowered on
, and shows one line
Suspending VM:
unless neither VMware Tools, nor open-vm-tools can be communicated with, then you get this error:
(vmodl.fault.SystemError) { faultCause = (vmodl.MethodFault) null, faultMessage = , reason = "Invalid fault" msg = "Received SOAP response fault from []: standbyGuest vim.fault.GenericVmConfigFault" }
Suspended
: keeps the power state of the VM asSuspended
and shows two lines
Suspending VM: Suspend failed
vim-cmd vmsvc/power.suspendResume vmid
Depends on the power state of the VM:
Powered off
: keeps the power state of the VM asPowered off
and shows two lines
Suspend/Resuming the VM: Suspend/Resume failed
Powered on
: keeps the power state of the VM asPowered on
, and shows one line
Suspend/Resuming the VM:
Suspended
: keeps the power state of the VM asSuspended
and shows two lines
Suspend/Resuming the VM: Suspend/Resume failed
Note that in the VMware web console, this is shown as “Invoke FSR” which is a Fast Suspend Resume, which I think has to do with vMotion.
Notes:
- there is no command
vim-cmd vmsvc/power.startup vmid
(to undovim-cmd vmsvc/power.shutdown vmid
), usevim-cmd vmsvc/power.on vmid
in stead. - there is no command
vim-cmd vmsvc/power.resume vmid
(to undovim-cmd vmsvc/power.suspend vmid
), usevim-cmd vmsvc/power.on vmid
in stead. - there is no command
vim-cmd vmsvc/power.wakeup vmid
(to undovim-cmd vmsvc/power.hibernate vmid
), usevim-cmd vmsvc/power.on vmid
in stead.
Running the various power commands on all relevant VMs
This will be the topic for the next installment.
–jeroen