Creating “Maintenance Mode” for AHV using X-Play

In Prism Central 5.11 we got introduced to a new feature called X-Play. X-Play is essentially an IFTTT for Nutanix. It can do basic things like send reports on a schedule or send an alert, but it can also do some more advanced things. I wont go into all the other things it can do here, but there is a lot, and there is some flexibility to get a little creative.

As a longtime VMware admin, “Maintenance Mode” has become a staple in hypervisor management. The lack of an easy option for this in AHV was, honestly, a little frustrating.  Does AHV have “Maintenance Mode”, yes it does, but its part of the CLI, not the GUI. When I started looking at what X-play’s playbooks could do, it dawned on me that it might be able to close the gap between common tasks that can only be done through the CLI, right now.

How do we do this…

First off you need Prism Central, since X-Play only works from there.

Click the menu button in the top left, go down to “Operations”, then “Playbooks”.

There are a few other options in this menu that pertain to X-Play, but we don’t need those right now.

 

 

 

Next Choose “Create PlayBook” at the top.

 

The “Entity Type” is “Host”. This determines where you will go to execute the play. In this case you will be executing it per Host.

Click “Add Action” on the left. For my configuration I chose “IP Address SSH”. So now we have some options. The first is the VM IP Address. Now, here is the catch, because Nutanix isn’t currently exposing the host’s cvm ip or cluster ip, these plays are “Cluster Specific”. In other words, you will need a play for each cluster. This IP should be you cluster IP or a CVM IP in the cluster.

Username and password will be your CVM’s login information.

Command to run. So, the command for putting a host into maintenance mode from the CLI is actually an ‘acli‘ command. Enter: ‘/home/nutanix/bin/acli host.enter_maintenance_mode {{trigger[0].source_entity_info.uuid}}

I added a Slack action as well to tell me whether it was successful. Follow the ‘Learn More’ to setup your Slack channel to support this. Also, notice there is a “Parameters” button at the bottom of the ‘Message’ box for customizing the message.

Last, but not least, we need an “Exit Maintenance Mode”. Follow the exact same instruction from above, only this time the command will be ever so slightly different. Enter: ‘/home/nutanix/bin/acli host.exit_maintenance_mode {{trigger[0].source_entity_info.uuid}}

Now, how do I use this? Well, while in Prism Central, Goto Hardware > Hosts. Click the check box next to the host you need to be evacuated. The “Actions” drop down will appear at the top of the page. Choose ‘Run Playbook’. You will then be able to choose from your plays. Then watch to see your VMs start moving off that host.

…and that is it. As X-Play evolves, i look forward to making more powerful plays and streamlining more actions.

Tags