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!