vCloud Independent Disks: Part 3 - Updating Disks
Post
Cancel

vCloud Independent Disks: Part 3 - Updating Disks

In order to make a change to an Independent Disk, you have to the XML representation of the disk as it is now, make your changes to the XML and then send the updated XML back into the vCloud API.  You can change the name and the Storage Profile. I couldn’t change the size of the disk, but I understand this is possible on vCloud 8.

Updating a Disk
To get the XML for the current settings, you just make a GET to the HREF (the URL) for the disk.  In my example this was: https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a and the what is returned looks like this:

vCloud API Response 1

The XML returned contains all the setting for the disk and will be the basis for the PUT request which will make the update.  Edit the XML to include whatever changes you need to make.  Then you make a put request as follows:

Once you have the edited XML block, use it as the body of a PUT request to the same URL as the previous GET request. Make sure the Content-Type is set to application/vnd.vmware.vcloud.disk+xml

So in this example I used:

URL https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a
Action PUT
Content-Type application/vnd.vmware.vcloud.disk+xml
Request Body
<?xml version="1.0" encoding="UTF-8"?>
<Disk xmlns="http://www.vmware.com/vcloud/v1.5" busSubType="lsilogicsas" busType="6" size="53687091200" status="1" name="IndDisk_DBFiles1" id="urn:vcloud:disk:bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a" type="application/vnd.vmware.vcloud.disk+xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcd.mycloud.com/api/v1.5/schema/master.xsd">
    <Link rel="up" href="https://vcd.mycloud.com/api/vdc/40cd7d91-7959-4ae0-acb0-691082d5290f" type="application/vnd.vmware.vcloud.vdc+xml"/>
    <Link rel="remove" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a"/>
    <Link rel="edit" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a" type="application/vnd.vmware.vcloud.disk+xml"/>
    <Link rel="down" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a/owner" type="application/vnd.vmware.vcloud.owner+xml"/>
    <Link rel="down" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a/attachedVms" type="application/vnd.vmware.vcloud.vms+xml"/>
    <Link rel="down" href="https://vcd.mycloud.com/api/disk/bda4fb2c-d4eb-4976-8bdc-52b2b7f28b3a/metadata" type="application/vnd.vmware.vcloud.metadata+xml"/>
    <Description>Disk for DB Files</Description>
    <StorageProfile href="https://vcd.mycloud.com/api/vdcStorageProfile/19e5487d-555a-49b7-8c11-837d48a9c0fc" name="Standard Disk" type="application/vnd.vmware.vcloud.vdcStorageProfile+xml"/>
    <Owner type="application/vnd.vmware.vcloud.owner+xml">
        <User href="https://vcd.mycloud.com/api/admin/user/575fd232-7ecc-482d-8dbe-56e95a83f840" name="customerlogin" type="application/vnd.vmware.admin.user+xml"/>
    </Owner>
</Disk>

The response you get back from the vCloud API will give you information about your request, including the HREF to the task so you can check on the progress.

vCloud API Response 2

If nothing appears to happen following your PUT request, do a GET to the HREF of the task and see what it says. In this case, the disk was already attached to a VM so a change could not be made to the disk.

vCloud API Response 3

This proves that you must detach the disk from the VM before you can make change. Well, that’s almost true…

Updating a Disk via the VM Object

You have been able to make changes to disks on running VMs, via the vCloud API, for a while now. If the Independent Disk is mounted to a VM, then target the disk section on the VM instead and make your changes there. I tested that I was able to move the disk to a new Storage Profile which worked fine. Changing the name and description of the VM didn’t but that’s no big deal. I’m going to take a guess but I would assume you could also increase the disk of the disk while it is mounted on the VM. I couldn’t test this as resizing Independent Disk is not supported on the version of vCloud Director I’m using.

This post is licensed under CC BY 4.0 by the author.