Merge "Set cross_az_attach setting on cloud-compute relation"

This commit is contained in:
Zuul 2021-06-08 06:56:33 +00:00 committed by Gerrit Code Review
commit 179930d364
2 changed files with 16 additions and 0 deletions

View File

@ -654,6 +654,7 @@ def get_compute_config(remote_restart=False):
# this may not even be needed.
'ec2_host': hookenv.unit_get('private-address'),
'region': hookenv.config('region'),
'cross_az_attach': hookenv.config('cross-az-attach'),
}
rel_settings.update(console_settings())
rel_settings.update(ncc_utils.serial_console_settings())
@ -719,6 +720,18 @@ def set_region_on_relation_from_config(rid=None):
hookenv.relation_set(relation_id=rid, region=hookenv.config('region'))
def set_cross_az_attach_on_relation_from_config(rid=None):
"""Helper function that sets the cross-az-attach policy for that relation
to trigger a change for any units that see it differently.
:param rid: The relation to set, or if None, the current one related
to the hook.
:type rid: Union[str, None]
"""
hookenv.relation_set(relation_id=rid,
cross_az_attach=hookenv.config('cross-az-attach'))
def update_ssh_keys_and_notify_compute_units(rid=None, unit=None):
"""Update and notify the collected ssh keys to nova-compute units
@ -1174,6 +1187,7 @@ def upgrade_charm():
identity_joined(rid=r_id)
for r_id in hookenv.relation_ids('cloud-compute'):
set_region_on_relation_from_config(r_id)
set_cross_az_attach_on_relation_from_config(r_id)
for unit in hookenv.related_units(r_id):
update_ssh_keys_and_notify_compute_units(r_id, unit)
for r_id in hookenv.relation_ids('shared-db'):

View File

@ -615,6 +615,7 @@ class NovaCCHooksTests(CharmTestCase):
console_access_protocol=None,
ca_cert='foocert64',
region='RegionOne',
cross_az_attach=True,
volume_service='cinder',
ec2_host='nova-cc-host1',
network_manager='neutron',
@ -657,6 +658,7 @@ class NovaCCHooksTests(CharmTestCase):
quantum_host='nova-cc-host1',
quantum_security_groups='yes',
region='RegionOne',
cross_az_attach=True,
volume_service='cinder',
ec2_host='nova-cc-host1',
quantum_plugin='bob',