Encender máquinas virtuales en VMWare ESXi

Traducción del original en inglés. Léela en: CatalàEnglish

Los siguientes comandos son muy útiles cuando no tienes acceso a la UI de vSphere y tienes que acceder al hipervisor VMWare por SSH o consola:

# get the list of virtual machines
vim-cmd vmsvc/getallvms

# get the state of a VM with #id: VM_ID
vim-cmd vmsvc/power.getstate VM_ID

# turn on the virtual machine with #id: VM_ID
vim-cmd vmsvc/power.on VM_ID

Otra opción para encender la máquina virtual es usar un playbook de Ansible:

- hosts: vmware
  gather_facts: false
  tasks:
    - vsphere_guest:
        vcenter_hostname: "X.X.X.X"
        username: "{{ hostvars[inventory_hostname].ansible_ssh_user|quote }}"
        password: "{{ hostvars[inventory_hostname].ansible_ssh_pass|quote }}"
        guest: "NAME_OF_THE_VM"
        state: "powered_on"
      delegate_to: localhost