Vcenter VM create

Vcenter VM create

Creates a virtual machine.

Returns an authorization error if you do not have all of the privileges described as follows:

  • The resource Folder referenced by the property Vcenter VM InventoryPlacementSpec.folder requires VirtualMachine.Inventory.Create.
  • The resource ResourcePool referenced by the property Vcenter VM ComputePlacementSpec.resource_pool requires Resource.AssignVMToPool.
  • The resource Datastore referenced by the property Vcenter VM StoragePlacementSpec.datastore requires Datastore.AllocateSpace.
  • The resource Network referenced by the property Vcenter Vm Hardware Ethernet BackingSpec.network requires Network.Assign.
Request
URI
POST
https://{api_host}/api/vcenter/vm
COPY
Request Body

Virtual machine specification.

Vcenter VM CreateSpec of type(s) application/json
Required

Show optional properties

{
    "guest_os": "string"
}
{
    "guest_os": "string",
    "name": "string",
    "placement": {
        "folder": "string",
        "resource_pool": "string",
        "host": "string",
        "cluster": "string",
        "datastore": "string"
    },
    "hardware_version": "string",
    "boot": {
        "type": "string",
        "efi_legacy_boot": false,
        "network_protocol": "string",
        "delay": 0,
        "retry": false,
        "retry_delay": 0,
        "enter_setup_mode": false
    },
    "boot_devices": [
        {
            "type": "string"
        }
    ],
    "cpu": {
        "count": 0,
        "cores_per_socket": 0,
        "hot_add_enabled": false,
        "hot_remove_enabled": false
    },
    "memory": {
        "size_mib": 0,
        "hot_add_enabled": false
    },
    "disks": [
        {
            "type": "string",
            "ide": {
                "primary": false,
                "master": false
            },
            "scsi": {
                "bus": 0,
                "unit": 0
            },
            "sata": {
                "bus": 0,
                "unit": 0
            },
            "nvme": {
                "bus": 0,
                "unit": 0
            },
            "backing": {
                "type": "string",
                "vmdk_file": "string"
            },
            "new_vmdk": {
                "name": "string",
                "capacity": 0,
                "storage_policy": {
                    "policy": "string"
                }
            }
        }
    ],
    "nics": [
        {
            "type": "string",
            "upt_compatibility_enabled": false,
            "upt_v2_compatibility_enabled": false,
            "mac_type": "string",
            "mac_address": "string",
            "pci_slot_number": 0,
            "wake_on_lan_enabled": false,
            "backing": {
                "type": "string",
                "network": "string",
                "distributed_port": "string"
            },
            "start_connected": false,
            "allow_guest_control": false
        }
    ],
    "cdroms": [
        {
            "type": "string",
            "ide": {
                "primary": false,
                "master": false
            },
            "sata": {
                "bus": 0,
                "unit": 0
            },
            "backing": {
                "type": "string",
                "iso_file": "string",
                "host_device": "string",
                "device_access_type": "string"
            },
            "start_connected": false,
            "allow_guest_control": false
        }
    ],
    "floppies": [
        {
            "backing": {
                "type": "string",
                "image_file": "string",
                "host_device": "string"
            },
            "start_connected": false,
            "allow_guest_control": false
        }
    ],
    "parallel_ports": [
        {
            "backing": {
                "type": "string",
                "file": "string",
                "host_device": "string"
            },
            "start_connected": false,
            "allow_guest_control": false
        }
    ],
    "serial_ports": [
        {
            "yield_on_poll": false,
            "backing": {
                "type": "string",
                "file": "string",
                "host_device": "string",
                "pipe": "string",
                "no_rx_loss": false,
                "network_location": "string",
                "proxy": "string"
            },
            "start_connected": false,
            "allow_guest_control": false
        }
    ],
    "sata_adapters": [
        {
            "type": "string",
            "bus": 0,
            "pci_slot_number": 0
        }
    ],
    "scsi_adapters": [
        {
            "type": "string",
            "bus": 0,
            "pci_slot_number": 0,
            "sharing": "string"
        }
    ],
    "nvme_adapters": [
        {
            "bus": 0,
            "pci_slot_number": 0
        }
    ],
    "storage_policy": {
        "policy": "string"
    }
}
string
guest_os
Required

Guest OS.

For more information see: Vcenter Vm GuestOS.

string
name
Optional

Virtual machine name.

If missing or null, a default name will be generated by the server.

placement
Optional

Virtual machine placement information.

This property is currently required. In the future, if this property is missing or null, the system will attempt to choose suitable resources on which to place the virtual machine.

string
hardware_version
Optional

Virtual hardware version.

For more information see: Vcenter Vm Hardware Version.

If missing or null, defaults to the most recent version supported by the server.

boot
Optional

Boot configuration.

If missing or null, guest-specific default values will be used.

array of object
boot_devices
Optional

Boot device configuration.

If missing or null, a server-specific boot sequence will be used.

cpu
Optional

CPU configuration.

If missing or null, guest-specific default values will be used.

memory
Optional

Memory configuration.

If missing or null, guest-specific default values will be used.

array of object
disks
Optional

List of disks.

If missing or null, a single blank virtual disk of a guest-specific size will be created on the same storage as the virtual machine configuration, and will use a guest-specific host bus adapter type. If the guest-specific size is 0, no virtual disk will be created.

array of object
nics
Optional

List of Ethernet adapters.

If missing or null, no Ethernet adapters will be created.

array of object
cdroms
Optional

List of CD-ROMs.

If missing or null, no CD-ROM devices will be created.

array of object
floppies
Optional

List of floppy drives.

If missing or null, no floppy drives will be created.

array of object
parallel_ports
Optional

List of parallel ports.

If missing or null, no parallel ports will be created.

array of object
serial_ports
Optional

List of serial ports.

If missing or null, no serial ports will be created.

array of object
sata_adapters
Optional

List of SATA adapters.

If missing or null, any adapters necessary to connect the virtual machine's storage devices will be created; this includes any devices that explicitly specify a SATA host bus adapter, as well as any devices that do not specify a host bus adapter if the guest's preferred adapter type is SATA.

array of object
scsi_adapters
Optional

List of SCSI adapters.

If missing or null, any adapters necessary to connect the virtual machine's storage devices will be created; this includes any devices that explicitly specify a SCSI host bus adapter, as well as any devices that do not specify a host bus adapter if the guest's preferred adapter type is SCSI. The type of the SCSI adapter will be a guest-specific default type.

array of object
nvme_adapters
Optional

List of NVMe adapters.

This property was added in vSphere API 7.0.0.1.

If missing or null, any adapters necessary to connect the virtual machine's storage devices will be created; this includes any devices that explicitly specify a NVMe host bus adapter, as well as any devices that do not specify a host bus adapter if the guest's preferred adapter type is NVMe.

storage_policy
Optional

The Vcenter VM StoragePolicySpec schema contains information about the storage policy that is to be associated with the virtual machine home (which contains the configuration and log files).

This property was added in vSphere API 6.7.

If missing or null the datastore default storage policy (if applicable) is applied. Currently a default storage policy is only supported by object datastores : VVol and vSAN. For non-object datastores, if missing or null then no storage policy would be associated with the virtual machine home.

Authentication
This operation uses the following authentication methods.
Responses
201

ID of newly-created virtual machine.

The response will be an identifier for the resource type: VirtualMachine.

Returns string of type(s) application/json
Operation doesn't return any data structure

400

Vapi Std Errors AlreadyExists if a virtual machine with the specified name already exists.

Vapi Std Errors InvalidArgument if any of the specified parameters are invalid.

Vapi Std Errors ResourceInUse if any of the specified storage addresses (eg. IDE, SATA, SCSI, NVMe) result in a storage address conflict.

Vapi Std Errors Unsupported if guest_OS is not supported for the requested virtual hardware version and spec includes missing or null properties that default to guest-specific values.

Returns Vapi Std Errors Error of type(s) application/json
"Vapi Std Errors Error Object"
array of object
messages
Required

Stack of one or more localizable messages for human error consumers.

The message at the top of the stack (first in the list) describes the error from the perspective of the operation the client invoked.

Each subsequent message in the stack describes the "cause" of the prior message.

object
data
Optional

Data to facilitate clients responding to the operation reporting a standard error to indicating that it was unable to complete successfully.

Operations may provide data that clients can use when responding to errors. Since the data that clients need may be specific to the context of the operation reporting the error, different operations that report the same error may provide different data in the error. The documentation for each each operation will describe what, if any, data it provides for each error it reports.

The Vapi Std Errors ArgumentLocations, Vapi Std Errors FileLocations, and Vapi Std Errors TransientIndication schemas are intended as possible values for this property. Vapi Std DynamicID may also be useful as a value for this property (although that is not its primary purpose). Some resources may provide their own specific schemas for use as the value of this property when reporting errors from their operations.

Some operations will not set this property when reporting errors.

string
error_type
Required

Discriminator field to help API consumers identify the structure type.

For more information see: Vapi Std Errors Error Type.

This property was added in vSphere API 6.7.2.

Can be missing or null for compatibility with preceding implementations.


401

if the user can not be authenticated.

Returns Vapi Std Errors Unauthenticated of type(s) application/json
This response body class contains all of the following: InlineVapi Std Errors Unauthenticated0
"Vapi Std Errors Unauthenticated Object"
string
challenge
Optional

Indicates the authentication challenges applicable to the target API provider. It can be used by a client to discover the correct authentication scheme to use. The exact syntax of the value is defined by the specific provider, the protocol and authentication schemes used.

For example, a provider using REST may adhere to the WWW-Authenticate HTTP header specification, RFC7235, section 4.1. In this case an example challenge value may be: SIGN realm="27da1358-2ba4-11e9-b210-d663bd873d93",sts="http://vcenter/sso?vsphere.local", Basic realm="vCenter"

This property was added in vSphere API 7.0.0.0.

This property is optional because it was added in a newer version than its parent node.


403

if the user doesn't have the required privileges.

Returns Vapi Std Errors Unauthorized of type(s) application/json
This response body class contains all of the following: InlineVapi Std Errors Unauthorized0
"Vapi Std Errors Unauthorized Object"

404

if any of the resources specified in spec could not be found

Returns Vapi Std Errors NotFound of type(s) application/json
This response body class contains all of the following: InlineVapi Std Errors NotFound0
"Vapi Std Errors NotFound Object"

500

Vapi Std Errors Error if the system reports an error while responding to the request.

Vapi Std Errors ResourceInaccessible if a specified resource (eg. host) is not accessible.

Vapi Std Errors UnableToAllocateResource if any of the resources needed to create the virtual machine could not be allocated.

Returns Vapi Std Errors Error of type(s) application/json
"Vapi Std Errors Error Object"
array of object
messages
Required

Stack of one or more localizable messages for human error consumers.

The message at the top of the stack (first in the list) describes the error from the perspective of the operation the client invoked.

Each subsequent message in the stack describes the "cause" of the prior message.

object
data
Optional

Data to facilitate clients responding to the operation reporting a standard error to indicating that it was unable to complete successfully.

Operations may provide data that clients can use when responding to errors. Since the data that clients need may be specific to the context of the operation reporting the error, different operations that report the same error may provide different data in the error. The documentation for each each operation will describe what, if any, data it provides for each error it reports.

The Vapi Std Errors ArgumentLocations, Vapi Std Errors FileLocations, and Vapi Std Errors TransientIndication schemas are intended as possible values for this property. Vapi Std DynamicID may also be useful as a value for this property (although that is not its primary purpose). Some resources may provide their own specific schemas for use as the value of this property when reporting errors from their operations.

Some operations will not set this property when reporting errors.

string
error_type
Required

Discriminator field to help API consumers identify the structure type.

For more information see: Vapi Std Errors Error Type.

This property was added in vSphere API 6.7.2.

Can be missing or null for compatibility with preceding implementations.


503

if the system is unable to communicate with a service to complete the request.

Returns Vapi Std Errors ServiceUnavailable of type(s) application/json
This response body class contains all of the following: InlineVapi Std Errors ServiceUnavailable0
"Vapi Std Errors ServiceUnavailable Object"

Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"guest_os:"string"}' https://{api_host}/api/vcenter/vm