To create an image mapping, you make a POST request with a region ID associated with a cloud account. The cloud account can be an AWS, vSphere, Azure, or GCP cloud account.

Cloud vendors use images to configure a VM based on OS settings, such as an ubuntu-16 configuration. When you build a cloud template, you pick an image that fits your needs and map an image name to a value for each account or region. You can also add constraints and configuration scripts to further control resource placement.

The same API calls create an image profile for an AWS, vSphere, Azure, or GCP cloud account.

Prerequisites

Procedure

  1. Assign the cloud account ID variable.
    cloud_account_id='<your_cloud_account_id>'
  2. Look up region IDs associated with the cloud account and in the external region ID. This example specifies an AWS region ID us-east-1.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/regions/?apiVersion=$api_version&"'$filter'"=externalRegionId%20eq%20'us-east-1'%20and%20cloudAccountId%20eq%20'"$cloud_account_id"'"  | jq "."
  3. Examine the response to find the ID for the region that you want.
  4. Assign the region ID variable.
    region_id='<your_region_id>'
  5. List all fabric images.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/fabric-images/?apiVersion=$api_version" | jq "."
  6. To select fabric image that you want, examine the response.
  7. Create an image profile.
    curl -X POST \
      $url/iaas/api/image-profiles?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
        "name":"<your_image_profile>",
        "description":"Example image profile",
        "imageMapping": {
          "ubuntu": {
            "id": "<image_id_from_response>"
          },
          "ubuntu16": {
            "id": "<image_id_from_response>"
          },
          "ubuntu1604": {
            "name": "https://cloud-images.ubuntu.com/releases/16.04/release-20190605/ubuntu-16.04-server-cloudimg-amd64.ova"
          }
        },
        "regionId":"'$region_id'"
      }' | jq "."
  8. (Optional) For a vSphere region ID, create an image profile with an image mapping that specifies the OVA/OVF links instead of and image ID.
    curl -X POST \
      $url/iaas/api/image-profiles?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
        "name":"image-profile",
        "description":"vSphere Compute Images",
        "imageMapping": {
        "ubuntu": {
          "name": "https://cloud-images.ubuntu.com/releases/16.04/release-20190605/ubuntu-16.04-server-cloudimg-amd64.ova"
        }
      },
      "regionId":"'$region_id'"
    }' | jq "."
  9. To obtain the image profile ID, examine the response.
  10. Assign the image profile ID variable.
    image_profile_id='<your_image_profile_id>'
  11. (Optional) Look up the image profile you created with your image profile ID.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" $url/iaas/api/image-profiles/$image_profile_id?apiVersion=$api_version | jq "."
    The response shows the name and ID for the image profile you created.
    Note: Using the external region ID and the cloud account ID, you can also filter for the image profile with a query that does not require the image profile ID. See Filtering Resources by Region ID.

Example: Create image mapping

Assign the required variables including a cloud account ID.
$ url='https://appliance.domain.com''
$ api_version='2021-07-15'
$ cloud_account_id='c8c3c9bfdb449475-7f703c5265a63d87-5fa34c478df36b060e1ca3551254c4033013bf3283908e4661cd1c6fb2f8b9ae-ce5aad01092b47558644f6b6615d'

Look up region IDs associated with the cloud account and in the external region ID us-east-1.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/regions/?apiVersion=$api_version&"'$filter'"=externalRegionId%20eq%20'us-east-1'%20and%20cloudAccountId%20eq%20'"$cloud_account_id"'"  | jq "."

A snippet of the response shows the region ID.

...      
      "externalRegionId": "us-east-1",
      "cloudAccountId": "c8c3c9bfdb449475-7f703c5265a63d87-5fa34c478df36b060e1ca3551254c4033013bf3283908e4661cd1c6fb2f8b9ae-ce5aad01092b47558644f6b6615d",
      "id": "37d6c1acf4a8275586468873c739",
      "updatedAt": "2022-04-02",
...

Assign the region ID.

$ region_id='37d6c1acf4a8275586468873c739'

List all fabric images based on the name ubuntuserver.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/fabric-images/?apiVersion=$api_version&"'$filter'="name%20eq%20'*ubuntuserver*latest'%20or%20externalId%20eq%20ami-a8d2d7ce" | jq "."

A snippet of the response shows a fabric image ID. Select the IDs that you want.

...      
      "osFamily": "Linux",
      "externalRegionId": "francecentral",
      "isPrivate": false,
      "externalId": "Canonical:UbuntuServer:16.04-LTS:latest",
      "name": "Canonical:UbuntuServer:16.04-LTS:latest",
      "description": "Canonical:UbuntuServer:16.04-LTS:latest",
      "id": "fa13cb9367b63e755734f761858d8",
      "updatedAt": "2022-04-02",
...

Create an image profile named example-image-profile.

$ curl -X POST \
  $url/iaas/api/image-profiles?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
    "name":"example-image-profile",
    "description":"Example image profile",
    "imageMapping": {
      "ubuntu": {
        "id": "fa13cb9367b63e755734f761858d8"
      },
      "ubuntu16": {
        "id": "fa13cb9367b63e755734f761858d8"
      }
    },
    "regionId":"'$region_id'"
  }' | jq "."

A snippet of the response shows the image profile ID.

...        
   "externalRegionId": "us-east-1",
      "name": "example-image-profile",
      "description": "Example image profile",
      "id": "c70c0677a8e3787558edac19c9b10",
      "updatedAt": "2022-04-02",
...