VMware Cloud Community
Matthias_Hehnen
VMware Employee
VMware Employee
Jump to solution

Initiate ESX Maintenance mode through the vCLI

I wonder, if it's possible to initiate a complete ESX maintenance mode using the vCLI.

There are at least two commands available, however non of them is eager to migrate running VM's to other ESX hosts.

Thats - however - possible using the GUI from vCenter. If you activate the ESX maintenance mode in the GUI, running VM's will be migrated before the ESX sever enters the maintenance mode.

Unfortulately migrating running VM's manually via the vCLI might also not be an option, since DRS might start moving other running VM's back to the ESX server, which should enter into the maintenance mode. To avoid this, it would be required to stop also the DRR automated mode.

It would be therefore excellent, if there is a command or an option available, which would do all that automatically. Since it works over the GUI, it should not be so difficult to trigger this process also from the vCLI.

Perhaps it's already implemented - and I just do not know about it. So any hint would be more than helpful.

Otherwise: Are there any other ideas (perhaps already available scripts), which would help here?

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Actually there are a variety of scripts that are bundled with the vCLI that many aren't aware of dubbed "vSphere SDK for Perl Utilities" and one of which hostops.pl allows you to perform various host operations against a specific ESX(i) host, unfortunately the implemented version by VMware does not properly handle maintenance mode operation within a vCenter cluster and hence if you used it, it would not evacuate any running VMs.

I quickly wrote up my own version which takes vCenter into consideration and this script is to be executed against vCenter with a list of ESX(i) hosts to perform a certain operation and with the current version of the script it supports both entering/exiting maintenance mode.

Check out this script for instructions/requirements:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
3 Replies
lamw
Community Manager
Community Manager
Jump to solution

Actually there are a variety of scripts that are bundled with the vCLI that many aren't aware of dubbed "vSphere SDK for Perl Utilities" and one of which hostops.pl allows you to perform various host operations against a specific ESX(i) host, unfortunately the implemented version by VMware does not properly handle maintenance mode operation within a vCenter cluster and hence if you used it, it would not evacuate any running VMs.

I quickly wrote up my own version which takes vCenter into consideration and this script is to be executed against vCenter with a list of ESX(i) hosts to perform a certain operation and with the current version of the script it supports both entering/exiting maintenance mode.

Check out this script for instructions/requirements:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
wbdan
Contributor
Contributor
Jump to solution

Hi,

First, thanks for the Script.

Since hostops.pl did not migrate the VMs, I began to write a Script based on vmmigrate.pl.

Then my Collegue found your Script William, and was Happy.

Anyway, there is one Thing we nee.

Is ist possible to cancel the running Task ?

We have here a Cluster of ESX4 and vsphere/VCenter 4.

The ESX Servers are located in separatly Romms, each with a dedicated UPS.

In Case of Power breakdown, we have a script, that returns the runtime left on Battery Power.

If the runtime becomes Critical It invokes your Script, setting the Host in Maintenance Mode so that the VMs will migrate off.

When the Power comes Back, or the Emergency Generator is online, i want to cancel the Task.

Stefan

0 Kudos
wbdan
Contributor
Contributor
Jump to solution

Ok,

Sometimes its easy:

$task_view->CancelTask;

Stefan

0 Kudos