NAME

vmcreate.pl - Create Virtual Machines as per the specifications provided in the input XML file.


SYNOPSIS

 vmcreate.pl [options]


DESCRIPTION

This command 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.


OPTIONS

filename

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 referance to create there own input XML files and specify the file's location using <filename> option.

schema

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.

INPUT PARAMETERS

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:

vmname

Required. Name of the virtual machine to be created.

vmhost

Required. Name of the host.

datacenter

Required. Name of the datacenter.

guestid

Optional. Guest operating system identifier. Default: 'winXPProGuest'.

datastore

Optional. Name of the datastore. Default: Any accessible datastore with free space greater than the disksize specified.

disksize

Optional. Capacity of the virtual disk (in KB). Default: 4096

memory

Optional. Size of virtual machine's memory (in MB). Default: 256

num_cpus

Optional. Number of virtual processors in a virtual machine. Default: 1

nic_network

Optional. Network name. Default: Any accessible network.

nic_poweron

Optional. Flag to specify whether or not to connect the device when the virtual machine starts. Default: 1


EXAMPLE

Create five new virtual machines with the following configuration:

 Machine 1:
      Name             : Virtual_1
      Host             : 192.168.111.2
      Datacenter       : Dracula
      Guest Os         : Windows Server 2003, Enterprise Edition
      Datastore        : storage1
      Disk size        : 4096 KB
      Memory           : 256 MB
      Number of CPUs   : 1
      Network          : VM Network
      nic_poweron flag : 0
 Machine 2:
      Name             : Virtual_2
      Host             : <Any Invalid Name, say Host123>
      Datacenter       : Dracula
      Guest Os         : Red Hat Enterprise Linux 4
      Datastore        : storage1
      Disk size        : 4096 KB
      Memory           : 256 MB
      Number of CPUs   : 1
      Network          : VM Network
      nic_poweron flag : 0
 Machine 3:
      Name             : Virtual_3
      Host             : 192.168.111.2
      Datacenter       : Dracula
      Guest Os         : Windows XP Professional
      Datastore        : <Invalid datastore name, say DataABC>
      Disk size        : 4096 KB
      Memory           : 256 MB
      Number of CPUs   : 1
      Network          : VM Network
      nic_poweron flag : 0
 Machine 4:
      Name             : Virtual_4
      Host             : 192.168.111.2
      Datacenter       : Dracula
      Guest Os         : Solaris 9
      Datastore        : storage1
      Disk size        : <No disk size; default value will be used>
      Memory           : 128 MB
      Number of CPUs   : 1
      Network          : VM Network
      nic_poweron flag : 0
 Machine 5:
      Name             : Virtual_5
      Host             : 192.168.111.2
      Datacenter       : Dracula
      Guest Os         : <No guest OS, default will be used>
      Datastore        : storage1
      Disk size        : 2048 KB
      Memory           : 128 MB
      Number of CPUs   : 1
      Network          : <No network name, default will be used>
      nic_poweron flag : 1

To create five virtual machines as specified, use the following input XML file:

 <?xml version="1.0"?>
 <virtual-machines>
   <VM>
      <vmname>Virtual_1</vmname>
      <vmhost>192.168.111.2</vmhost>
      <datacenter>Dracula</datacenter>
      <guestid>winNetEnterpriseGuest</guestid>
      <datastore>storage1</datastore>
      <disksize>4096</disksize>
      <memory>256</memory>
      <num_cpus>1</num_cpus>
      <nic_network>VM Network</nic_network>
      <nic_poweron>0</nic_poweron>
   </VM>
   <VM>
      <vmname>Virtual_2</vmname>
      <vmhost>Host123</vmhost>
      <datacenter>Dracula</datacenter>
      <guestid>rhel4Guest</guestid>
      <datastore>storage1</datastore>
      <disksize>4096</disksize>
      <memory>256</memory>
      <num_cpus>1</num_cpus>
      <nic_network>VM Network</nic_network>
      <nic_poweron>0</nic_poweron>
   </VM>
   <VM>
      <vmname>Virtual_3</vmname>
      <vmhost>192.168.111.2</vmhost>
      <datacenter>Dracula</datacenter>
      <guestid>winXPProGuest</guestid>
      <datastore>DataABC</datastore>
      <disksize>4096</disksize>
      <memory>256</memory>
      <num_cpus>1</num_cpus>
      <nic_network>VM Network</nic_network>
      <nic_poweron>0</nic_poweron>
   </VM>
   <VM>
      <vmname>Virtual_4</vmname>
      <vmhost>192.168.111.2</vmhost>
      <datacenter>Dracula</datacenter>
      <guestid>solaris9Guest</guestid>
      <datastore>storage1</datastore>
      <disksize></disksize>
      <memory>128</memory>
      <num_cpus>1</num_cpus>
      <nic_network>VM Network</nic_network>
      <nic_poweron>0</nic_poweron>
   </VM>
   <VM>
      <vmname>Virtual_5</vmname>
      <vmhost>192.168.111.2</vmhost>
      <datacenter>Dracula</datacenter>
      <guestid></guestid>
      <datastore>storage1</datastore>
      <disksize>2048</disksize>
      <memory>128</memory>
      <num_cpus>1</num_cpus>
      <nic_network></nic_network>
      <nic_poweron>1</nic_poweron>
   </VM>
 </virtual-machines>

The command to run the vmcreate script is:

 vmcreate.pl --url https://192.168.111.52:443/sdk/webService
             --username administrator --password mypassword
             --filename create_vm.xml --schema schema.xsd

The script continues to create the next virtual machine even if a previous machine creation process failed. Sample output of the command:

 --------------------------------------------------------------
 Successfully created virtual machine: 'Virtual_1'
 Error creating VM 'Virtual_2': Host 'Host123' not found
 Error creating VM 'Virtual_3': Datastore DataABC not available.
 Successfully created virtual machine: 'Virtual_4'
 Successfully created virtual machine: 'Virtual_5'
 --------------------------------------------------------------


SUPPORTED PLATFORMS

Create operation work with VMware VirtualCenter 2.0 or later.