Tag Archives: vCloud Director

Working with vCD Edge Gateway Rules in PowerCLI

Recently I was working with someone helping them automate the final part of their script which was used to deploy new customers as they were on boarded in vCloud Director 5.5, as part of this on boarding they needed to work with the Edge Gateway to add new SNAT and DNAT rules which correspond with the customers IP range.

After some investigation and reading this page I was able to find the basics, after some further testing and internal help I found that there is no way to update a single record so I had to retrieve the existing XML ruleset, add the new entry and then upload it.  You can see from the scripts how I do this and if you are feeling adventurous or have the need you could even create some remove- functions!

If you take a look at my Edge Gateway below you can see two existing rules, lets see what the functions do that I created.

TinyGrab Screen Shot 24-07-2014 22.31.21

Using the PowerCLI functions you can easily list the edge gateway rules using the following:

TinyGrab Screen Shot 24-07-2014 22.55.19

Creating a new SNAT rule is just as easy with the New-SNATRule function as you can see below:

TinyGrab Screen Shot 24-07-2014 22.59.55

And also a DNAT Rule with the New-DNATRule function as below:

TinyGrab Screen Shot 24-07-2014 23.01.48

Hopefully you will find this useful, feedback is of course welcome below in the comments section.

The Functions

Automating storage with NetApp Workflow Automation

Do you wish you could automate your NetApp Storage infrastructure?

Do you wish your storage admins could give an easy to use custom interface to other areas of the business allowing them to provision or use storage however they need whilst still applying best practice and corporate policies to the configuration?

Continue reading Automating storage with NetApp Workflow Automation

vCDAudit for vCloud Director

imageSometimes its hard to retrieve a report or data that you want to see in one place from a pre-built GUI, I often see this as a use case with PowerShell, being able to grab the data that you want to see and export it or report on it in a unified and simple way.  With the release of vCheck 6 and the easy to adapt HTML framework I have a very easy way to do just this, with a few simple changes to the plugins we can easily add any product into the reporting framework.

Currently this has been the case for vSphere and Exchange 2010.

A college of mine Tom Stephens who works for VMware Technical Marketing contacted me last week with a request which fits into the vCheck Framework quite nicely.  He was working with a customer who needed to be able to report on their vCD infrastructure, they had a need to be able to audit their vCD infrastructure and return certain data back in a centralized easy to read fashion.  He sent me a few headings of things the customer would like to see, after just a short period of time I was able to send him a working report with what the customer needed (and a little more I think).

This brings me on to what I call “vCDAudit”, unlike the vSphere health check script this is an audit script which retrieves and presents key vCD Data which is otherwise hard to find in a centralized place.

Example Page

An example of the vCDAudit report can be viewed by clicking here.


To download this version of vCheck you can download the following file which includes the base script and all VCDAudit plugins:


For more information on the base vCheck script and its framework including a demo of how to use it visit this page.


Removing the vCD Agent from hosts

When re-installing my vCD home lab I had an issue when I went to re-add some hosts which had already been used in a vCD environment, this was because the hosts had already been “prepared” by vCD and therefore had the “vcloud-agent” vib installed.  Of course you would normally unprepare these from the vCD web interface before deleting your vCD instance but I forgot to do this.

I was then pointed to Chris Colotti’s post here which showed how to manually remove the vCD agent from hosts in this situation.

As I had a few of them to do I didn’t want to repeat myself and therefore wrote a quick PowerCLI Script to remove the agents for me.

Another thing I couldn’t see in Chris’s post which I had to do before it was fully removed was reboot the host so I added that into the script too.

Checking for hosts with the vCD Agent installed

We can easily see the hosts which have the vCD agent installed by running the following PowerCLI code:

Connect-VIServer MyVIServer -User Administrator –Password “Pa$$word”
Get-VMHost | Sort Name | Foreach {
    $ESXCLI = Get-EsxCli -VMHost $_ -ErrorAction SilentlyContinue
    $ESXCLI.software.vib.list() | Where { $_.Name -like "*vCloud*"} | Select @{N="VMHost";E={$ESXCLI.VMHost}}, Name, Version

We would receive the following output:


Removing the vCD Agents

Due to an issue with the way PowerCLI calls ESXCLI I have had to make the script slightly more complicated than it needs to be but it still does the job.  It will go through each host and remove the “vcloud-agent” vib and then reboot them ready to be added into the new vCD instance.

# The following two variables are used to define the esx hosts local login details
$HostUser = "root"
$HostPass = "localpa$$"

$vCenter = Connect-VIServer MyviServer -User Administrator –Password “Pa$$word”
Get-Cluster | Get-VMHost | Sort Name | Foreach {
    $ESXCLI = Get-EsxCli -VMHost $_ -ErrorAction SilentlyContinue
     $vCDHosts = $ESXCLI.software.vib.list() | Where { $_.Name -like "*vCloud*"} | Select @{N="VMHost";E={$ESXCLI.VMHost}}, Name, Version

$vCenter | Disconnect-VIServer -Force -Confirm:$false

# Because of a bug in PowerCLI with ESXCLI we need to connect to each host individually and not through vCenter
$vCDHosts | Foreach {
    $VMHCon = Connect-VIServer ($_.VmHost) -User $HostUser -Password $HostPass
    Write-Host "Removing vCloud Agent for $($_.VMHost)"
    $ESXCLI = Get-EsxCli -ErrorAction SilentlyContinue
    $ESXCLI.software.vib.remove($false, $true, $false, $true, $_.Name)
    # During testing I found a reboot was needed
    Write-Host "Rebooting host $($_.VMHost)"
    Restart-VMHost -VMHost $_.VmHost -Confirm:$false
    $VMHCon | Disconnect-VIServer -Confirm:$false

vCloud Director 1.0 PowerShell Advanced Functions

Its no secret that VMware are working on vCloud Director (vCD) cmdlets, they recently surveyed the PowerShell and VMware community to make sure they had all the information needed to make this as much of a success as the vSphere PowerCLI cmdlets.

But did you know you can already use PowerShell with vCD ?  It should be no surprise to anyone who uses PowerShell to know that PowerShell does a great job with XML manipulation and API calls.

As part of vCD 1.0 there was obviously an API, this was based on REST which is essentially calls to web pages and sending/receiving data, so with the knowledge that this API is available and that PowerShell is a great way to communicate with this API all that was left was for someone to tie all this together and create some advanced functions which can be used against the vCloud API…. enter Jake Robinson.


Jake has been doing some great work recently, personally I have spoken to him a couple of times and had the privilege of meeting him at VMworld 2011 Las Vegas, he is a great guy and very knowledgeable about both PowerShell and vCD so the perfect guy to create some advanced functions.

The functions can be downloaded from here:

Download: https://github.com/jakerobinson/vCloud-Powershell

I would also recommend checking out his great video on what he has created and some examples of how these can be used published here on his blog (add to your RSS feed) and also embedded below. Continue reading vCloud Director 1.0 PowerShell Advanced Functions

PowerCLI for vCloud Director–Have your say !

VMware have recently announced a survey on the PowerCLI site, this has been setup timageo poll people for what they think would be the best way to introduce cmdlets for vCloud Director, personally I think it’s a great move and proves that VMware really does listen to their customers opinions.

Their questions not only ask how you would like the vCloud cmdlets distributed but also if you would prefer common objects like VMs and Users to be new cmdlets based towards vCloud director or to add these as additional parameters to the existing cmdlets.

Personally when answering these questions I have to remind myself of a few things and ask myself a few questions:

  • vCloud Org users or tenants are going to be interested in different things than a vSphere admin, for example, does a tenant care about the details of the datastore so long as they are getting what they paid for, do they care about things like what host the VM or even what vCenter the VM is hosted in ? With this in mind do they really want to see the full set of “vSphere Properties” for an object or would a new set of properties based on the cloud information be relevant, similar with the cmdlets, do they want to see all the vSphere cmdlets or would a more specific set of cmdlets be better ?
  • Will vCloud Admins want to connect to both the vCloud and the vCenter at the same time ?  How will this work, when connected to both what would they expect to be displayed when running Get-VM? vSphere VMs, vCloud VMs both ? How would the properties be displayed ?
  • Will vCloud admins want to take a cloud VM and perform vSphere actions against the VM ?

Continue reading PowerCLI for vCloud Director–Have your say !

Auto Deploy and vCloud Director

When re-installing my home lab I realized that when using Auto Deploy with vCloud Director (vCD) you would need to have an extra step in the planning process, this makes sense if you think about the way that Auto Deploy and vCD works.

vCloud Director installs an agent on the ESXi host which is used for deploying virtual machines and other operations, if you think about the way Auto Deploy works, any change that is made to the host which is not part of your initial Image Profile or set in your Host Profile will be removed if the host is rebooted, this includes the vCD Agent.

On installing the VCD agent I was presented with the following error:


So  I did as advised and consulted the documentation and found the following:

Continue reading Auto Deploy and vCloud Director