Set cross_az_attach mode from ncc relation configuration
The cross_az_attach property needs to be configured on the compute nodes. The policy is set on the ncc service and is propigated to the compute nodes on the cloud-compute relation. Update the relevant cinder config setting based on the value provided. Note, the default value for cross_az_attach is aligned with the nova default of True. Closes-Bug: #1899084 Change-Id: I7d00b50acbfe05dfd943a3511126b507fc570aeb
This commit is contained in:
parent
75975ff917
commit
17e44e12e3
@ -503,6 +503,17 @@ class CloudComputeContext(context.OSContextGenerator):
|
||||
rid=rid, unit=unit)
|
||||
return volume_service
|
||||
|
||||
@property
|
||||
def cross_az_attach(self):
|
||||
# Default to True as that is the nova default
|
||||
cross_az_attach = True
|
||||
for rid in relation_ids('cloud-compute'):
|
||||
for unit in related_units(rid):
|
||||
setting = relation_get('cross_az_attach', rid=rid, unit=unit)
|
||||
if setting is not None:
|
||||
cross_az_attach = setting
|
||||
return cross_az_attach
|
||||
|
||||
@property
|
||||
def region(self):
|
||||
region = None
|
||||
@ -733,6 +744,7 @@ class CloudComputeContext(context.OSContextGenerator):
|
||||
vol_service = self.volume_context()
|
||||
if vol_service:
|
||||
ctxt['volume_service'] = vol_service
|
||||
ctxt['cross_az_attach'] = self.cross_az_attach
|
||||
|
||||
if self.restart_trigger():
|
||||
ctxt['restart_trigger'] = self.restart_trigger()
|
||||
|
@ -6,4 +6,5 @@ catalog_info = {{ volume_catalog_info }}
|
||||
{% if region -%}
|
||||
os_region_name = {{ region }}
|
||||
{% endif %}
|
||||
cross_az_attach = {{ cross_az_attach }}
|
||||
{% endif -%}
|
||||
|
@ -132,7 +132,32 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
self.related_units.return_value = 'nova-cloud-controller/0'
|
||||
cloud_compute = context.CloudComputeContext()
|
||||
self.test_relation.set({'volume_service': 'cinder'})
|
||||
self.assertEqual({'volume_service': 'cinder'}, cloud_compute())
|
||||
self.assertEqual({'volume_service': 'cinder',
|
||||
'cross_az_attach': True}, cloud_compute())
|
||||
|
||||
@patch.object(context, '_network_manager')
|
||||
def test_cloud_compute_cross_az_context(self, netman):
|
||||
netman.return_value = None
|
||||
self.relation_ids.return_value = 'cloud-compute:1'
|
||||
self.related_units.return_value = 'nova-cloud-controller/0'
|
||||
cloud_compute = context.CloudComputeContext()
|
||||
|
||||
# Check no cross_az_attach value set, defaults to cross_az_attach=True
|
||||
self.test_relation.set({'volume_service': 'cinder'})
|
||||
self.assertEqual({'volume_service': 'cinder',
|
||||
'cross_az_attach': True}, cloud_compute())
|
||||
|
||||
# Check that explicit True setting for cross_az_attach
|
||||
self.test_relation.set({'volume_service': 'cinder',
|
||||
'cross_az_attach': True})
|
||||
self.assertEqual({'volume_service': 'cinder',
|
||||
'cross_az_attach': True}, cloud_compute())
|
||||
|
||||
# Check false setting for cross_az_attach
|
||||
self.test_relation.set({'volume_service': 'cinder',
|
||||
'cross_az_attach': False})
|
||||
self.assertEqual({'volume_service': 'cinder',
|
||||
'cross_az_attach': False}, cloud_compute())
|
||||
|
||||
@patch.object(context, '_network_manager')
|
||||
def test_cloud_compute_flatdhcp_context(self, netman):
|
||||
|
Loading…
x
Reference in New Issue
Block a user