Merge "Fix integer/float conversions for py34 compatibility"
This commit is contained in:
commit
88aade204a
|
@ -277,7 +277,7 @@ class WSGIService(service.ServiceBase):
|
||||||
self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
|
self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
|
||||||
self.port = getattr(CONF, '%s_listen_port' % name, 0)
|
self.port = getattr(CONF, '%s_listen_port' % name, 0)
|
||||||
self.workers = getattr(CONF, '%s_workers' % name, None)
|
self.workers = getattr(CONF, '%s_workers' % name, None)
|
||||||
if self.workers < 1:
|
if self.workers is not None and self.workers < 1:
|
||||||
LOG.warn(
|
LOG.warn(
|
||||||
_LW("Value of config option %(name)s_workers must be integer "
|
_LW("Value of config option %(name)s_workers must be integer "
|
||||||
"greater than 1. Input value ignored.") % {'name': name})
|
"greater than 1. Input value ignored.") % {'name': name})
|
||||||
|
|
|
@ -299,7 +299,7 @@ class ShareDriver(object):
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""Check for setup error."""
|
"""Check for setup error."""
|
||||||
max_ratio = self.configuration.safe_get('max_over_subscription_ratio')
|
max_ratio = self.configuration.safe_get('max_over_subscription_ratio')
|
||||||
if max_ratio < 1.0:
|
if not max_ratio or float(max_ratio) < 1.0:
|
||||||
msg = (_("Invalid max_over_subscription_ratio '%s'. "
|
msg = (_("Invalid max_over_subscription_ratio '%s'. "
|
||||||
"Valid value should be >= 1.0.") % max_ratio)
|
"Valid value should be >= 1.0.") % max_ratio)
|
||||||
raise exception.InvalidParameterValue(err=msg)
|
raise exception.InvalidParameterValue(err=msg)
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
|
||||||
|
|
||||||
# Do the unmount, handling split-related errors with retries.
|
# Do the unmount, handling split-related errors with retries.
|
||||||
retry_interval = 3 # seconds
|
retry_interval = 3 # seconds
|
||||||
for retry in range(wait_seconds / retry_interval):
|
for retry in range(int(wait_seconds / retry_interval)):
|
||||||
try:
|
try:
|
||||||
self._unmount_volume(volume_name, force=force)
|
self._unmount_volume(volume_name, force=force)
|
||||||
LOG.debug('Volume %s unmounted.', volume_name)
|
LOG.debug('Volume %s unmounted.', volume_name)
|
||||||
|
|
|
@ -845,7 +845,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||||
elif (network_info['network_type'] == 'vlan'
|
elif (network_info['network_type'] == 'vlan'
|
||||||
and (network_info['segmentation_id'] is None
|
and (network_info['segmentation_id'] is None
|
||||||
or int(network_info['segmentation_id']) > 4094
|
or int(network_info['segmentation_id']) > 4094
|
||||||
or int(network_info['segmentation_id'] < 1))):
|
or int(network_info['segmentation_id']) < 1)):
|
||||||
msg = _('A segmentation ID %s was specified but is not valid for '
|
msg = _('A segmentation ID %s was specified but is not valid for '
|
||||||
'a VLAN network type; the segmentation ID must be an '
|
'a VLAN network type; the segmentation ID must be an '
|
||||||
'integer value in the range of [1,4094]')
|
'integer value in the range of [1,4094]')
|
||||||
|
@ -854,7 +854,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||||
elif (network_info['network_type'] == 'vxlan'
|
elif (network_info['network_type'] == 'vxlan'
|
||||||
and (network_info['segmentation_id'] is None
|
and (network_info['segmentation_id'] is None
|
||||||
or int(network_info['segmentation_id']) > 16777215
|
or int(network_info['segmentation_id']) > 16777215
|
||||||
or int(network_info['segmentation_id'] < 1))):
|
or int(network_info['segmentation_id']) < 1)):
|
||||||
msg = _('A segmentation ID %s was specified but is not valid for '
|
msg = _('A segmentation ID %s was specified but is not valid for '
|
||||||
'a VXLAN network type; the segmentation ID must be an '
|
'a VXLAN network type; the segmentation ID must be an '
|
||||||
'integer value in the range of [1,16777215]')
|
'integer value in the range of [1,16777215]')
|
||||||
|
@ -863,7 +863,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||||
elif (network_info['network_type'] == 'gre'
|
elif (network_info['network_type'] == 'gre'
|
||||||
and (network_info['segmentation_id'] is None
|
and (network_info['segmentation_id'] is None
|
||||||
or int(network_info['segmentation_id']) > 4294967295
|
or int(network_info['segmentation_id']) > 4294967295
|
||||||
or int(network_info['segmentation_id'] < 1))):
|
or int(network_info['segmentation_id']) < 1)):
|
||||||
msg = _('A segmentation ID %s was specified but is not valid for '
|
msg = _('A segmentation ID %s was specified but is not valid for '
|
||||||
'a GRE network type; the segmentation ID must be an '
|
'a GRE network type; the segmentation ID must be an '
|
||||||
'integer value in the range of [1, 4294967295]')
|
'integer value in the range of [1, 4294967295]')
|
||||||
|
|
|
@ -207,14 +207,14 @@ class ShareDriverTestCase(test.TestCase):
|
||||||
self.assertEqual([],
|
self.assertEqual([],
|
||||||
share_driver.get_share_server_pools('fake_server'))
|
share_driver.get_share_server_pools('fake_server'))
|
||||||
|
|
||||||
@ddt.data(0.8, 1.0, 10.5, 20.0, None)
|
@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, value):
|
||||||
driver.CONF.set_default('driver_handles_share_servers', False)
|
driver.CONF.set_default('driver_handles_share_servers', False)
|
||||||
share_driver = driver.ShareDriver(False)
|
share_driver = driver.ShareDriver(False)
|
||||||
share_driver.configuration = configuration.Configuration(None)
|
share_driver.configuration = configuration.Configuration(None)
|
||||||
self.mock_object(share_driver.configuration, 'safe_get',
|
self.mock_object(share_driver.configuration, 'safe_get',
|
||||||
mock.Mock(return_value=value))
|
mock.Mock(return_value=value))
|
||||||
if value >= 1.0:
|
if value and float(value) >= 1.0:
|
||||||
share_driver.check_for_setup_error()
|
share_driver.check_for_setup_error()
|
||||||
else:
|
else:
|
||||||
self.assertRaises(exception.InvalidParameterValue,
|
self.assertRaises(exception.InvalidParameterValue,
|
||||||
|
|
Loading…
Reference in New Issue