2012
08.14

In my current job, I monitor the lab environment, educate users on usage of the lab and take user requests to create vApp environments for them to reproduce customer issues.

For the most part because things almost never break it is the education and vApp creation that takes up the bulk of my time.

I don’t know if you have ever used vCloud Director, but creating a vApp requires going through a series of questions, What do you want to call it? What vApp templates do you want to add? Do you want to make new VMs? Do you want to add networking? Do you want static, DHCP or manual Ips? Do you need to configure the vApp network services? Is this all correct?

In any event, I created a standard I follow when I build these environments and I almost always answer the questions the same so that 5-10 min of answering questions can be time consuming over the course of a week. Around a week ago I encountered a slow period where the questions and environments slowed to a drizzle so I decided to take the time to explore the vCD API and see if I could create some tools to make things a bit more stream lined.

First I created a reporting script, it shows me each org, the VM’s within the ORG and active users (an active user counting as a user with a running vApp deployed), VM count, powered on state and datastore usage. After getting my feet wet I decided to dive a little deeper and create a script I could use to deploy a vApp from command line.

Day 1, I was able to create a vApp and add VM’s of my choice to it
Day 2, I was able to specify Isolated, Routed or direct networking
Day 3, Provision networking features such as Firewall, DHCP
Day 4, Handle repeat VMs, power on vApps after creation, an option wait flag so I would know when the whole process was complete, an easy to modify table of templates linked to hash flags for easy expandability, code clean up with some helper functions

In essence, it worked beyond my wildest expectations.

Here is a sample output of the usage screen and a run time of the script:

Usage:
$ deployrepro -o Org -v vApp --win7 --win2k3 --win2k8 --vsa --ad --sql --vc50 --vc50u1 --vc41u2 --lan

[vApp]
-o|--org  <orgname>     [req] Name of Organization for vApp placement
-v|--vapp <vAppName>    [req] Name of the vApp to create
-p|--on                       Power on vApp after it is created
-w|--wait                     Script will wait for running operations to complete before exiting

[Vms]
--win7=     <OptionalName> add Windows 7 template to vApp
--win2k3=   <OptionalName> add Windows 2003 template to vApp
--win2k8=   <OptionalName> add Windows 2008 R2 template to vApp
--vsa=      <OptionalName> Add VSA storage template to vApp
--ad=       <OptionalName> Add Active directory template to vApp
--sql=      <OptionalName> Add SQL 2008 template to vApp
--vc50 --vc50u1 --vc41u2 Add Virtual Center template to vApp
--tools=    <OptionalName> Add the Tools VM template to vApp
--rhel=     <OptionalName> Add Red hat 6.2 template to vApp
--centos=   <OptionalName> Add CentOS 6.2 template to vApp
--ubuntu=   <OptionalName> Add Ubuntu 12.04 template to vApp
[Networks]
--lan       Add vApp network of the default 192.168.2.x range to vApp
--landirect Add vApp network of the default 192.168.2.x range connected to the Org direct
--direct    Add direct Org network connection
--dhcp      Enable DHCP server
--firewall  Enable Firewall

phil@somehost:~$ deployrepro -o SomeOrg -v "pspencer example" --win7 --rhel --landirect -w -p
deployrepro 0.3 by Phil Spencer
vApp Compose initiated
Waiting for vApp compose to finish...
vApp power on initiated
Waiting for the vApp power on to finish...
Operation completed

I have also made some other helper apps such as lsorg, lscatalog, lsvapps to ease some of the repetitiveness of the day. If you use a vCloud environment make sure you take the time to explore the API it is well worth it. In the above scripts I was using the PHP SDK, there is also a Java and C# SDK available and you can also work with the REST API directly if you so choose to do so.

Check it out.

 

 

Facebook Comments

No Comment.

Add Your Comment

You must be logged in to post a comment.