vmclone.pl - clone, customize virtual machine and the guest.
perl vmclone.pl --username <server login name> --password <server login password> --operation clone --vmhost <Name of the ESX server> --vmname <Name of the virtual machine> --vmname_destination <Name of the clone> --url <web service URL> --customize_guest [yes/no] --customize_vm [yes/no] --filename <input XML file> --schema <schema file>
This VI Perl command-line utility provides an interface for creating clone of the VM's. One can customize the VM or the guest while creating the clone of the virtual machine.
Operation is clone
URL to the virtual center. E.g https://192.168.111.52/sdk/vimService
Required. Name of the host containing the ESX server
Required .Name of the virtual machine whose clone is to be created
Required. Name of the clone VM which will be created
Optional. Datacenter Name, if it is not given script will search for default datacenter
Required . Name of the host containing the ESX server
Required. Name of the virtual machine whose clone is to be created
Required. Name of the clone which will be created
Required. Customize guest is used to customize the network settings of the guest operating system Options are Yes/No
Required. It is the name of the file in which values of parameters to be customized is written e.g. --filename clone_vm.xml.
Required. It is the name of the schema which validates the filename
Optional. Datacenter Name, if it is not given script will search for default datacenter
Required. Name of the host containing the ESX server
Required. Name of the virtual machine whose clone is to be created
Required. Name of the clone which will be created
Required. customize_vm is used to customize the virtual machine settings like disksize, memory If yes is written it will be customized
Required. It is the name of the file in which values of parameters to be customized is written e.g. --filename clone_vm.xml.
Required. It is the name of the schema which validates the filename
Optional. Datacenter Name, if it is not given script will search for default datacenter
Making a clone without any customization::
perl vmclone.pl --username username --password mypassword --operation clone --vmhost 192.168.111.2 --vmname DVM1 --vmname_destination DVM99 --url https://192.168.111.52/sdk/vimService
If datastore is given:
perl vmclone.pl --username username --password mypassword --operation clone --vmhost 192.168.111.2 --vmname DVM1 --vmname_destination DVM99 --url https://192.168.111.52/sdk/vimService --datastore storage1
Making a clone and customizing the VM
perl vmclone.pl --username myusername --password mypassword --operation clone --vmhost 192.168.111.2 --vmname DVM1 --vmname_destination Clone_VM --url https://192.168.111.52/sdk/vimService --customize_vm yes --filename clone_vm.xml --schema clone_schema.xsd
All the parameters which are to customized are writtend in the xml file in this format:
<?xml version="1.0"?>
<specification>
<configspec>
<vmname>T0I</vmname>
<vmhost>192.168.111.2</vmhost>
<datacenter>Dracula</datacenter>
<guestid>winXPProGuest</guestid>
<datastore>storage1</datastore>
<disksize>5096</disksize>
<memory>256</memory>
<num_cpus>2</num_cpus>
<nic_network>VM Network</nic_network>
<nic_poweron>1</nic_poweron>
</configspec>
</specification>
Making a clone and customizing the guestOS::
perl vmclone.pl --username myuser --password mypassword --operation clone --vmhost 192.168.111.2 --vmname DVM1 --vmname_destination DVM99 --url https://192.168.111.52/sdk/vimService --customize_guest yes --filename clone_vm.xml --schema clone_schema.xsd
All the parameters which are to customized are writtend in the xml file in this format:
<?xml version="1.0"?>
<specification>
<customizationspec>
<autologon>1</autologon>
<computername>VM9</computername>
<timezone>033</timezone>
<domain_user_name>username</domain_user_name>
<domain_user_password>password</domain_user_password>
<domain>InterraIT.info</domain>
<fullname>admin</fullname>
<orgname>Interrait</orgname>
</customizationspec>
</specification>
Making a clone and customizing both guestos and VM
perl vmclone.pl --username myuser --password mypassword --operation clone --vmhost 192.168.111.2 --vmname DVM1 --vmname_destination DVM99 --url https://192.168.111.52/sdk/vimService --customize_guest yes --customize_vm yes --filename clone_vm.xml --schema clone_schema.xsd
All operations supported on Virtual Center 2.0.1