5.1

Table Of Contents
<Link
rel="disk:detach"
type="application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml"
href="https://vcloud.example.com/api/vApp/vm-4/disk/action/detach" />
You can POST a DiskAttachOrDetachParams element to one of these URLs to attach or detach an independent
disk.
Prerequisites
n
Verify that you are logged in to the vCloud API as a system administrator or the object owner.
n
Verify that the vDC contains an independent disk. If the vDC does not contain independent disks, you
can create one. See “Create or Update an Independent Disk,” on page 76.
Procedure
1 Retrieve a reference to the independent disk to attach to a virtual machine.
The independent disk and the virtual machine must be contained by the same vDC. You can retrieve
references to independent disks in a vDC in the following ways:
n
Use the query service. A query like this one returns references to all Disk objects in the vDC named
MyVdc.
GET https://vcloud.example.com/api/query?
type=disk&format=references&filter=vdcName==MyVdc
n
Retrieve the vDC and look for ResourceEntity elements whose type attribute has a value of
application/vnd.vmware.vcloud.disk+xml. The href value of a ResourceEntity that represents a disk
is a reference to that Disk object.
2 Create a DiskAttachOrDetachParams element.
Provide a reference to the independent disk in the href attribute of the Disk element.
3 POST the DiskAttachOrDetachParams to the disk/action/attach link of the Vm.
Example: Attach an Independent Disk to a Virtual Machine
This request attaches the disk created in “Create or Update an Independent Disk,” on page 76 to a virtual
machine.
Request:
POST https://vcloud.example.com/api/vApp/vm-4/disk/action/attach
Content-Type: application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<DiskAttachOrDetachParams
xmlns="http://www.vmware.com/vcloud/v1.5">
<Disk
type="application/vnd.vmware.vcloud.disk+xml"
href="https://vcloud.example.com/api/disk/128" />
</DiskAttachOrDetachParams>
The response is a Task.
Response:
<Task
href="https://vcloud.example.com/api/task/57"
...
status="running"
vCloud API Programming Guide
94 VMware, Inc.