Power and maintenance operations in ESXi 5.1 with esxcli

September 18, 2012 — 4 Comments

ESXi 5.1 comes with many improvements and one of them is new namespaces and commands in esxcli.

Those new commands enable a system administrator to perform a shutdown, a reboot or a maintenance operation in a host.

Under the system namespace the new commands are the equivalents of the classic vicfg/esxcfg-hostops which until now was the only way to perform such kind of operations with vCLI and are also accesible locally on ESXi Shell.

image

Maintenance mode operations

Getting the basic usage of the command is as simple as always. You can perform two operations.

  • Get the state of the host
  • Put the the host in or out of Maintenance Mode
~ # esxcli system maintenanceMode 
Usage: esxcli system maintenanceMode {cmd} [cmd options]
Available Commands: 
  get                   Get the maintenance mode state of the system. 
  set                   Enable or disable the maintenance mode of the system. 
~ #
  • Get the state of the host
~ # esxcli system maintenanceMode get 
Disabled 
~ #
  • Put the host in Maintenance Mode
~ # esxcli system maintenanceMode set -e true -t 0 
~ # 
~ # esxcli system maintenanceMode get 
Enabled 
~ #

Power operations

With the shutdown command the host can be either rebooted or shutdown. If the ESXi server is not in Maintenance Mode mode the operation will not be allowed.

~ # esxcli system shutdown 
Usage: esxcli system shutdown {cmd} [cmd options]
Available Commands: 
  poweroff              Power off the system. The host must be in maintenance mode. 
  reboot                Reboot the system. The host must be in maintenance mode. 
~ #

For both task the delay and reason parameter must be provided.

~ # esxcli system shutdown poweroff 
Error: Missing required parameter -r|--reason
Usage: esxcli system shutdown poweroff [cmd options]
Description: 
  poweroff              Power off the system. The host must be in maintenance mode.
Cmd options: 
  -d|--delay=<long>     Delay interval in seconds 
  -r|--reason=<str>     Reason for performing the operation (required) 
~ #
  • Power off the host
~ # esxcli system shutdown poweroff --delay=10 --reason=”Hardware maintenance”
  • Reboot the host
~ # esxcli system shutdown reboot -d 10 –r “Patches applied”

Juanma.

About these ads

4 responses to Power and maintenance operations in ESXi 5.1 with esxcli

  1. 

    Thanks for your post. I’ve found that when using the following command:

    ‘esxcli system shutdown poweroff -d 10 -r test’

    results in the host becoming unresponsive to WOL requests, but powering off via the vSphere client will allow a WOL packet to boot the machine.

    Any ideas on how to get round this? I would like to be able to script the powering down of the VMs and the Host and still allow a remote boot via WOL.

    Cheers,

  2. 

    Thank for the article. One thing that I am looking for is if one can use esxcli to stop / start the tsm-ssh service. I have yet to find anything.

Trackbacks and Pingbacks:

  1. Welcome to vSphere-land! » vSphere 5.1 Link-O-Rama - September 19, 2012

    [...] 5.1 Free with no vRAM limit but physical RAM limit of 32Gb (ESX Virtualization) Power and maintenance operations in ESXi 5.1 with esxcli (Juanma’s Blog) Host warning for ESXi Shell and SSH appear on a ESXi 5.1 host (KB Article) [...]

  2. vSphere 5.1 Link-O-Rama « Osvaldoneris's Blog - December 3, 2012

    [...] 5.1 Free with no vRAM limit but physical RAM limit of 32Gb (ESX Virtualization) Power and maintenance operations in ESXi 5.1 with esxcli (Juanma’s Blog) Host warning for ESXi Shell and SSH appear on a ESXi 5.1 host (KB Article) ESXi [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s