Set availability_zone as part of the cloud-compute relation

A new Juju action, to the nova-cloud-controller charm, will be
added to sync the nova-compute units Juju availability zones with
the availability from OpenStack.

It is useful in the context of a MAAS deployment, in order to map
MAAS AZs to OpenStack AZs.

Change-Id: I62f68f0c0c97aeca20a8afb32095d2972abd8473
This commit is contained in:
Ionut Balutoiu 2021-02-03 15:17:25 +00:00
parent e316cc66c3
commit 9f4369d9c2
2 changed files with 18 additions and 0 deletions

View File

@ -345,6 +345,10 @@ def compute_joined(rid=None):
'migration', cidr_network=config('libvirt-migration-network')),
}
juju_az = os.environ.get('JUJU_AVAILABILITY_ZONE')
if juju_az:
relation_set(relation_id=rid, availability_zone=juju_az)
if migration_enabled():
auth_type = config('migration-auth-type')
settings['migration_auth_type'] = auth_type

View File

@ -383,6 +383,20 @@ class NovaComputeRelationsTests(CharmTestCase):
hooks.compute_joined()
self.assertFalse(self.relation_set.called)
@patch('os.environ.get')
def test_compute_joined_with_juju_az(self, mock_env_get):
def environ_get_side_effect(key):
return {
'JUJU_AVAILABILITY_ZONE': 'az1',
}[key]
mock_env_get.side_effect = environ_get_side_effect
self.migration_enabled.return_value = False
hooks.compute_joined('cloud-compute:2')
self.relation_set.assert_called_with(**{
'relation_id': 'cloud-compute:2',
'availability_zone': 'az1',
})
def test_compute_joined_with_ssh_migration(self):
self.migration_enabled.return_value = True
self.test_config.set('migration-auth-type', 'ssh')