Use the disk/action/attach
or disk/action/detach
links in a Vm to attach or detach an independent disk. You must be the owner of the Vm object and the disk.
Every
Vm element includes links of the following form:
<Link rel="disk:attach" type="application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml" href="https://vcloud.example.com/api/vApp/vm-4/disk/action/attach" /> <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.
Note: An independent disk can be attached to at most one virtual machine.
Prerequisites
-
Verify that you are logged in to the VMware Cloud Director API as an administrator or the object owner. Verify that you are logged in to the vCloud Air Compute Service as a Virtual Infrastructure Administrator or the End User who owns this object.
- Verify that the VDC contains an independent disk. If the VDC does not contain independent disks, you can create one. See Create an Independent Disk.
Procedure
Example: Attach an Independent Disk to a Virtual Machine
This request attaches the disk created in Create an Independent Disk 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>