Migrate named disk to another Organization Virtual Datacenter using the Cloud Director API
search cancel

Migrate named disk to another Organization Virtual Datacenter using the Cloud Director API

book

Article ID: 325550

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • How to migrate a named disk to another Organization VDC using the Cloud Director API.

Environment

VMware Cloud Director 10.x

Resolution

To migrate a named disk to another Organization Virtual Datacenter, this can be done by using the Cloud Director API's moveDisk operation against the named disk in question:

VMware Cloud Director API, User Operations, POST /disk/{id}/action/moveDisk

 

Example steps to move the named disk to another Organization VDC would be as follows:

  1. Log in to the Cloud Director UI Provider portal as a System Administrator.
  2. Navigate to the Resources > Cloud Resources > Organizations view and click on the name of the Organization in which the Named Disk is located.
  3. From the URL displayed in the browser, note the ID of the Organization as this will be required later.

    Example URL:
    https://vcloud.example.com/provider/cloud/organizations/urn:vcloud:org:<org-id>/configure/general

  4. Navigate to the Resources > Cloud Resources > Organizations VDCs view and click on the name of the destination Organization VDC to which the Named Disk is to be moved.
  5. Click on the Open In Tenant Portal button to open the destination Organization VDC in the Cloud Director UI Tenant portal in a new tab.
  6. From the URL displayed in the browser in the new tab, note the ID of the Organization VDC as this will be required later.

    Example URL:
    https://vcloud.example.com/tenant/<org-name>/vdcs/<dest-org-vdc-id>/vm

  7. Navigate to the Storage > Storage Policies view in the Tenant portal and click on the name of the destination Storage Policy in the destination Organization VDC to which the Named Disk is to be moved.
  8. From the URL displayed in the browser, note the ID of the Storage Policy as this will be required later.

    Example URL:
    https://vcloud.example.com/tenant/<org-name>/vdcs/<org-vdc-id>/storage-policies/<dest-storage-policy-id>/general

  9. Log into the Cloud Director API as a System Administrator:

    Request:
    POST https://vcloud.example.com/cloudapi/1.0.0/sessions/provider

    Request headers:
    Accept:application/json;version=38.1
    Authorization:Basic (Encoded username@system / password)

    NOTE: For the version value set the appropriate Cloud Director API version for the Cloud Director to which the API call is being made. The Cloud Director API versions are listed on the main Cloud Director documentation page here, VMware Cloud Director Documentation. Alternatively query the Cloud Director API versions directly from the Cloud Director instance:
    GET https://vcloud.example/api/versions

  10. Copy the value of the response header X-VMWARE-VCLOUD-ACCESS-TOKEN which is our login Bearer token used for further requests.

    Example response header:
    X-VMWARE-VCLOUD-ACCESS-TOKEN:<vcd-access-token>

  11. Query the list of Named Disks in the Organization using the name of the Named Disk to be moved as a filter:

    Request:
    GET https://vcloud.example.com/api/query?type=disk&format=records&page=1&pageSize=20&filterEncoded=true&filter=name==<named-disk-name>

    Request headers:
    Accept:application/*+xml;version=38.1
    Authorization:Bearer <vcd-access-token>
    X-VMWARE-VCLOUD-TENANT-CONTEXT:<org-id>


  12. From the XML response body retrieve the href of the Named Disk to be moved, note the ID of the Named Disk as this will be required later.

    Example href:
    https://vcloud.example/api/disk/<named-disk-id>

  13. Using the values retrieved in the steps above construct the DiskMoveParams XML request body required to move the Named Disk:

    Example DiskMoveParams:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <DiskMoveParams xmlns="http://www.vmware.com/vcloud/v1.5">
        <Vdc href="https://vcloud.example.com/api/vdc/<dest-org-vdc-id>" id="urn:vcloud:vdc:<dest-org-vdc-id>" type="application/vnd.vmware.vcloud.vdc+xml" name="<dest-org-vdc-name>"/>
        <StoragePolicy href="https://vcloud.example.com/api/admin/vdcStorageProfile/<dest-storage-policy-id>" type="application/vnd.vmware.vcloud.vdcStorageProfile+xml" name="<dest-storage-policy-name>"/>
    </DiskMoveParams>

  14. Send the request to move the Named Disk using the DiskMoveParams XML request body and the IDs retrieved above:

    Request:
    POST https://vcloud.example/api/disk/<named-disk-id>/action/moveDisk

    Request headers:
    Accept:application/*+xml;version=38.1
    Content-Type:application/*+xml
    Authorization:Bearer <vcd-access-token>

    Request body:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <DiskMoveParams xmlns="http://www.vmware.com/vcloud/v1.5">
        <Vdc href="https://vcloud.example.com/api/vdc/<dest-org-vdc-id>" id="urn:vcloud:vdc:<dest-org-vdc-id>" type="application/vnd.vmware.vcloud.vdc+xml" name="<dest-org-vdc-name>"/>
        <StoragePolicy href="https://vcloud.example.com/api/admin/vdcStorageProfile/<dest-storage-policy-id>" type="application/vnd.vmware.vcloud.vdcStorageProfile+xml" name="<dest-storage-policy-name>"/>
    </DiskMoveParams>

  15. Confirm the Named Disk has moved to the destination Organization VDC successfully.

Additional Information

For more information on connecting to the Cloud Director API see, How to establish an API connection VMware Cloud Director (56948).