Summary
Before creating a compute instance, I need to know if there is sufficient capacity is available.
References
Find Available Capacity
To find what available capacity is available for all fault domains in the Sandbox compartment, a JSON file containing the query needs to be constructed. A sample to download is called shape-availabilities.json. To build your own query file, you will need the information from the queries:
The data returned by the compute compute-capacity-report create
command can be returned in either tabular or JSON format. The tabular format is easier to scan, while the JSON can return all fields:
Create Table of Available Shapes
Once the shape-availabilities.json file has been downloaded or built, run the following commands to generate a table of available shapes:
export sandbox_ocid=$( \ oci iam compartment list \ --name 'Sandbox' \ --query 'data[0].id' \ --raw-output \ ) export ad_name=$( \ oci iam availability-domain list \ --compartment-id $sandbox_ocid \ --query 'data[0].name' \ --raw-output \ ) oci compute compute-capacity-report create \ --compartment-id $sandbox_ocid \ --availability-domain $ad_name \ --shape-availabilities 'file://shape-availabilities.json' \ --query 'data."shape-availabilities"[*].{"FD Name":"fault-domain", "Availabilty Status":"availability-status", "Shape Name":"instance-shape"}' \ --output table
Sample output is:
+--------------------+----------------+------------------------+ | Availabilty Status | FD Name | Shape Name | +--------------------+----------------+------------------------+ | AVAILABLE | FAULT-DOMAIN-1 | VM.Standard.E2.1.Micro | | AVAILABLE | FAULT-DOMAIN-2 | VM.Standard.E2.1.Micro | | AVAILABLE | FAULT-DOMAIN-3 | VM.Standard.E2.1.Micro | +--------------------+----------------+------------------------+
Create JSON File of Available Shapes
Once the shape-availabilities.json file has been downloaded or built, run the following commands to create a JSON file of available shapes:
export sandbox_ocid=$( \ oci iam compartment list \ --name 'Sandbox' \ --query 'data[0].id' \ --raw-output \ ) export ad_name=$( \ oci iam availability-domain list \ --compartment-id $sandbox_ocid \ --query 'data[0].name' \ --raw-output \ ) oci compute compute-capacity-report create \ --compartment-id $sandbox_ocid \ --availability-domain $ad_name \ --shape-availabilities 'file://shape-availabilities.json' \ >compute-capacity-report-result.json
The JSON output is uploaded as compute-capacity-report-result.json