Wednesday, February 20, 2013

An all-CLI approach to starting/stopping VMs in ESXi 5.1

You could do that without vSphere client, you knew that?!?

Provided that SSH is enabled on ESXi (link opens another window), log in to the root prompt the follow the steps below:
  1. first, verify that the host is/isn't in Maintenance mode:
    # vim-cmd hostsvc/hostsummary | grep Maintenance
          inMaintenanceMode = false,
  1. obviously, if it is, exit Maintenance mode:
    # vim-cmd hostsvc/maintenance_mode_exit
    'vim.Task:haTask-ha-host-vim.HostSystem.exitMaintenanceMode-415392973'
  1. then, check which VMs are available (output edited):
    # vim-cmd vmsvc/getallvms
    Vmid  Name               File                      Guest OS     Version

    1    name_1  [storage_1] Debian 64 6.x/vmx1.vmx  LinuxGuest     vmx-08
    2    name_2  [storage_2] Windows XP 1/vmx2.vmx   winXPProGuest  vmx-07
    3    name_3  [storage_3] Windows XP 2/vmx3.vmx   winXPProGuest  vmx-08
  1. VMs can be started as follows:
    # vim-cmd vmsvc/power.on 2
    Powering on VM:
Yep, that's all you have to do, no need for vSphere client for the time being :)

Links:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1038043
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=9639912


No comments: