diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py index 51e0242b..287cf48b 100755 --- a/hooks/nova_cc_hooks.py +++ b/hooks/nova_cc_hooks.py @@ -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'): diff --git a/unit_tests/test_nova_cc_hooks.py b/unit_tests/test_nova_cc_hooks.py index 0a7d3dbf..b5415cd0 100644 --- a/unit_tests/test_nova_cc_hooks.py +++ b/unit_tests/test_nova_cc_hooks.py @@ -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',