vcenter vm hardware disk: create

Adds a virtual disk to the virtual machine. While adding the virtual disk, a new VMDK file may be created or an existing VMDK file may be used to back the virtual disk.

Request:

HTTP request

POST https://{server}/rest/vcenter/vm/{vm}/hardware/disk

Path Parameters

Name Type Description
Required
vm string Virtual machine identifier.

Request Body Structure:

{
    "spec"{
        "backing"{
            "type""VMDK_FILE",
            "vmdk_file""string"
        },
        "ide"{
            "master"true,
            "primary"true
        },
        "new_vmdk"{
            "capacity"1,
            "name""string"
        },
        "sata"{
            "bus"1,
            "unit"1
        },
        "scsi"{
            "bus"1,
            "unit"1
        },
        "type""IDE"
    }
}
<?xml version="1.0" ?>
<ns0:Create-Input xmlns:ns0="http://vmware.com/vcenter/vm/hardware/disk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <spec>
    <scsi>
      <unit>1</unit>
      <bus>1</bus>
    </scsi>
    <ide>
      <primary>true</primary>
      <master>true</master>
    </ide>
    <sata>
      <unit>1</unit>
      <bus>1</bus>
    </sata>
    <new_vmdk>
      <name>string</name>
      <capacity>1</capacity>
    </new_vmdk>
    <type>IDE</type>
    <backing>
      <vmdk_file>string</vmdk_file>
      <type>VMDK_FILE</type>
    </backing>
  </spec>
</ns0:Create-Input>

Request Body Parameters:

Name Type Description
bold = required
spec create_spec Specification for the new virtual disk.
spec.type string Type of host bus adapter to which the device should be attached.

Optional. If unset, guest-specific default values will be used.

spec.ide ide_address_spec Address for attaching the device to a virtual IDE adapter.

Optional. It is only relevant when type has value IDE. If unset, the server will choose an available address; if none is available, the request will fail.

spec.ide.primary boolean Flag specifying whether the device should be attached to the primary or secondary IDE adapter of the virtual machine.

Optional. If unset, the server will choose a adapter with an available connection. If no IDE connections are available, the request will be rejected.

spec.ide.master boolean Flag specifying whether the device should be the master or slave device on the IDE adapter.

Optional. If unset, the server will choose an available connection type. If no IDE connections are available, the request will be rejected.

spec.scsi scsi_address_spec Address for attaching the device to a virtual SCSI adapter.

Optional. It is only relevant when type has value SCSI. If unset, the server will choose an available address; if none is available, the request will fail.

spec.scsi.bus long Bus number of the adapter to which the device should be attached.

spec.scsi.unit long Unit number of the device.

Optional. If unset, the server will choose an available unit number on the specified adapter. If there are no available connections on the adapter, the request will be rejected.

spec.sata sata_address_spec Address for attaching the device to a virtual SATA adapter.

Optional. It is only relevant when type has value SATA. If unset, the server will choose an available address; if none is available, the request will fail.

spec.sata.bus long Bus number of the adapter to which the device should be attached.

spec.sata.unit long Unit number of the device.

Optional. If unset, the server will choose an available unit number on the specified adapter. If there are no available connections on the adapter, the request will be rejected.

spec.backing backing_spec Existing physical resource backing for the virtual disk. Exactly one of backing or new_vmdk must be specified.

Optional. If unset, the virtual disk will not be connected to an existing backing.

spec.backing.type string Backing type for the virtual disk.

Defines the valid backing types for a virtual disk. Value is one of:
VMDK_FILE: Virtual disk is backed by a VMDK file.

spec.backing.vmdk_file string Path of the VMDK file backing the virtual disk.

Optional. It is only relevant when type has value VMDK_FILE. This field is optional and it is only relevant when the value of type is VMDK_FILE.

spec.new_vmdk vmdk_create_spec Specification for creating a new VMDK backing for the virtual disk. Exactly one of backing or new_vmdk must be specified.

Optional. If unset, a new VMDK backing will not be created.

spec.new_vmdk.name string Base name of the VMDK file. The name should not include the '.vmdk' file extension.

Optional. If unset, a name (derived from the name of the virtual machine) will be chosen by the server.

spec.new_vmdk.capacity long Capacity of the virtual disk backing in bytes.

Optional. If unset, defaults to a guest-specific capacity.

Response:

HTTP Status Code: 200

Representations:

{
    "value""obj-103"
}
<?xml version="1.0" ?>
<ns0:Create-Result xmlns:ns0="http://vmware.com/vcenter/vm/hardware/disk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <value>obj-103</value>
</ns0:Create-Result>

Response Type:

Name Type Description
bold = required
value string Virtual disk identifier.

Errors:

HTTP Status Code Type Description
500 error if system reported that the disk device was created but was unable to confirm the creation because the identifier of the new device could not be determined.
404 not_found if the virtual machine is not found.
400 not_allowed_in_current_state if the virtual machine is suspended or if the virtual machine is powered on and virtual disk type is IDE.
400 unable_to_allocate_resource if the specified storage address is unavailable; for example, if the SCSI adapter requested does not exist.
400 resource_in_use if the specified storage address is in use.
400 invalid_argument if the specified storage address is out of bounds.
400 resource_busy if the virtual machine is busy performing another operation.
400 resource_inaccessible if the virtual machine's configuration state cannot be accessed.
503 service_unavailable if the system is unable to communicate with a service to complete the request.
401 unauthenticated if the user can not be authenticated.
403 unauthorized if the user doesn't have the required privileges.
400 unsupported if the guest operating system of the virtual machine is not supported and spec includes unset fields that default to guest-specific values.