5.5

Table Of Contents
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 80.
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 80 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"
operationName="vappAttachDisk"
... />
...
</Task>
Chapter 5 Deploying and Operating vApps
VMware, Inc. 113