Management of nova Host Aggregates and Availability Zones with OpenStack CLI

Here is a list of commands to add and manage compute nodes in availability zones with OpenStack CLI.

It is useful for instance in case you want to spawn an instance on a desired compute node.

  • Log in on your OpenStack cli, source cloud-admin environment

  • List available compute nodes:

    $ nova hypervisor-list
    +----+---------------------+-------+----------+
    | ID | Hypervisor hostname | State | Status   |
    +----+---------------------+-------+----------+
    | 1  | ct1-r2-s11.maas     | up    | enabled  |
    | 4  | ct1-r3-s11.maas     | up    | enabled  |
    | 6  | ct1-r1-s01.maas     | up    | enabled  |
    ...
    | 24 | ct1-r1-s12.maas     | up    | enabled  |
    | 27 | ct1-r2-s09.maas     | up    | disabled |
    | 30 | ct1-r2-s16.maas     | up    | disabled |
    | 33 | ct1-r1-s09.maas     | up    | enabled  |
    +----+---------------------+-------+----------+
    
  • We want to create an instance on ct1-r2-s16 which is currently disabled.

    To enable a compute node:

    $ openstack compute service set –enable <compute-node-hostname> nova-compute

    To disable a compute node:

    $ openstack compute service set –disable <compute-node-hostname> nova-compute

    Also, you can enable/disable compute nodes via Openstack dashboard with Admin credentials

  • Create an host aggregate:

    $ openstack aggregate create SingleHostAtCT
    
  • Associate nova Availability Zone to the aggregate:

    $ openstack aggregate set --zone SingleHostAtCT-AZ SingleHostAtCT
    
  • Associate compute node to the aggregate:

    $ openstack aggregate add host SingleHostAtCT ct1-r2-s16
    
  • List host aggregates:

    $ openstack aggregate list
    +----+----------------+-------------------+
    | ID | Name           | Availability Zone |
    +----+----------------+-------------------+
    |  4 | SingleHostAtCT | SingleHostAtCT-AZ |
    +----+----------------+-------------------+
    
  • Show details of host aggregate:

    $ openstack aggregate show SingleHostAtCT
    +-------------------+----------------------------+
    | Field             | Value                      |
    +-------------------+----------------------------+
    | availability_zone | SingleHostAtCT-AZ          |
    | created_at        | 2018-09-06T10:29:36.000000 |
    | deleted           | False                      |
    | deleted_at        | None                       |
    | hosts             | [u'ct1-r2-s16']            |
    | id                | 4                          |
    | name              | SingleHostAtCT             |
    | properties        |                            |
    | updated_at        | None                       |
    +-------------------+----------------------------+
    

It is now possible to spawn instances selecting the new AZ from the Availability Zone tab on the dashboard.

  • Remove host from aggregate:

    $  openstack aggregate remove host SingleHostAtCT ct1-r2-s16
    
  • Delete host aggregate:

    $ openstack aggregate delete SingleHostAtCT