Y U NO vMotion!?!?
The Story
You’ve been there. Sitting at vSphere client waiting for the clock to hit 10:00pm so that you can start your maintenance change. You plan to do host updates so you need to put each host in maintenance mode. And away you go…
“Wait! Stuck at 2%!?!”
“What’s going on?”
“Why is this VM not moving!?”
“Fine, I’ll move it manual…UGGH… Y U NO vMotion!?!?!”

Several months ago my coworker, Jade, and I decided that we really needed to buckle down and find a way to identify VMs in a cluster that can not vMotion. We had seen and heard about more and more issues where VMs were not migrating off for a variety of reasons during the small change windows.
The biggest pain point for this was trying to identify all of the possible criteria that would prevent a vMotion on a VM. Through our discussion we came to the conclusion that there MUST be an existing method in vSphere since it does a similar check when you manually attempt to migrate a VM. Off to the interwebs we went. A quick search on the vSphere API Reference guide we identified the .CheckMigrate method.
After banging our head on the desk a few days Hal Rottenberg came to the rescue and provided us the necessary code required to get to the method. I now had something that could run the check and began to build the function around this code. This is where things got complicated and exciting.
A few months passed as I was making slow progress but was finding issues with some of the error/warning output. A quick conversation and email exchange with Alan Renouf got me straight on parsing these messages to get meaningful information.
The Functionality
After several days of work and validation the script now allows you to test the following:
- All VMs in a Cluster (Random host or to a specific host)
- A single VM (Random host or to a specific host)
- Limited pipeline capability for checking an entire cluster (This will be expanded soon)
- Ability to turn off all console output so script can be used in console or as scheduled task.
We’re in the process of working this function into our auditing so that we can know well in advanced of any change if there are any VMs that may cause us problems. Our goal is to reduce the uncertainty and hopefully save lots of time.
Some console screenshots courtesy of Alan Renouf. Unfortunately my production tests had to be redacted to the point of uselessness and my homelab is under rebuild. Can you say #VMTNSubscriptionMovement? :) Thanks Alan!


The Future
I have identified some additional functionality and have made some plans on expanding this function in 2012 so I’m looking forward to your thoughts and feedback. Hope you find it helpful and it saves you some time.
The Contributors
Huge thanks to these Contributors and Validation folks.
- Hal Rottenberg
- Alan Renouf
- Jade Lester
- Josh Coen
THE SCRIPT is located here:
http://communities.vmware.com/docs/DOC-17941
Links
http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.check.ProvisioningChecker.html#checkMigrate