Comando utiles VMware CLI

A continuación les dejo un resumen de los comandos más básicos y utilizados a través de la shell y SSH de un host ESXi VMware. Por defecto, los hosts ESXi no tienen habilitado ni el servicio SSH ni el ESXi Shell. Es necesario activarlo manualmente del siguiente modo:
  1. Acceder al vCenter Server o al Host usando el cliente vSphere.
  2. Seleccionar el host del panel izquierdo o del inventario.
  3. Hacer click en la pestaña de configuración y luego en perfil de seguridad (Security Profile)
  4. En la sección ed servicios, hacer click en propiedades.
  5. Seleccionar ESXi Shell y SSH de la lista
  6. Hacer click en “opciones” y elegir “Start and stop manually” o “Start and stop with host” según si queremos únicamente arrancarlo para un momento o queremos que sea persistente a reinicios.

Comando y Operaciones Consola ESXi 

Información extendida del host de ESXi.

El comando "esxcfg-info" muestra información extendida del hardware del host
esxcfg-info | more
+Host : 
   \==+Hardware Info : 
      |----BIOS UUID................................................0xff 0x20 0x0 0x8 0xff 0xff 
      |----Product Name.............................................SUN BLADE X4-2B 
      |----Vendor Name..............................................Oracle Corporation
      |----Serial Number............................................XXXXX            
      |----Hardware Uptime..........................................744880994637 
      |----Ipmi Supported...........................................true
      \==+PCI Info : 
         \==+All Pci Devices : 
            \==+PCI Device : 
               |----Segment.........................................0x0000 
               |----Bus.............................................0x00 
               |----Slot............................................0x00 
               |----Function........................................0x00 
               |----Runtime Owner...................................vmkernel
               |----Has Configured Owner............................false
               |----Configured Owner................................
               |----Vendor Id.......................................0x8086 
               |----Device Id.......................................0x0e00 
               |----Sub-Vendor Id...................................0x108e 
               |----Sub-Device Id...................................0x434c 
               |----Vendor Name.....................................Intel Corporation
               |----Device Name.....................................Ivytown DMI2
               |----Device Class....................................1536 
               |----Device Class Name...............................Host bridge
               |----PIC Line........................................0 
               |----Old IRQ.........................................255 
               |----Vector..........................................0 
               |----PCI Pin.........................................4 
               |----Spawned Bus.....................................0 
               |----Flags...........................................521 
               \==+BAR Info : 

El TOP de VMware

El comando “esxtop” tiene prácticamente las mismas funcionalidades que el comando TOP de Linux:
esxtop

Reiniciar todos los servicios de un host ESXi

/sbin/services.sh restart

Modo mantenimiento del ESXi Host

Los siguientes comandos activan y deshabilitan el modo de mantenimento de un Host ESXi:
vim-cmd hostsvc/maintenance_mode_enter
vim-cmd hostsvc/maintenance_mode_exit

Comandos de networking

Ver interfaces de red

El comando “esxcfg-nics” permite gestionar las interfaces de red del host ESXi y el parámetro “-l” las lista:
esxcfg-nics -l
Name    PCI           Driver      Link Speed     Duplex MAC Address MTU    Description                   
vmnic0  0000:20:00.00 igb         Down 0Mbps     Half   00:10:e0: 1500   Intel Corporation I350 Gigabit Network Connection
vmnic1  0000:20:00.01 igb         Down 0Mbps     Half   00:10:e0: 1500   Intel Corporation I350 Gigabit Network Connection
vmnic2  0000:b0:00.00 ixgbe       Up   10000Mbps Full   00:1b:21: 1500   Intel Corporation 82599EB 10-Gigabit KX4 Network Connection
vmnic3  0000:b0:00.01 ixgbe       Up   10000Mbps Full   00:1b:21: 1500   Intel Corporation 82599EB 10-Gigabit KX4 Network Connection

Virtual Switches

Al igual que las interfaces de red, los virtual switches se pueden gestionar con el comando esxcfg-vswitch, para listarlos también usamos el parámetro “-l”:
esxcfg-vswitch -l
Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks   
vSwitch0         4352        18          128               1500    vmnic2,vmnic3

  PortGroup Name        VLAN ID  Used Ports  Uplinks   
  VM Network            4095    10          vmnic2,vmnic3
  VM Management Network 10      1           vmnic2,vmnic3
  iSCSI                 20      1           vmnic2,vmnic3
  Management Network    10      1           vmnic2,vmnic3
Tanto con las interfaces de red como los virtual switches podemos realizar operaciones avanzadas que normalmente se realizan gráficamente desde el vCenter.

Comandos de máquinas virtuales

Listado de máquinas virtuales

vim-cmd vmsvc/getallvms
Vmid             Name       File         Guest OS
1      vCenter   [vmware01] vCenter.vmx  VMware vCenter Server Appliance
10     redhat1   [vmware01] redhat01.vmx Red Hat Enterprise Linux

Arrancar, parar o reiniciar una máquina virtual

A partir del Vmid que sacamos con el comando anterior podemos controlar el estado de la máquina virtual:

Arrancar máquina virtual

vim-cmd vmsvc/power.on Vmid
vim-cmd vmsvc/power.on 10

Parar máquina virtual

vim-cmd vmsvc/power.off Vmid
vim-cmd vmsvc/power.off 10

Reiniciar máquina virtual

vim-cmd vmsvc/power.reboot Vmid
vim-cmd vmsvc/power.reboot 10


Ver el estado de una máquina virtual

vim-cmd vmsvc/power.getstate Vmid
vim-cmd vmsvc/power.getstate 10

Ver información y configuración de una máquina virtual

vim-cmd vmsvc/get.summary Vmid
 vim-cmd vmsvc/get.summary 10
Listsummary:

(vim.vm.Summary) {
   dynamicType = , 
   vm = 'vim.VirtualMachine:10', 
   runtime = (vim.vm.RuntimeInfo) {
      dynamicType = , 
      device = (vim.vm.DeviceRuntimeInfo) [
         (vim.vm.DeviceRuntimeInfo) {

Borrar una máquina virtual

El siguiente comando borra la máquina virtual, incluyendo tanto la configuración como el disco de la VM:
vim-cmd vmsvc/destroy Vmid
vim-cmd vmsvc/destroy 10

Publicar un comentario

0 Comentarios