Specifying Virtual Machine Attributes with VirtualMachineConfigSpec
The actual customization of the virtual machine happens through the properties of the VirtualMachineConfigSpec that is passed in as an argument to Folder.CreateVM_Task. For example, you can specify the name, boot options, number of CPUs, and memory for the virtual machine. All properties of VirtualMachineConfigSpec are optional to support incremental changes. See the API Reference.
The following example fragment from the VMCreate sample program illustrates how to define a VirtualMachineConfigSpec.
Defining a VirtualMachineConfigSpec Data Object
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); ... vmConfigSpec.setName(“MyVM”); vmConfigSpec.setMemoryMB(new Long(Integer.parseInt 500)); vmConfigSpec.setNumCPUs(Integer.parseInt 4); vmConfigSpec.setGuestId(cb.get_option("guestosid")); ...
The VMware SDK SDK/samples/Axis/java/com/vmware/apputils/vim/VMUtils.java sample defines a more comprehensive virtual machine that also includes a Floppy, CD-ROM, disk, and virtual NIC. See Configuring a Virtual Machine for a discussion of commonly set properties.
When you create a virtual machine, the virtual machine files are added at the virtual machine’s storage location. See Default Files.
Additional Configuration Information
The VirtualMachineConfigInfo and VirtualMachineConfigSpec objects provide the extraConfig property for additional configuration information. The extraConfig property is an array of key/value pairs that identify configuration options. The Server stores the extraConfig options in the .vmx file for the virtual machine. As the vSphere API evolves from version to version, an extraConfig option may become a standard configuration property that is part of the defined inventory data model. In this case, you must use the standard data model property for access; you cannot use the extraConfig property.