vmcreate.pl - Creates virtual machines as per the specifications provided in the input XML file.
vmcreate.pl [options]
This VI Perl command-line utility provides an interface for creating one or more new virtual machines based on the parameters specified in the input valid XML file. The syntax of the XML file is validated against the specified schema file.
Optional. The location of the XML file which contains the specifications of the virtual machines to be created. If this option is not specified, then the default file 'vmcreate.xml' will be used from the ``../sampledata'' directory. The user can use this file as a reference to create there own input XML files and specify the file's location using the <filename> option.
Optional. The location of the schema file against which the input XML file is validated. If this option is not specified, then the file 'vmcreate.xsd' will be used from the ``../schema'' directory. This file need not be modified by the user.
The parameters for creating the virtual machine are specified in an XML file. The structure of the input XML file is:
<virtual-machines> <VM> <!--Several parameters like machine name, guest OS, memory etc--> </VM> . . . <VM> </VM> </virtual-machines>
Following are the input parameters:
Required. Name of the virtual machine to be created.
Required. Name of the host.
Required. Name of the datacenter.
Optional. Guest operating system identifier. Default: 'winXPProGuest'.
Optional. Name of the datastore. Default: Any accessible datastore with free space greater than the disksize specified.
Optional. Capacity of the virtual disk (in KB). Default: 4096
Optional. Size of virtual machine's memory (in MB). Default: 256
Optional. Number of virtual processors in a virtual machine. Default: 1
Optional. Network name. Default: Any accessible network.
Optional. Flag to specify whether or not to connect the device when the virtual machine starts. Default: 1
Create five new virtual machines as per the specification given in the following input XML file:
<?xml version="1.0"?> <Virtual-Machines> <Virtual-Machine> <Name>VirtualA1</Name> <Host>111.112.111.2</Host> <Datacenter>Dracula</Datacenter> <Guest-Id>winXPProGuest</Guest-Id> <Datastore>storage1</Datastore> <Disksize>4096</Disksize> <Memory>256</Memory> <Number-of-Processor>1</Number-of-Processor> <Nic-Network>VM Network</Nic-Network> <Nic-Poweron>0</Nic-Poweron> </Virtual-Machine> <Virtual-Machine> <Name>VirtualA2</Name> <Host>111.112.111.2</Host> <Datacenter>Dracula</Datacenter> <Guest-Id>winXPProGuest</Guest-Id> <Datastore>storage1</Datastore> <Disksize>4096</Disksize> <Memory>256</Memory> <Number-of-Processor>1</Number-of-Processor> <Nic-Network>VM Network</Nic-Network> <Nic-Poweron>0</Nic-Poweron> </Virtual-Machine> </Virtual-Machines>
The command to run the vmcreate script is:
vmcreate.pl --url https://<ipaddress>:<port>/sdk/webService --username administrator --password mypassword --filename create_vm.xml --schema schema.xsd
The script will continue to create the next virtual machines even if some previous machine creation process is failed.
The output of the above script is:
-------------------------------------------------------------- Successfully created virtual machine: 'VirtualA1'
Successfully created virtual machine: 'VirtualA2' --------------------------------------------------------------
Create operation work with VMware VirtualCenter 2.0 or later.