To create an NSX-T or NSX-V cloud account, you make a POST request. The request body includes the NSX-specific parameters required to create the cloud account.

As an alternative to using the cloud-accounts API call, you can use a cloud-accounts-nsx-t or cloud-accounts-nsx-v API call to list NSX-T or NSX-V cloud accounts respectively.

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. Examine the response and assign the data collector variable.
    data_collector_id='<your_datacollector_id>'
  3. Assign the NSX account variables.
    nsx_host_name='<your_nsx_host_name>'
    nsx_username='<your_nsx_user_name>'
    nsx_password='<your_nsx_password>'
    
  4. (Optional) If you have a vSphere cloud account that you want to associate with the NSX cloud account, assign the ID of the vSphere cloud account to the vsphere_cloud_account_id variable. See Add a vSphere Cloud Account.
    vpshere_cloud_accout_id='<your_vsphere_cloud_account_id>'
  5. Submit a request to create an NSX-V cloud account. To add an NSX-T cloud account, use "cloudAccountType": "nsxt". This example includes the vsphere_cloud_account_id variable.
    curl -X POST \
      "$url/iaas/api/cloud-accounts?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
      "cloudAccountType": "nsxv",
      "privateKeyId": "'$nsx_username'",
      "privateKey": "'$nsx_password'",
      "associatedCloudAccountIds": [
        "'$vsphere_cloud_account_id'"
      ],
      "cloudAccountProperties": {
        "hostName": "'$nsx_host_name'",
        "acceptSelfSignedCertificate": "true",
        "dcId": "'$data_collector_id'",
        "privateKeyId": "'$nsx_username'",
        "privateKey": "'$nsx_password'"
      },
     
      "tags": [
        {
          "key": "env",
          "value": "prod"
        }
      ],
      "name": "<your_nsx_cloud_account>",
      "description": "Example NSX cloud account description"
    }' | jq "."
  6. To obtain the NSX cloud account ID, examine the response.
  7. Assign the NSX cloud account ID variable.
    nsx_cloud_id='<your_nsx_cloud_id>'
  8. List all cloud accounts.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/cloud-accounts?apiVersion=$api_version"  | jq "."
  9. (Optional) List all NSX-T cloud accounts using the cloud-accounts-nsx-t API call.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/cloud-accounts-nsx-t?apiVersion=$api_version"  | jq "."
  10. (Optional) List all NSX-V cloud accounts using the cloud-accounts-nsx-v API call.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/cloud-accounts-nsx-v?apiVersion=$api_version"  | jq "."
  11. Examine the response and verify that the name and ID of the NSX cloud account you created is listed.
    Note: The ID of the associated vSphere cloud account appears under _links and hrefs as in the following code snippet example.
    ...
          "name": "nsxv manager",
          "id": "515684ccebafde75-7f703c5265a63d87-e78aab87e9c8d5cd4cd1da1a285403f0f4e77a5240720d093e147b830b172542-d5a5e16bdc3eec75572358fd24ab6",
          "updatedAt": "2022-04-02",
          "organizationId": "f670fdfc-66d6-4689-9793-d524e7066d1e",
          "orgId": "f670fdfc-66d6-4689-9793-d524e7066d1e",
          "_links": {
            "associated-cloud-accounts": {
              "hrefs": [
                "/iaas/api/cloud-accounts/515684ccebafde75-7f703c5265a63d87-e78aab87e9c8d5cd4cd1da1a285403f0f4e77a5240720d093e147b830b172542-23b5c527d7083675572f5099a8da0"
              ]
            },
            "self": {
              "href": "/iaas/api/cloud-accounts/515684ccebafde75-7f703c5265a63d87-e78aab87e9c8d5cd4cd1da1a285403f0f4e77a5240720d093e147b830b172542-d5a5e16bdc3eec75572358fd24ab6"
    ...

Example: Create an NSX-V Cloud Account

This example creates an NSX-V cloud account that includes an existing vSphere cloud account.

Assign the required variables.

$ url='https://appliance.domain.com'
$ api_version='2021-07-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": "cd7d1eb4-573f-4150-8206-de3d536490ca",
      "ipAddress": "10.139.116.60",
      "name": "localhost.localdom",
      "hostName": "localhost.localdom",
      "status": "ACTIVE"
    },,
...

Assign the data collector ID variable.

$ data_collector_id='cd7d1eb4-573f-4150-8206-de3d536490ca'

Assign the NSX account variables.

$ nsx_host_name='nsx-manager.mycompany.local'
$ nsx_username='admin' 
$ nsx_password='my_nsx_password'

Assign the account variables for your existing vSphere cloud account.

vsphere_cloud_account_id='515684ccebafde75-7f703c5265a63d87-e78aab87e9c8d5cd4cd1da1a285403f0f4e77a5240720d093e147b830b172542-23b5c527d7083675572f5099a8da0'

Create an NSX-V cloud account named demo-nsxv-account.

$ curl -X POST \
  "$url/iaas/api/cloud-accounts?apiVersion=$api_version" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
  "cloudAccountType": "nsxv",
  "privateKeyId": "'$nsx_username'",
  "privateKey": "'$nsx_password'",
  "associatedCloudAccountIds": [
    "'$vsphere_cloud_account_id'"
  ],
  "cloudAccountProperties": {
    "hostName": "'$nsx_host_name'",
    "acceptSelfSignedCertificate": "true",
    "dcId": "'$data_collector_id'",
    "privateKeyId": "'$nsx_username'",
    "privateKey": "'$nsx_password'"
  },
 
  "tags": [
    {
      "key": "env",
      "value": "prod"
    }
  ],
  "name": "demo-nsxv-account",
  "description": "Example NSX cloud account description"
}' | jq "."

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

...            
      "tags": [],
      "name": "demo-nsx-account",  
      "id": "7b2c48362c94567559080d8f575a2",
      "updatedAt": "2022-04-02",
      "organizationId": "8327d53f-91ea-420a-8613-ba8f3149db95",
      "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95",
...