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. The following example shows how to create an image profile for a vSphere cloud account with the external region ID Datacenter:datacenter-3.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Cloud Assembly Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the cloud account ID for the new cloud account that you added. See Adding Cloud Accounts.
Procedure
Example: Create image mapping
$ url='https://appliance.domain.com''
$ api_version='2021-07-15'
$ cloud_account_id='ff4e7585-4197-41fb-89cb-179ef4d24779'
Look up region IDs associated with the cloud account and in the external region ID Datacenter:datacenter-3.
$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/regions/?apiVersion=$api_version&"'$filter'"=externalRegionId%20eq%20'Datacenter:datacenter-3'%20and%20cloudAccountId%20eq%20'"$cloud_account_id"'" | jq "."
A snippet of the response shows the region ID.
... "externalRegionId": "Datacenter:datacenter-3", "name": "w01-vc08-DC", "cloudAccountId": "ff4e7585-4197-41fb-89cb-179ef4d24779", "id": "9b148b38-fc7c-4560-b413-5f47b30e57d8", ...
Assign the region ID.
$ region_id='9b148b38-fc7c-4560-b413-5f47b30e57d8'
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": { "externalId": "https://cloud-images.ubuntu.com/releases/16.04/release-20220305/ubuntu-16.04-server-cloudimg-amd64.ova" } }, "regionId":"'$region_id'" }' | jq "."
A snippet of the response shows the image profile ID.
... "externalRegionId": "Datacenter:datacenter-3", "cloudAccountId": "ff4e7585-4197-41fb-89cb-179ef4d24779", "name": "example-image-profile", "id": "f670fdfc-66d6-4689-9793-d524e7066d1e-9b148b38-fc7c-4560-b413-5f47b30e57d8", ...