Add a vSphere Cloud Account

To create a vSphere cloud account, you make a POST request. The request body includes the vSphere-specific parameters required to create the cloud account.

Prerequisites

Procedure

  1. List all cloud proxies.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/data-collectors?api_version=$api_version" | jq "."
  2. To obtain the data collector ID, examine the response.
  3. Assign the data collector ID variable.
    data_collector_id='<your_datacollector_id>'
  4. Assign the vSphere account variables.
    vsphere_host_name='<your_vsphere_host_name>'
    vsphere_user='<your_vsphere_user_name>'
    vsphere_password='<your_vsphere_password>'
    
  5. List external region IDs from a vSphere cloud account.
    curl -X POST \
      "$url/iaas/api/cloud-accounts-vsphere/region-enumeration?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
      "cloudAccountType": "vsphere",
      "username": "'$vsphere_user'",
      "password": "'$vsphere_password'",
      "hostName": "'$vsphere_host_name'",
      "dcid": "'$data_collector_id'",
      "acceptSelfSignedCertificate": "false"
    }' | jq "."
  6. To obtain the external region ID, examine the response and assign the region ID variable.
    vsphere_region_id='<your_vsphere_region_id>'
  7. Submit a request to create a vSphere cloud account without default cloud zones.
    curl -X POST \
      "$url/iaas/api/cloud-accounts?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
      "cloudAccountType": "vsphere",
      "privateKeyId": "'$vsphere_user'",
      "privateKey": "'$vsphere_password'",
      "cloudAccountProperties": {
        "hostName": "'$vsphere_host_name'",
        "acceptSelfSignedCertificate": "false",
        "dcId": "'$data_collector_id'",
        "privateKeyId": "'$vsphere_user'",
        "privateKey": "'$vsphere_password'"
      },
      "regionIds": [
        "<your_region_id>"
      ],
      "createDefaultZones": false,
      "tags": [
        {
          "key": "env",
          "value": "prod"
        }
      ],
      "name": "demo-vsphere-account",
      "description": "This is a demo vSphere account without default cloud zones"
    }' | jq "."
  8. (Optional) Submit a request to create a vSphere cloud account with default cloud zones.
    curl -X POST \
      "$url/iaas/api/cloud-accounts?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
      "cloudAccountType": "vsphere",
      "privateKeyId": "'$vsphere_user'",
      "privateKey": "'$vsphere_password'",
      "cloudAccountProperties": {
        "hostName": "'$vsphere_host_name'",
        "acceptSelfSignedCertificate": "false",
        "dcId": "'$data_collector_id'",
        "privateKeyId": "'$vsphere_user'",
        "privateKey": "'$vsphere_password'"
      },
      "regionIds": [
        "<your_region_id>"
      ],
      "createDefaultZones": true,
      "tags": [
        {
          "key": "env",
          "value": "prod"
        }
      ],
      "name": "demo-vsphere-account-default-cloud-zones",
      "description": "This is a demo vSphere account with default cloud zones"
    }' | jq "."
  9. List all cloud accounts
    curl -X GET $url/iaas/api/cloud-accounts?apiVersion=$api_version -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" | jq "."
  10. Examine the response and verify that the name and ID of the vSphere cloud account you created is listed.

Example: Create a vSphere Cloud Account

This example creates a cloud account without default cloud zones.

Assign the required variables.

$ url='https://appliance.domain.com'
$ api_version='2019-01-15'

List all cloud proxies.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/data-collectors?api_version=$api_version" | jq "."

A snippet of the response from your request shows the data collector IDs.

...          
      {
      "dcId": "60740040-f3cd-4694-96da-15e547242bf7",
      "ipAddress": "10.108.78.154",
      "name": "example-prod-corp-rdc",
      "hostName": "corp-v783-dhcp-79-85.eng.mycompany.com",
      "status": "ACTIVE"
    },
...

Assign the data collector ID variable.

$ data_collector_id='60740040-f3cd-4694-96da-15e547242bf7'

Assign the vSphere account variables.

$ vsphere_host_name='corp-v783-dhcp-79-85.eng.mycompany.com'
$ vsphere_user='[email protected]'
$ vsphere_password='my_vsphere_password'

List external region IDs from your vSphere cloud account.

$ curl -X POST \
  "$url/iaas/api/cloud-accounts-vsphere/region-enumeration?apiVersion=$api_version" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
  "cloudAccountType": "vsphere",
  "username": "'$vsphere_user'",
  "password": "'$vsphere_password'",
  "hostName": "'$vsphere_host_name'",
  "dcid": "'$data_collector_id'",
  "acceptSelfSignedCertificate": "false"
}' | jq "."

A snippet of the response shows the region ID to use.

...
{
  "externalRegionIds": [
    "Datacenter:datacenter-2"
  ]
}
...

Assign the region ID variable.

vsphere_region_id='Datacenter:datacenter-2'

Create a cloud account named demo-vsphere-account without default cloud zones.

$ curl -X POST \
  "$url/iaas/api/cloud-accounts?apiVersion=$api_version" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
  "cloudAccountType": "vsphere",
  "privateKeyId": "'$vsphere_user'",
  "privateKey": "'$vsphere_password'",
  "cloudAccountProperties": {
    "hostName": "'$vsphere_host_name'",
    "acceptSelfSignedCertificate": "false",
    "dcId": "'$data_collector_id'",
    "privateKeyId": "'$vsphere_user'",
    "privateKey": "'$vsphere_password'"
  },
  "regionIds": [
    "'$vsphere_region_id'"
  ],
  "createDefaultZones": false,
  "tags": [
    {
      "key": "env",
      "value": "prod"
    }
  ],
  "name": "demo-vsphere-account",
  "description": "This is a demo vSphere account without default cloud zones"
}' | jq "."

A snippet of the response from your request shows the account ID.

...            
      "tags": [],
      "name": "demo-vsphere-account",
      "id": "515684ccebafde75-7f703c5265a63d87-e78aab87e9c8d5cd4cd1da1a285403f0f4e77a5240720d093e147b830b172542-23b5c527d7083675572f5099a8da0",
      "updatedAt": "2019-08-02",
      "organizationId": "8327d53f-91ea-420a-8613-ba8f3149db95",
      "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95",
...