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 ""

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,, in order to create a VM.

The 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.

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:

Share this item with your network: