Merge "Fix some types in the FS and VMware drivers"

This commit is contained in:
Zuul 2019-01-28 06:14:25 +00:00 committed by Gerrit Code Review
commit db75918208
4 changed files with 10 additions and 8 deletions

View File

@ -436,7 +436,7 @@ class Store(glance_store.driver.Store):
(datadir_path,
priority) = self._get_datadir_path_and_priority(datadir)
priority_paths = self.priority_data_map.setdefault(
int(priority), [])
priority, [])
self._check_directory_paths(datadir_path, directory_paths,
priority_paths)
directory_paths.add(datadir_path)
@ -490,8 +490,9 @@ class Store(glance_store.driver.Store):
parts = [part.strip() for part in datadir.rsplit(":", 1)]
datadir_path = parts[0]
if len(parts) == 2 and parts[1]:
priority = parts[1]
if not priority.isdigit():
try:
priority = int(parts[1])
except ValueError:
msg = (_("Invalid priority value %(priority)s in "
"filesystem configuration") % {'priority': priority})
LOG.exception(msg)

View File

@ -463,8 +463,9 @@ class Store(glance_store.Store):
raise exceptions.BadStoreConfiguration(
store_name='vmware_datastore', reason=msg)
if len(parts) == 3 and parts[2]:
weight = parts[2]
if not weight.isdigit():
try:
weight = int(parts[2])
except ValueError:
msg = (_('Invalid weight value %(weight)s in '
'vmware_datastores configuration') %
{'weight': weight})
@ -501,7 +502,7 @@ class Store(glance_store.Store):
LOG.error(msg)
raise exceptions.BadStoreConfiguration(
store_name='vmware_datastore', reason=msg)
ds_map.setdefault(int(weight), []).append(ds_obj)
ds_map.setdefault(weight, []).append(ds_obj)
return ds_map
def configure_add(self):

View File

@ -391,7 +391,7 @@ class TestMultiStore(base.MultiStoreBaseTest,
parts = self.store._parse_datastore_info_and_weight(datastore)
self.assertEqual('a', parts[0])
self.assertEqual('b', parts[1])
self.assertEqual('100', parts[2])
self.assertEqual(100, parts[2])
def test_parse_datastore_info_and_weight_default_weight(self):
datastore = 'a:b'

View File

@ -396,7 +396,7 @@ class TestStore(base.StoreBaseTest,
parts = self.store._parse_datastore_info_and_weight(datastore)
self.assertEqual('a', parts[0])
self.assertEqual('b', parts[1])
self.assertEqual('100', parts[2])
self.assertEqual(100, parts[2])
def test_parse_datastore_info_and_weight_default_weight(self):
datastore = 'a:b'