Virtualization Pro

Dec 14 2007   8:18PM GMT

Generating the XML necessary to create VMs with the VI Perl Toolkit

Kutz Profile: Akutz

It is a pain in the rear to generate XML on the fly. There just is not a fun way of doing it. Unfortunately this is what is required when creating, cloning, and altering VMs with the VI Perl toolkit. I went ahead and creating a very simple Perl script that will take HTML GET variables from the query string and build the necessary HTML. I also created an extremely simple HTML form to try out the script. Alternatively, you could call the script from Perl using the command wget. For example:

wget -O vmcreate.xml "http://www.lostcreations.com/cgi-bin/vmcreate2xml.pl?name=www.lostcreations.com&host=esx01.lostcreations.local&datacenter=red&guestId=Windows+2003&datastore=storage-san-vms03&disksize=10240&memory=10240&numberOfProcessor=1&nicNetwork=p-vlan-104&nicPoweron=1"

This command will turn your input into a properly formatted XML file called vmcreate.xml that can be used with the VI Perl Toolkit command, vmcreate.pl, in order to create a VM.

The vmcreate2xml.pl script takes the following input variables:

name: The name of the VM to create.
host: The host to initially create the VM on.
datacenter: The datacenter to create the VM in.
guestId: The guest ID of the VM. E.g. Windows 2003
datastore: The datastore to place the VM’s files in.
disksize: The size of the VM’s hard disk in megabytes.
memory: The amount of memory to allocate to the VM in megabytes.
numberOfProcessor: The number of processors to allocate to the VM.
nicNetwork: The name of the port group to assign the VM to.
nicPoweron: Whether or not the NIC is powered on (0=off,1=on)

Hope this helps!

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: