Using Host Aggregates for More Flexible Instance Management

It is a common practice for a Metacloud admin to define host aggregates and label them as Availability Zones (AZs) for various purposes, such as the following:

  • Segregating resources according to operating system (OS), storage type, or similar groupings.
  • Designating resources for different teams of users in your organization.
  • Dedicating resources for specific projects, such as testing a new cloud application.

This practice can create guidelines for organizing instances in ways that are meaningful to your business. Non-admin users can follow those guidelines by attaching new instances to those AZs.

Note: For detailed explanation of AZs, see Clarifying what "Availability Zone" Means in Metacloud. For an explanation of host aggregates, see the section AZs Based on Host Aggregates in that article.

Limitations with the Compute (Nova) service scheduler present a drawback to this practice of attaching new instances to AZs: If a Metacloud Admin deletes an AZ that has attached instances, users have problems resizing or migrating those instances. See Troubleshooting VMs From Deleted Host Aggregates Tagged as Availability Zones.

Letting Users Attach VMs Directly to Host Aggregates

A Metacloud admin can avoid these issues by letting users attach instances directly to host aggregates. Because host aggregates that have not been tagged as AZs are not visible to non-admin users, an admin can enable this attachment by creating flavors that share metadata with host aggregates and then having users launch instances with those flavors.

The following steps result in a user launching instances that are hosted by Metacloud Hypervisors (MHV) within a given host aggregate.

Note: The workflow involves using the Nova and OpenStack command-line interface (CLI) clients.

1. Create a host aggregate:

 $ nova aggregate-create mg_host_agg_5
+----+---------------+-------------------+-------+----------+
| Id | Name          | Availability Zone | Hosts | Metadata |
+----+---------------+-------------------+-------+----------+
| 31 | host_agg_1    | -                 |       |          |
+----+---------------+-------------------+-------+----------+

Note the ID of new aggregate. You will use it when you add MHVs to it.

2. View a list of hosts, so that you can add Metacloud Hypervisors (MHVs) from the list, to the new aggregate:

$ openstack host list
+------------------------------+-------------+----------+
| Host Name                    | Service     | Zone     |
+------------------------------+-------------+----------+
| mcp2.<AZ.DOMAIN>             | conductor   | internal |
| mcp3.<AZ.DOMAIN>             | conductor   | internal |
| mcp3.<AZ.DOMAIN>             | scheduler   | internal |
| mcp3.<AZ.DOMAIN>             | consoleauth | internal |
| mcp3.<AZ.DOMAIN>             | console     | internal |
| mcp2.<AZ.DOMAIN>             | consoleauth | internal |
| mcp2.<AZ.DOMAIN>             | console     | internal |
| mcp2.<AZ.DOMAIN>             | scheduler   | internal |
| mcp1.<AZ.DOMAIN>             | consoleauth | internal |
| mcp1.<AZ.DOMAIN>             | conductor   | internal |
| mcp1.<AZ.DOMAIN>             | scheduler   | internal |
| mcp1.<AZ.DOMAIN>             | console     | internal |
| mhv1.<AZ.DOMAIN>             | compute     | AZ_2     |
| mhv2.<AZ.DOMAIN>             | compute     | AZ_2     |
| mhv8.<AZ.DOMAIN>             | compute     | AZ_1     |
| mhv9.<AZ.DOMAIN>             | compute     | AZ_1     |
| mhv5.<AZ.DOMAIN>             | compute     | AZ_3     |
| mhv5.<AZ.DOMAIN>             | compute     | AZ_3     |
| mhv6.<AZ.DOMAIN>             | compute     | AZ_1     |
| mhv10.<AZ.DOMAIN>            | compute     | AZ_1     |
| mhv3.<AZ.DOMAIN>             | compute     | AZ_3     |
| mhv7.<AZ.DOMAIN>             | compute     | AZ_1     |
+------------------------------+-------------+----------+

3. Add MHVs to the aggregate to host new instances:

$ nova aggregate-add-host 31 mhv1.stage1.mc.metacloud.in
Host mhv1.stage1.mc.metacloud.in has been successfully added for aggregate 31 
+----+---------------+-------------------+---------------------------------------------------------------+----------+
| Id | Name          | Availability Zone | Hosts                                                         | Metadata |
+----+---------------+-------------------+---------------------------------------------------------------+----------+
| 31 | host_agg_1    | -                 | 'mhv10.<AZ.DOMAIN>', 'mhv1.<AZ.DOMAIN>'                       |          |
+----+---------------+-------------------+---------------------------------------------------------------+----------+

Repeat this step for every MHV you want to add.

Note: An MHV can be associated with multiple host aggregates.

4. Add metadata to the host aggregate:

$ nova aggregate-set-metadata 31 coolhardware=true
Metadata has been successfully updated for aggregate 31.
+----+---------------+-------------------+----------------------------------------------------------------------------------------------+---------------------+
| Id | Name          | Availability Zone | Hosts                                                                                        | Metadata            |
+----+---------------+-------------------+----------------------------------------------------------------------------------------------+---------------------+
| 31 | host_agg_1    | -                 | 'mhv10.<AZ.DOMAIN>', 'mhv1.<AZ.DOMAIN>', 'mhv2.<AZ.DOMAIN>'                                  | 'coolhardware=true' |
+----+---------------+-------------------+----------------------------------------------------------------------------------------------+---------------------+

5. Create a flavor. Use the auto value parameter to have an ID automatically generated for the flavor (See Managing Flavors Using the Command-line Interface for more information.):

$ nova flavor-create --is-public true m1.flavor_2 auto 256 20 1
+--------------------------------------+----------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name           | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+----------------+-----------+------+-----------+------+-------+-------------+-----------+
| <FLAVOR_UUID>                        | m1.flavor_2    | 256       | 20   | 0         |      | 1     | 1.0         | True      |
+--------------------------------------+----------------+-----------+------+-----------+------+-------+-------------+-----------+

6. Use an extra_specs key pair to associate the flavor with metadata created for the host aggregate:

$ nova flavor-key <FLAVOR_UUID> set coolhardware=true
$ nova flavor-show <FLAVOR_UUID>
+----------------------------+--------------------------------------+
| Property                   | Value                                |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                |
| OS-FLV-EXT-DATA:ephemeral  | 0                                    |
| disk                       | 20                                   |
| extra_specs                | {"coolhardware": "true"}             |
| id                         | <FLAVOR_UUID>                        |
| name                       | m1.flavor_2                          |
| os-flavor-access:is_public | True                                 |
| ram                        | 256                                  |
| rxtx_factor                | 1.0                                  |
| swap                       |                                      |
| vcpus                      | 1                                    |
+----------------------------+--------------------------------------+

7. Launch an image with the flavor. Note that you do not specify an AZ.

$ openstack server create server_1 --flavor m1.flavor_2  --image ubuntu_1404_server_cloudimg_amd64 --nic net-id=<NETWORK_UUID>
+-------------------------------------+--------------------------------------------------------------------------+
| Field                               | Value                                                                    |
+-------------------------------------+--------------------------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                                   |
| OS-EXT-AZ:availability_zone         |                                                                          |
| OS-EXT-SRV-ATTR:host                | None                                                                     |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                                                     |
| OS-EXT-SRV-ATTR:instance_name       | instance-00003fd9                                                        |
| OS-EXT-STS:power_state              | NOSTATE                                                                  |
| OS-EXT-STS:task_state               | None                                                                     |
| OS-EXT-STS:vm_state                 | building                                                                 |
| OS-SRV-USG:launched_at              | None                                                                     |
| OS-SRV-USG:terminated_at            | None                                                                     |
| accessIPv4                          |                                                                          |
| accessIPv6                          |                                                                          |
| addresses                           |                                                                          |
| adminPass                           | 5Jau5iZHkEJm                                                             |
| config_drive                        |                                                                          |
| created                             | 2017-04-04T00:40:36Z                                                     |
| flavor                              | m1.flavor_2 (<FLAVOR_UUID>)                                              |
| hostId                              |                                                                          |
| id                                  | <INSTANCE_UUID>                                                          |
| image                               | ubuntu_1404_server_cloudimg_amd64 (<IMAGE_UUID>)                         |
| key_name                            | None                                                                     |
| name                                | server_1                                                                 |
| progress                            | 0                                                                        |
| project_id                          | <PROJECT_UUID>                                                           |
| properties                          |                                                                          |
| security_groups                     | name='default'                                                           |
| status                              | BUILD                                                                    |
| updated                             | 2017-04-04T00:40:36Z                                                     |
| user_id                             | <USER_UUID>                                                              |
| volumes_attached                    |                                                                          |
+-------------------------------------+--------------------------------------------------------------------------+

8. View details about the new instance to verify that it is running on a host in the aggregate you created. 

$ openstack server show <INSTANCE_UUID>
+-------------------------------------+--------------------------------------------------------------------------+
| Field                               | Value                                                                    |
+-------------------------------------+--------------------------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                                   |
| OS-EXT-AZ:availability_zone         | enic                                                                     |
| OS-EXT-SRV-ATTR:host                | mhv10.<AZ.DOMAIN>                                                        |
| OS-EXT-SRV-ATTR:hypervisor_hostname | mhv10.<AZ.DOMAIN>                                                        |
| OS-EXT-SRV-ATTR:instance_name       | instance-00003fd9                                                        |
| OS-EXT-STS:power_state              | Running                                                                  |
| OS-EXT-STS:task_state               | None                                                                     |
| OS-EXT-STS:vm_state                 | active                                                                   |
| OS-SRV-USG:launched_at              | 2017-04-04T00:40:42.000000                                               |
| OS-SRV-USG:terminated_at            | None                                                                     |
| accessIPv4                          |                                                                          |
| accessIPv6                          |                                                                          |
| addresses                           | silver=<IP_ADDRESS>                                                      |
| config_drive                        |                                                                          |
| created                             | 2017-04-04T00:40:36Z                                                     |
| flavor                              | m1.flavor_2 (<FLAVOR_UUID>)                                              |
| hostId                              | <HOST_UUID>                                                              |
| id                                  | <INSTANCE_UUID>                                                          |
| image                               | ubuntu_1404_server_cloudimg_amd64 (<IMAGE_UUID>)                         |
| key_name                            | None                                                                     |
| name                                | server_1                                                                 |
| progress                            | 0                                                                        |
| project_id                          | <PROJECT_UUID>                                                           |
| properties                          |                                                                          |
| security_groups                     | name='default'                                                           |
| status                              | ACTIVE                                                                   |
| updated                             | 2017-04-04T00:40:42Z                                                     |
| user_id                             | <USER_UUID>                                                              |
| volumes_attached                    |                                                                          |
+-------------------------------------+--------------------------------------------------------------------------+

 

Have more questions? Submit a request
Powered by Zendesk