sodcalculator

10 Tech How-To

Create OpenStack Availability Zones via CLI

Guide 10-8279 · Updated · Step by step

This guide shows you how to create and configure availability zones (AZs) in OpenStack from the Linux command line. You’ll use the OpenStack client to define host aggregates, map them to availability zones, and verify the setup. You need working OpenStack credentials and the openstack CLI tool installed.

What You’ll Need

  • Access to an OpenStack deployment (admin or project admin role)
  • OpenStack CLI client installed (pip install python-openstackclient)
  • Source your openrc or clouds.yaml credentials file
  • List of compute hosts (nova-compute nodes) to group into AZs

Step-by-Step

  1. Source your credentials
    Run source openrc.sh (or your credential file) to set environment variables. Verify with openstack token issue – you should see a token ID.
  2. List existing host aggregates
    Run openstack aggregate list to see current aggregates and their AZ names. Note the IDs and names.
  3. Create a new host aggregate
    Use openstack aggregate create --zone . Replace <az-name> with the availability zone label (e.g., az1) and <aggregate-name> with a descriptive name (e.g., az1-aggregate). Example: openstack aggregate create --zone az1 az1-aggregate.
  4. Add compute hosts to the aggregate
    For each host you want in this AZ, run openstack aggregate add host . Example: openstack aggregate add host az1-aggregate compute1. Repeat for all hosts.
  5. Set additional metadata (optional)
    You can add custom metadata with openstack aggregate set --property key=value . For example, openstack aggregate set --property availability_zone=az1 az1-aggregate (though the --zone flag already sets this).
  6. Verify the aggregate
    Run openstack aggregate show to confirm the AZ name and host list. The output should show availability_zone set to your AZ.
  7. Check availability zones
    Run openstack availability zone list to see all AZs. Your new AZ should appear with the hosts listed as available.
  8. Test launching an instance in the new AZ
    Use openstack server create --flavor --image --availability-zone test-instance. If it launches successfully, your AZ is working.

Common Mistakes

  • Forgetting to source credentials – commands fail with authentication errors.
  • Using the same AZ name for multiple aggregates – OpenStack merges them, which may cause unexpected host grouping.
  • Adding a host that is already in another aggregate with a different AZ – the host will be associated with the last aggregate’s AZ, causing confusion.
  • Not checking host availability – if a host is disabled or in maintenance mode, it won’t show as available in the AZ.

Tips

  • Name aggregates clearly, e.g., az1-aggregate, to avoid confusion.
  • Use openstack aggregate list --long to see AZ names and host counts at a glance.
  • Plan your AZ layout before creating – think about fault domains (e.g., separate racks or power zones).
  • Document which hosts belong to which AZ for future maintenance.
  • Use the --zone flag when creating the aggregate; setting it later via metadata is less reliable.

Troubleshooting

  • AZ not showing in list
    Run openstack aggregate list and check if the aggregate exists. If not, recreate it. If it exists but AZ is missing, set it with openstack aggregate set --zone .
  • Host not appearing in AZ
    Check the host is up: openstack host list and openstack host show . Ensure the host is added to the aggregate: openstack aggregate show .
  • Instance fails to launch in AZ
    Check the AZ name is exactly as set (case-sensitive). Also verify the flavor and image exist. Look at the compute service logs on the host for scheduler errors.
  • Commands return ‘Unauthorized’
    Re-source your credentials and check your role. You need at least admin or project admin to manage aggregates.
  • Aggregate creation fails with ‘Conflict’
    Another aggregate may already have the same AZ name. Use a different AZ name or delete the conflicting aggregate if it’s unused.

Frequently Asked Questions

  1. Can I create an availability zone without a host aggregate?
    No, in OpenStack, availability zones are implemented via host aggregates. You must create an aggregate and assign hosts to it.
  2. What is the difference between an aggregate and an AZ?
    An aggregate is a grouping of hosts for scheduling purposes; an AZ is a user-facing label that maps to an aggregate. You can have multiple aggregates with the same AZ name, but it’s not recommended.
  3. Can I move a host from one AZ to another?
    Yes, remove the host from the old aggregate with openstack aggregate remove host , then add it to the new aggregate.
  4. How do I set a default AZ for a project?
    Set the availability_zone in the project’s quota or use a default in the flavor, but the simplest is to specify it when launching instances.
  5. Do I need to restart nova services after creating an AZ?
    No, the changes are picked up dynamically. However, if hosts are not showing, you may need to wait a few seconds or restart nova-scheduler in rare cases.
  6. Can I use the same AZ name for aggregates in different regions?
    Yes, but they will be independent. Each region has its own set of aggregates and AZs.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →