Page MenuHomeDevCentral
Paste P316

Steps needed to automate a reboot on hypervisor
ActivePublic

Authored by dereckson on Mar 25 2023, 17:07.
[dereckson@hyper-001:~] vim-cmd vmsvc/getallvms | grep docker-002
4 docker-002 [datastore1] docker-002/docker-002.vmx centos9_64Guest vmx-19 Network adapter 3 / 00:50:56:0c:7a:98 has temporarily the docker-001 IP
[dereckson@hyper-001:~] vim-cmd vmsvc/getallvms | grep docker-002 | awk '{print $1}'
4
[dereckson@hyper-001:~] VM_ID=$(vim-cmd vmsvc/getallvms | grep docker-002 | awk '{print $1}')
[dereckson@hyper-001:~] vim-cmd vmsvc/power.getstate $VM_ID
Retrieved runtime info
Powered on
[dereckson@hyper-001:~] VM_STATE=$(vim-cmd vmsvc/power.getstate $VM_ID)
[dereckson@hyper-001:~] echo $VM_STATE
Retrieved runtime info Powered on
[dereckson@hyper-001:~] vim-cmd vmsvc/get.tasklist $VM_ID
(ManagedObjectReference) []
[dereckson@hyper-001:~] vim-cmd vmsvc/power.reboot $VM_ID
(vim.fault.ToolsUnavailable) {
faultCause = (vmodl.MethodFault) null,
faultMessage = <unset>
msg = "Received SOAP response fault from [<<io_obj p:0x0000004e00581dd8, h:5, <TCP '127.0.0.1 : 48760'>, <TCP '127.0.0.1 : 8307'>>, /sdk>]: rebootGuest
Cannot complete operation because VMware Tools is not running in this virtual machine."
}