Skip to main content

VMware Cloud Director API

The VMware Cloud Director API allows you to interact with VMware Cloud Director through a REST client.

For a description of the VMware Cloud Director API methods, see VMware documentation.

Authorization

To log in and start using the API, find out the API version и get a token.

Request API version

  1. Execute the request:
curl 'https://vcd.selectel.ru/api/versions'

Current versions of the API have the attribute deprecated takes on the value falseand the irrelevant ones have true.

  1. Select any current API version from the list. The example requests use version 36.3.

Get a token

  1. Use any string translation tool to translate a string from text format to MIME Base64 format:
<username>@<tenant>:<password>

Specify:

  • <username> — the user name to access Cloud Director;
  • <tenant> — tenant, you can look in the URL to log in to Cloud Director: https://vcd.selectel.ru/tenant/<tenant>
  • <password> — user password to access Cloud Director.
  1. Request a token:
curl -i -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Basic <encoded_string>' \
'https://vcd.selectel.ru/cloudapi/1.0.0/sessions/'

Specify:

  • <version> — API version;
  • <encoded_string> — string obtained in step 1.
  1. Check it out:
  • token in the field X-VMWARE-VCLOUD-ACCESS-TOKEN. When the key session expires, the token must be retrieved again;
  • organization identifier in the field org:id in the format of urn:vcloud:org:<org_id>where <org_id> — organization identifier.

Examples of requests

A full description of the VMware Cloud Director API in VMware documentation.

Request organization objects

Outputs all available organization objects (virtual data centers, directories, directories, tasks, quotas, groups, metadata, and organization networks), as well as a link to administer the organization.

Example of a request:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/api/org/<org_id>'

Specify:

  • <version> — API version;
  • <token> — token;
  • <org_id> — organization identifier received when the token is received.

Request virtual data center objects

Returns a list of virtual data center objects.

Example of a request:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/api/query?type=orgVdc'

Specify:

  • <version> — API version;
  • <token> — token.

Request a list of virtual machines

Returns a list of virtual machines.

Example of a request:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/api/query?type=vm&fields=name,containerName&filter=isVAppTemplate==false'

Request Parameters:

  • type=vm — Requests objects of type virtual machine;
  • fields=name,containerName — for each virtual machine shows only the attributes name и containerName (and by default the attributes href);
  • filter=isVAppTemplate==false — outputs only deployed virtual machines without vApp templates.

Turn on the virtual machine

Enables the specified virtual machine.

Example of a request:

curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/api/vApp/vm-<vm_id>/power/action/powerOn'

Specify:

Shut down the virtual machine

Shuts down the specified virtual machine.

Example of a request:

curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/api/vApp/vm-<vm_id>/power/action/powerOff'

Specify:

Exit the session

Deletes the current session.

Example of a request:

curl -i -XDELETE \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/cloudapi/1.0.0/sessions/'

Specify:

  • <version> — API version;
  • <token> — token.