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" : {
"scsi" : {
"bus" : 1,
"unit" : 1
},
"nvme" : {
"bus" : 1,
"unit" : 1
},
"new_vmdk" : {
"name" : "string",
"storage_policy" : {
"policy" : "obj-103"
},
"capacity" : 1
},
"backing" : {
"vmdk_file" : "string",
"type" : "VMDK_FILE"
},
"ide" : {
"primary" : true,
"master" : true
},
"type" : "IDE",
"sata" : {
"bus" : 1,
"unit" : 1
}
}
}
"spec" : {
"scsi" : {
"bus" : 1,
"unit" : 1
},
"nvme" : {
"bus" : 1,
"unit" : 1
},
"new_vmdk" : {
"name" : "string",
"storage_policy" : {
"policy" : "obj-103"
},
"capacity" : 1
},
"backing" : {
"vmdk_file" : "string",
"type" : "VMDK_FILE"
},
"ide" : {
"primary" : true,
"master" : true
},
"type" : "IDE",
"sata" : {
"bus" : 1,
"unit" : 1
}
}
}
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.nvme | nvme_address_spec | Address for attaching the device to a virtual NVMe adapter. Warning: This attribute is part of a new feature in development. It may be changed at any time and may not have all supported functionality implemented. Optional. It is only relevant when type has value NVME. If unset, the server will choose an available address; if none is available, the request will fail. |
spec.nvme.bus | long | Bus number of the adapter to which the device should be attached. Warning: This attribute is part of a new feature in development. It may be changed at any time and may not have all supported functionality implemented. |
spec.nvme.unit | long | Unit number of the device. Warning: This attribute is part of a new feature in development. It may be changed at any time and may not have all supported functionality implemented. 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. |
spec.new_vmdk.storage_policy | storage_policy_spec | The storage_policy_spec structure contains information about the storage policy that is to be associated the with VMDK file. This attribute was added in vSphere API 6.7. Optional. If unset the default storage policy of the target datastore (if applicable) is applied. Currently a default storage policy is only supported by object based datastores : VVol & vSAN. For non- object datastores, if unset then no storage policy would be associated with the VMDK file. |
spec.new_vmdk.storage_policy.policy | string | Identifier of the storage policy which should be associated with the VMDK file. This attribute was added in vSphere API 6.7. When clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: com.vmware.vcenter.StoragePolicy . When operations return a value of this structure as a result, the field will be an identifier for the resource type: com.vmware.vcenter.StoragePolicy . |
Response:
HTTP Status Code: 200
Representation:
{
"value" : "obj-103"
}
"value" : "obj-103"
}
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. |
500 | 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 or if the specified storage policy is invalid. |
500 | resource_busy | if the virtual machine is busy performing another operation. |
500 | 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. |