Merge "Use config validation to reject invalid max_over_subscription_ratio"
This commit is contained in:
commit
328d957063
|
@ -81,6 +81,7 @@ share_opts = [
|
|||
cfg.FloatOpt(
|
||||
'max_over_subscription_ratio',
|
||||
default=20.0,
|
||||
min=1.0,
|
||||
help='Float representation of the over subscription ratio '
|
||||
'when thin provisioning is involved. Default ratio is '
|
||||
'20.0, meaning provisioned capacity can be 20 times '
|
||||
|
@ -892,11 +893,7 @@ class ShareDriver(object):
|
|||
|
||||
def check_for_setup_error(self):
|
||||
"""Check for setup error."""
|
||||
max_ratio = self.configuration.safe_get('max_over_subscription_ratio')
|
||||
if not max_ratio or float(max_ratio) < 1.0:
|
||||
msg = (_("Invalid max_over_subscription_ratio '%s'. "
|
||||
"Valid value should be >= 1.0.") % max_ratio)
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
pass
|
||||
|
||||
def do_setup(self, context):
|
||||
"""Any initialization the share driver does while starting."""
|
||||
|
|
|
@ -256,18 +256,11 @@ class ShareDriverTestCase(test.TestCase):
|
|||
self.assertEqual([],
|
||||
share_driver.get_share_server_pools('fake_server'))
|
||||
|
||||
@ddt.data(0.8, 1.0, 10.5, 20.0, None, '1', '1.1')
|
||||
def test_check_for_setup_error(self, value):
|
||||
def test_check_for_setup_error(self):
|
||||
driver.CONF.set_default('driver_handles_share_servers', False)
|
||||
share_driver = driver.ShareDriver(False)
|
||||
share_driver.configuration = configuration.Configuration(None)
|
||||
self.mock_object(share_driver.configuration, 'safe_get',
|
||||
mock.Mock(return_value=value))
|
||||
if value and float(value) >= 1.0:
|
||||
share_driver.check_for_setup_error()
|
||||
else:
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
share_driver.check_for_setup_error)
|
||||
share_driver.check_for_setup_error()
|
||||
|
||||
def test_snapshot_support_exists(self):
|
||||
driver.CONF.set_default('driver_handles_share_servers', True)
|
||||
|
|
Loading…
Reference in New Issue