Package com.vmware.vm

Class VMCreate


  • @Sample(name="vm-create",
            description="This sample creates a VM")
    public class VMCreate
    extends ConnectedVimServiceBase
     VMCreate
    
     This sample creates a VM
    
     Parameters:
     url              [required] : url of the web service
     username         [required] : username for the authentication
     password         [required] : password for the authentication
     vmname           [required] : Name of the virtual machine
     datacentername   [required] : Name of the datacenter
     hostname         [required] : Name of the host
     networkname      [required] : Network Name
                                  (Types can be Standard/Distributed/Opaque)
     guestosid        [optional] : Type of Guest OS
     cpucount         [optional] : Total cpu count
     disksize         [optional] : Size of the Disk
     memorysize       [optional] : Size of the Memory in 1024MB blocks
     datastorename    [optional] : Name of dataStore
    
     Command Line:
     Create a VM given datacenter and host names
     run.bat com.vmware.vm.VMCreate --url [webserviceurl]
     --username [username] --password [password] --vmname [vmname]
     --datacentername [DataCenterName] --hostname [hostname] --networkname [networkname]
    
     Create a VM given its name, Datacenter name and GuestOsId
     run.bat com.vmware.vm.VMCreate --url [webserviceurl]
     --username [username] --password [password] --vmname [vmname]
     --datacentername [DataCenterName] --guestosid [GuestOsId]
    
     Create a VM given its name, Datacenter name and its cpucount
     run.bat com.vmware.vm.VMCreate --url [webserviceurl]
     --username [username] --password [password] --vmname [vmname]
     --datacentername [DataCenterName] --cpucount [cpucount]
     
    • Constructor Detail

      • VMCreate

        public VMCreate()
    • Method Detail

      • setVirtualMachineName

        @Option(name="vmname",
                description="Name of the virtual machine")
        public void setVirtualMachineName​(java.lang.String vmname)
      • setDataCenterName

        @Option(name="datacentername",
                description="Name of the datacenter")
        public void setDataCenterName​(java.lang.String dcname)
      • setHostname

        @Option(name="hostname",
                description="Name of the host")
        public void setHostname​(java.lang.String hostname)
      • setGuestOsId

        @Option(name="guestosid",
                required=false,
                description="Type of Guest OS [Windows|Posix]")
        public void setGuestOsId​(java.lang.String guestOsId)
      • setCpuCount

        @Option(name="cpucount",
                required=false,
                description="Total cpu count")
        public void setCpuCount​(java.lang.String cpuCount)
      • setDiskSize

        @Option(name="disksize",
                required=false,
                description="Size of the Disk")
        public void setDiskSize​(java.lang.String size)
      • setMemorySize

        @Option(name="memorysize",
                required=false,
                description="Size of Memory in 1024MB blocks")
        public void setMemorySize​(java.lang.String memorySize)
      • setDataStore

        @Option(name="datastorename",
                required=false,
                description="Name of dataStore")
        public void setDataStore​(java.lang.String dsname)
      • setNetwork

        @Option(name="networkname",
                required=true,
                description="Name of Network. Supported Types:Standard Network|Distributed Virtual Switch|Opaque Network")
        public void setNetwork​(java.lang.String networkname)
      • getAvailableHostNetworkDevice

        public java.util.HashMap<java.lang.String,​com.vmware.vim25.VirtualDeviceBackingInfo> getAvailableHostNetworkDevice​(com.vmware.vim25.ConfigTarget configTarget)
                                                                                                                          throws com.vmware.vim25.InvalidPropertyFaultMsg,
                                                                                                                                 com.vmware.vim25.RuntimeFaultFaultMsg
        Return the list of any available networks on ESX which will host the VM
        Returns:
        deviceBacking
        Throws:
        com.vmware.vim25.RuntimeFaultFaultMsg
        com.vmware.vim25.InvalidPropertyFaultMsg
      • run

        @Action
        public void run()
                 throws com.vmware.vim25.RuntimeFaultFaultMsg,
                        com.vmware.vim25.VmConfigFaultFaultMsg,
                        com.vmware.vim25.AlreadyExistsFaultMsg,
                        com.vmware.vim25.InvalidDatastoreFaultMsg,
                        com.vmware.vim25.FileFaultFaultMsg,
                        com.vmware.vim25.InvalidStateFaultMsg,
                        com.vmware.vim25.InvalidCollectorVersionFaultMsg,
                        com.vmware.vim25.InvalidNameFaultMsg,
                        com.vmware.vim25.OutOfBoundsFaultMsg,
                        com.vmware.vim25.DuplicateNameFaultMsg,
                        com.vmware.vim25.InsufficientResourcesFaultFaultMsg,
                        com.vmware.vim25.InvalidPropertyFaultMsg,
                        java.rmi.RemoteException,
                        com.vmware.vim25.TaskInProgressFaultMsg
        Throws:
        com.vmware.vim25.RuntimeFaultFaultMsg
        com.vmware.vim25.VmConfigFaultFaultMsg
        com.vmware.vim25.AlreadyExistsFaultMsg
        com.vmware.vim25.InvalidDatastoreFaultMsg
        com.vmware.vim25.FileFaultFaultMsg
        com.vmware.vim25.InvalidStateFaultMsg
        com.vmware.vim25.InvalidCollectorVersionFaultMsg
        com.vmware.vim25.InvalidNameFaultMsg
        com.vmware.vim25.OutOfBoundsFaultMsg
        com.vmware.vim25.DuplicateNameFaultMsg
        com.vmware.vim25.InsufficientResourcesFaultFaultMsg
        com.vmware.vim25.InvalidPropertyFaultMsg
        java.rmi.RemoteException
        com.vmware.vim25.TaskInProgressFaultMsg