What Changed? vCloud Director Integrity Scripts Unleashed

Posted by vele1655 | Posted in Powershell, Scripting, vCloud Director | Posted on 10-10-2012

Tags:

3

A really important thing in operating VMware vCloud Director is change management and being able to verify the integrity of configuration among your vApps.  This seems to be somewhat fresh terrain for PowerCLI so I took it upon myself to build some cmdlets that might help in many different situations.

  • What changed with vCD objects, specifically vApps and Templates?
  • What is different since the restore of my vCD objects?
  • How can I export all configuration information per vCD object?

For these purposes I built five new cmdlets, three of which are specific to vCloud Director.  The examples I provide are basic, the use cases specified can be far beyond what is listed here.

Requirements

  • PowerCLI 5.1 with vCloud
  • Tested with vCloud Director 5.1
  • Download the module here
  • Unzip module
  • Dir *.psm1 | Import-Module

Capabilities in this module

  • Export the raw Xml of a PowerCLI vCD object
  • Put configuration parameters per object in an easily readable format
  • Serialize/Deserialize the Xml to allow for modifying parameters without problematic parsing
  • Compare vCD objects to see what has changed

Export-CIXml

Something that is somewhat cool is the ability to leverage the REST interface of vCD to expose any and all portions of the API.  A really simple way to do this is to leverage the PowerCLI vCD module to establish a connection to vCD and then following use the authorization header to establish a separate session through a WebClient object.

From there you can leverage the existing cmdlets to look for objects (ie. Get-CIVApp | Get-CIVM) and pipe the Href parameter into the WebClient (REST GET).  Otherwise you would need to do all this yourself, overall a bit heavy but very easy.

Now what’s really cool is that once you issue the call to the Href, you get the full Xml result from the REST interface for the specific object.

Get-CIVApp vApp1 | Export-CIXml

image

And what do you do with this Xml?  Anything you want, but I will be converting this to an Xml object and then using it to nicely compare objects against each other.

Export-CIOvf

This gives the capability to export an Ovf for any VApp without instantiating a Download call (prepares VMDKs unnecessarily).

(Get-CIVApp vApp5e) | Export-CIOvf

image

 

Get-CIXmlObject

Now if we simply converted the Xml into an object it would be a bit of work to recurse through and find what we’re looking for.  For this purpose I wrote this cmdlet to allow us to recurse and build a single dimensional view while appending periods between the levels as the parameter name.  This allows us to then later easily run comparative queries against different objects.


(Get-CIVApp vApp1 | Export-CIXml) | Get-CIXmlObject

image

Compare-CIObject

Ok, now to the meat of it.  If you want to be able to compare the objects we leverage the work from prior and a more specific cmdlet here that does the comparison.  See the following screenshot where we simply specify the vCloud objects to look at, and then wallah we have a nice output of the differences between the two.  Notice on this example that we actually copied vApp1 to vApp2 so they are awfully similar except for a few things (StartupSection) being 1 (need to investigate this).

Compare-CIObject (Get-CIVApp vApp1) (Get-CIVApp vApp2)

image

 

Or how about the VMs in the VApp?

Compare-CIObject (Get-CIVApp vApp1 | Get-CIVM | Select -first 1) (Get-CIVApp vApp2 | Get-CIVM | Select -First 1)

image

 

Here we have another example of looking at templates.

Compare-CIObject (Get-CIVAppTemplate lguest-01-gold) (Get-CIVAppTemplate wguest-01-gold)

image

 

 

That’s it for now!

Comments (3)

[...] Permanent Link to What Changed- vCloud Director Integrity Scripts Unleashed [...]

[...] What Changed- vCloud Director Integrity Scripts Unleashed [...]

[...] Kitson, an EMC vSpecialist, talks about some VCD integrity scripts he created. Looks like some pretty cool stuff—great work, [...]

Write a comment


× four = twenty four