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 Virtual Datacenter using the Cloud Director API.


Symptoms:

Need to migrate a Named Disk to another Organization Virtual Datacenter in Cloud Director.


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 Org VDC:

  1. Get the ID of the below:
    1. Named Disk (<Named_Disk_ID>)
    2. Destination Org VDC (https://vcloud.example/tenant/ExampleOrg/vdcs/<VDC_ID>)
    3. Destination Storage Policy (https://vcloud.example/tenant/ExampleOrg/vdcs/<VDC_ID>/storage-policies/<Storage_Policy_ID>)
  2. Using the Named Disk ID construct the URL for the move Disk operation
Example URL:
https://vcloud.example.com/api/disk/<Named_Disk_ID>/action/moveDisk
  1. 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=37.2
Authorization:Basic (Encoded username@system / password)

NOTE: the API version in the Accept header is based on the Cloud Director version.
  1. Copy the value of the response header X-VMWARE-VCLOUD-ACCESS-TOKEN which is our login Bearer token used for further requests.
Response Headers:
 
X-VMWARE-VCLOUD-ACCESS-TOKEN:eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbml...bY1pTknnRprwEg
  1. Using the constructed URL in step 2 and the authorization bearer token from step 4, send the API call to move the named Disk:
Request:

POST https://vcloud.example/api/disk/<Named_Disk_ID>/action/moveDisk

Headers:

Accept: application/*+xml;version=38.0.0-alpha
Authorization: Bearer XXXXX (from step 4)
Content-Type: application/*+xml;version=38.0.0-alpha

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

Body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DiskMoveParams xmlns="http://www.vmware.com/vcloud/v1.5">
    <Vdc href="https://vcloud.example/api/vdc/<Destination_Org_VDC_ID>" id="urn:vcloud:vdc:<Destination Org VDC ID>" type="application/vnd.vmware.vcloud.vdc+xml" name="<Name of Destination Org VDC>"/>
    <StoragePolicy href="https://vcloud.example/api/admin/vdcStorageProfile/<Destination_Storage_Policy_ID>" type="application/vnd.vmware.vcloud.vdcStorageProfile+xml" name="<Name of Destination Storage Policy>"/>
</DiskMoveParams>


Additional Information

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