If you want to balance your deployed resources across multiple cloud zones, you can use the IaaS API to define the placement policy in a project and its cloud zones. When you deploy a cloud template that uses the project, vRealize Automation allocates new VMs to zones and clusters with the most free memory, effectively spreading them for better memory usage.

Prerequisites for defining a placement policy

How to specify spread by memory in your project

This example shows how to find the project with cloud zones where you want to place your VMs. Then using the project ID, you update the project with "placementPolicy": "SPREAD_MEMORY" to spread VM memory use across the cloud zones.

For information about project-level placement policies, see How do project-level placement policies affect resource allocation in vRealize Automation .

Get all projects.

curl -X GET -H 'Accept: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/projects?apiVersion=$api_version" | jq "."
A snippet of the response shows a project with its assigned cloud zones. The project ID 6c2f2d0d-ecee-42e3-90be-7bb66d6da2f9 has two zones with zone IDs:
  • 3c2bbe36-bf8e-4484-9c31-ce552422aaf1
  • 8992bdf0-136f-401c-822a-e22dae67259b
{
    "administrators": [],
    "members": [],
    "viewers": [],
    "zones": [
        {
            "zoneId": "3c2bbe36-bf8e-4484-9c31-ce552422aaf1",
            "priority": 0,
            "maxNumberInstances": 0,
            "allocatedInstancesCount": 0,
            "memoryLimitMB": 0,
            "allocatedMemoryMB": 0,
            "cpuLimit": 0,
            "allocatedCpu": 0,
            "storageLimitGB": 0,
            "allocatedStorageGB": 0.0
        },
        {
            "zoneId": "8992bdf0-136f-401c-822a-e22dae67259b",
            "priority": 0,
            "maxNumberInstances": 0,
            "allocatedInstancesCount": 0,
            "memoryLimitMB": 0,
            "allocatedMemoryMB": 0,
            "cpuLimit": 0,
            "allocatedCpu": 0,
            "storageLimitGB": 0,
            "allocatedStorageGB": 0.0
        }
    ],
    "constraints": {},
    "operationTimeout": 0,
    "sharedResources": true,
    "placementPolicy": "DEFAULT",
    "customProperties": {},
    "name": "project1",
    "description": "",
    "id": "6c2f2d0d-ecee-42e3-90be-7bb66d6da2f9",
    "orgId": "f098d692-e980-41a5-b349-83084fce1ea0",
    "_links": {
        "self": {
            "href": "/iaas/api/projects/6c2f2d0d-ecee-42e3-90be-7bb66d6da2f9"
        }
    }
}   

Use the project ID to update the placement policy and spread memory over the two cloud zones.

curl -X PATCH \
  "$url/iaas/api/projects/6c2f2d0d-ecee-42e3-90be-7bb66d6da2f9?apiVersion=$api_version"
  -H 'Content-Type: application/json' 
  -H "Authorization: Bearer $access_token" 
  -d '{ 
    "placementPolicy": "SPREAD_MEMORY" 
  }' | jq "."

How to specify spread by memory in cloud zones

This example shows how to use the cloud zone IDs in the project ID 6c2f2d0d-ecee-42e3-90be-7bb66d6da2f9 to check free memory in compute resources. Provided that free memory is available, you update the cloud zones with "placementPolicy": "SPREAD_MEMORY".

For information about placement policies in Cloud Assembly cloud zones, see Learn more about Cloud Assembly cloud zones.

To check available memory in zone ID 3c2bbe36-bf8e-4484-9c31-ce552422aaf1, list compute resources.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones/3c2bbe36-bf8e-4484-9c31-ce552422aaf1/computes?apiVersion=$api_version"  | jq "."
The response shows two clusters with available memory:
  • ESO_PKS_VC01_Cluster03 has 747 Gbytes available memory.
  • ESO_PKS_VC01_Cluster04 has 397 Gbytes available memory.
{
  "content": [
    {
      "externalRegionId": "Datacenter:datacenter-3",
      "tags": [],
      "type": "Cluster",
      "lifecycleState": "READY",
      "powerState": "ON",
      "customProperties": {
        "vcUuid": "74620317-856c-4f55-a862-dd2b43f07373",
        "hostCount": "2",
        "datacenter": "Datacenter:datacenter-3",
        "cpuPkgCount": "4",
        "cpuCoreCount": "56",
        "vsanConfigId": "52a60c7a-ef2e-af08-7cb2-36b06f686ebb",
        "isVsanEnabled": "true",
        "MaxVCPUperInstance": "56",
        "MemoryAvailableBytes": "747407147008"
      },
      "externalId": "domain-c21",
      "name": "ESO_PKS_VC01_Cluster03",
      "id": "e03f62e1-9a48-4d2c-8aa7-7bdb97293749",
      "createdAt": "2022-07-25",
      "updatedAt": "2022-07-26",
      "orgId": "f098d692-e980-41a5-b349-83084fce1ea0"
    },
    {
      "externalRegionId": "Datacenter:datacenter-3",
      "tags": [],
      "type": "Cluster",
      "lifecycleState": "READY",
      "powerState": "ON",
      "customProperties": {
        "vcUuid": "74620317-856c-4f55-a862-dd2b43f07373",
        "hostCount": "1",
        "datacenter": "Datacenter:datacenter-3",
        "cpuPkgCount": "2",
        "cpuCoreCount": "28",
        "vsanConfigId": "",
        "isVsanEnabled": "false",
        "MaxVCPUperInstance": "56",
        "MemoryAvailableBytes": "397091536896"
      },
      "externalId": "domain-c24",
      "name": "ESO_PKS_VC01_Cluster04",
      "id": "d2d42957-b6df-4e45-879a-93dfbec9a528",
      "createdAt": "2022-07-25",
      "updatedAt": "2022-07-26",
      "orgId": "f098d692-e980-41a5-b349-83084fce1ea0"
    }
  ],
  "totalElements": 2,
  "numberOfElements": 2
}

Use the zone ID 3c2bbe36-bf8e-4484-9c31-ce552422aaf1 to spread memory over the clusters.

curl -X PATCH \
  "$url/iaas/api/zones/3c2bbe36-bf8e-4484-9c31-ce552422aaf1?apiVersion=$api_version"
  -H 'Content-Type: application/json' 
  -H "Authorization: Bearer $access_token" 
  -d '{ 
    "placementPolicy": "SPREAD_MEMORY" 
  }' | jq "."

To check available memory in zone ID 8992bdf0-136f-401c-822a-e22dae67259b, list compute resources.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones/8992bdf0-136f-401c-822a-e22dae67259b/computes?apiVersion=$api_version"  | jq "."
The response shows two clusters with available memory:
  • ESO_PKS_VC01_Cluster01 has 830 Gbytes available memory.
  • ESO_PKS_VC01_Cluster05 has 397 Gbytes available memory.
{
  "content": [
    {
      "externalRegionId": "Datacenter:datacenter-3",
      "tags": [],
      "type": "Cluster",
      "lifecycleState": "READY",
      "powerState": "ON",
      "customProperties": {
        "vcUuid": "74620317-856c-4f55-a862-dd2b43f07373",
        "hostCount": "5",
        "datacenter": "Datacenter:datacenter-3",
        "cpuPkgCount": "10",
        "cpuCoreCount": "140",
        "vsanConfigId": "52de077e-2f21-b24c-536b-79ef9a412968",
        "isVsanEnabled": "true",
        "MaxVCPUperInstance": "56",
        "MemoryAvailableBytes": "830677712896"
      },
      "externalId": "domain-c18",
      "name": "ESO_PKS_VC01_Cluster01",
      "id": "98691ba2-2f84-4d31-a9f1-690d254c5305",
      "createdAt": "2022-07-25",
      "updatedAt": "2022-07-26",
      "orgId": "f098d692-e980-41a5-b349-83084fce1ea0"
    },
    {
      "externalRegionId": "Datacenter:datacenter-3",
      "tags": [],
      "type": "Cluster",
      "lifecycleState": "READY",
      "powerState": "ON",
      "customProperties": {
        "vcUuid": "74620317-856c-4f55-a862-dd2b43f07373",
        "hostCount": "1",
        "datacenter": "Datacenter:datacenter-3",
        "cpuPkgCount": "2",
        "cpuCoreCount": "28",
        "vsanConfigId": "",
        "isVsanEnabled": "false",
        "MaxVCPUperInstance": "56",
        "MemoryAvailableBytes": "397045399552"
      },
      "externalId": "domain-c26",
      "name": "ESO_PKS_VC01_Cluster05",
      "id": "f576f346-ed3b-4180-acdc-3c217e9fa0fd",
      "createdAt": "2022-07-25",
      "updatedAt": "2022-07-26",
      "orgId": "f098d692-e980-41a5-b349-83084fce1ea0"
    }
  ],
  "totalElements": 2,
  "numberOfElements": 2
}

Use the zone ID 8992bdf0-136f-401c-822a-e22dae67259b to spread memory over the clusters.

curl -X PATCH \
  "$url/iaas/api/zones/8992bdf0-136f-401c-822a-e22dae67259b?apiVersion=$api_version"
  -H 'Content-Type: application/json' 
  -H "Authorization: Bearer $access_token" 
  -d '{ 
    "placementPolicy": "SPREAD_MEMORY" 
  }' | jq "."