Alarms – Cody’s Abandon Ship

Yesterday, Cody published on his Professional VMware blog an excellent article, called vSphere Host Died Abandon Ship! – vSphere vCenter Alarms & Actions.

The article shows a very elegant solution how to move your guests to “safer havens”, the moment one of the hosts in the cluster starts experiencing hardware problems.
The elegance of Cody’s solution is that he uses maintenance mode to force vMotion on all the powered-on guests on the host that experiences HW problems.

The condition for the solution to work is of course that the host needs to be a node in a DRS-enabled cluster where the Automation Level is set to Fully automated.

Since I thought that this was a good example of some of the alarm-related posts I did in the past, I created a script so you can automate the creation of Cody’s alarm.

Annotations

Line 1: The script creates the alarm on a datacenter but you can easily replace that by any object that supports alarm definitions.

Line 26: When the alarm is fired this action will make a call to the EnterMaintenanceMode_Task.

Line 29-35: The EnterMaintenanceMode_Task method requires two arguments. For the first argument, called timeout, we specify 0 (zero) which indicates there is no timeout. The second argument, called evacuatePoweredOffVms, is a Boolean value that indicates if powered-off guests should also be migrated. We pass $false, meaning that the powered-off guest shall not be migrated.

Line 52-56: See my earlier post, called Alarm expressions – Part 2 : Event alarms, for more information on how to list the available events.

The result of the script is a new alarm identical to the one Cody created in the vSphere client.

With this script you can now include the creation of this alarm in your automation process.

And the script has also shown that it is more flexible than the vSphere client. Try for example changing the parameters of the method (in this case EnterMaintenanceMode_Task) you use in the Actions.

2 Comments

    Cody Bunch

    Nice!

    Carter Shanklin

    Very nice!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.