This option is used to specify the default AZ for the whole service. So when
creating a new volume this value is used to specify the AZ of a volume.
Previously we were overloading the use of the storage_availability_zone option
which is also used to specify what AZ a service belongs to. We still fail back
on the storage_availability_zone when creating a new volume if the
default_availability_zone is not set.
Fixes bug:
1221260
Change-Id: Iec381f50c9aeb4a0abbcaa1d7b0107de09a73544
cfg.StrOpt('storage_availability_zone',
default='nova',
help='availability zone of this node'),
+ cfg.StrOpt('default_availability_zone',
+ default=None,
+ help='default availability zone to use when creating a new volume. '
+ 'If this is not set then we use the value from the '
+ 'storage_availability_zone option as the default '
+ 'availability_zone for new volumes.'),
cfg.ListOpt('memcached_servers',
default=None,
help='Memcached servers or None for in process cache.'),
None,
test_meta)
+ def test_create_volume_uses_default_availability_zone(self):
+ """Test setting availability_zone correctly during volume create."""
+ volume_api = cinder.volume.api.API()
+
+ def fake_list_availability_zones():
+ return ({'name': 'az1', 'available': True},
+ {'name': 'az2', 'available': True},
+ {'name': 'default-az', 'available': True})
+
+ self.stubs.Set(volume_api,
+ 'list_availability_zones',
+ fake_list_availability_zones)
+
+ # Test backwards compatibility, default_availability_zone not set
+ CONF.set_override('storage_availability_zone', 'az2')
+ volume = volume_api.create(self.context,
+ 1,
+ 'name',
+ 'description')
+ self.assertEqual(volume['availability_zone'], 'az2')
+
+ CONF.set_override('default_availability_zone', 'default-az')
+ volume = volume_api.create(self.context,
+ 1,
+ 'name',
+ 'description')
+ self.assertEqual(volume['availability_zone'], 'default-az')
+
def test_create_volume_with_volume_type(self):
"""Test volume creation with default volume type."""
def fake_reserve(context, expire=None, project_id=None, **deltas):
pass
if availability_zone is None:
- availability_zone = CONF.storage_availability_zone
+ if CONF.default_availability_zone:
+ availability_zone = CONF.default_availability_zone
+ else:
+ # For backwards compatibility use the storge_availability_zone
+ availability_zone = CONF.storage_availability_zone
if not self.az_check_functor(availability_zone):
msg = _("Availability zone '%s' is invalid") % (availability_zone)
LOG.warn(msg)
# availability zone of this node (string value)
#storage_availability_zone=nova
+# default availability zone to use when creating a new volume.
+# If this is not set then we use the value from the
+# storage_availability_zone option as the default
+# availability_zone for new volumes. (string value)
+#default_availability_zone=<None>
+
# Memcached servers or None for in process cache. (list value)
#memcached_servers=<None>
#volume_dd_blocksize=1M
-# Total option count: 377
+# Total option count: 378