vMotion Check

It’s been almost a year since I read a post on vTesseract where Josh Atwell posted a PowerShell script that he had written that tests vMotion compatibility for virtual machines.

How cool is that? Now you can proactively check your clusters the day before your scheduled change so that you can fix any potential issues instead of finding them at 2 am.

Because I was curious how my environment was looking I wrote a PowerShell script based on Josh’s work that gave me a grid view of a cluster that shows each VM and what would happen if it tried to move to each host in the cluster. Unfortunately it is SLOOOOOW, with 350+ hosts and 6,000+ virtual machines it literally takes 24 hours to run. Part of that is definitely the way I coded it but I also have a sneaking suspicion that PowerShell is partly to blame.

Fast forward six months and I’m on this vOrchestrator kick and I thought to myself, wonder how much quicker I can make it run.

It turns out that it runs through a single cluster in a few seconds, now, I’m not doing everything I did with the PowerShell script, I’m just dumping out the results from the query. Think of this as a teaser, I’ll be working on recreating the rest of the stuff that I did with PowerShell in the future.

So what does the code look like?

First we get the SDK object that does the checking:

Once we have that it is just a matter of grabbing a collection of virtual machines and a collection of hosts.

Then all we have to do is to execute the queryVMotionCompatibilityEx_Task function, passing it the list of virtual machines and hosts.

After we wait for the task to complete we get an array of VcCheckResult objects that we can loop over and print out the results.
The VcCheckResults objects have a error property and a warning property that are arrays of VcLocalizedMethodFault, these in turn have a property called localizedMessage that contains the error/warning message.

No package this time, when I get the rest of the script converted over I’ll post the code for that.

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">