Empty option value maybe cause Unity driver failed to initialize
If the value of list type option is empty, Unity driver may failed to initialize. Example: unity_io_ports= unity_storage_pool_names= Change-Id: Ib5850d984bfd3651d308f448993251e9ec5a9460 Closes-bug: #1775518
This commit is contained in:
parent
c308b281dc
commit
2ecfd6144b
|
@ -133,7 +133,8 @@ class UnityDriverTest(unittest.TestCase):
|
||||||
def test_default_initialize(self):
|
def test_default_initialize(self):
|
||||||
config = conf.Configuration(None)
|
config = conf.Configuration(None)
|
||||||
iscsi_driver = driver.UnityDriver(configuration=config)
|
iscsi_driver = driver.UnityDriver(configuration=config)
|
||||||
self.assertIsNone(config.unity_storage_pool_names)
|
self.assertListEqual([], config.unity_storage_pool_names)
|
||||||
|
self.assertListEqual([], config.unity_io_ports)
|
||||||
self.assertTrue(config.san_thin_provision)
|
self.assertTrue(config.san_thin_provision)
|
||||||
self.assertEqual('', config.san_ip)
|
self.assertEqual('', config.san_ip)
|
||||||
self.assertEqual('admin', config.san_login)
|
self.assertEqual('admin', config.san_login)
|
||||||
|
|
|
@ -258,3 +258,24 @@ class UnityUtilsTest(unittest.TestCase):
|
||||||
ret = utils.get_backend_qos_specs(volume)
|
ret = utils.get_backend_qos_specs(volume)
|
||||||
expected = {'maxBWS': 2, 'id': 'max_2_mbps', 'maxIOPS': None}
|
expected = {'maxBWS': 2, 'id': 'max_2_mbps', 'maxIOPS': None}
|
||||||
self.assertEqual(expected, ret)
|
self.assertEqual(expected, ret)
|
||||||
|
|
||||||
|
def test_remove_empty(self):
|
||||||
|
option = mock.Mock()
|
||||||
|
value_list = [' pool1', 'pool2 ', ' pool3 ']
|
||||||
|
ret = utils.remove_empty(option, value_list)
|
||||||
|
expected = ['pool1', 'pool2', 'pool3']
|
||||||
|
self.assertListEqual(expected, ret)
|
||||||
|
|
||||||
|
def test_remove_empty_none(self):
|
||||||
|
option = mock.Mock()
|
||||||
|
value_list = None
|
||||||
|
ret = utils.remove_empty(option, value_list)
|
||||||
|
expected = None
|
||||||
|
self.assertEqual(expected, ret)
|
||||||
|
|
||||||
|
def test_remove_empty_empty_list(self):
|
||||||
|
option = mock.Mock()
|
||||||
|
value_list = []
|
||||||
|
ret = utils.remove_empty(option, value_list)
|
||||||
|
expected = None
|
||||||
|
self.assertEqual(expected, ret)
|
||||||
|
|
|
@ -31,11 +31,11 @@ CONF = cfg.CONF
|
||||||
|
|
||||||
UNITY_OPTS = [
|
UNITY_OPTS = [
|
||||||
cfg.ListOpt('unity_storage_pool_names',
|
cfg.ListOpt('unity_storage_pool_names',
|
||||||
default=None,
|
default=[],
|
||||||
help='A comma-separated list of storage pool names to be '
|
help='A comma-separated list of storage pool names to be '
|
||||||
'used.'),
|
'used.'),
|
||||||
cfg.ListOpt('unity_io_ports',
|
cfg.ListOpt('unity_io_ports',
|
||||||
default=None,
|
default=[],
|
||||||
help='A comma-separated list of iSCSI or FC ports to be used. '
|
help='A comma-separated list of iSCSI or FC ports to be used. '
|
||||||
'Each port can be Unix-style glob expressions.'),
|
'Each port can be Unix-style glob expressions.'),
|
||||||
cfg.BoolOpt('remove_empty_host',
|
cfg.BoolOpt('remove_empty_host',
|
||||||
|
|
|
@ -273,12 +273,13 @@ def get_backend_qos_specs(volume):
|
||||||
|
|
||||||
|
|
||||||
def remove_empty(option, value_list):
|
def remove_empty(option, value_list):
|
||||||
if value_list is not None:
|
if value_list:
|
||||||
value_list = list(filter(None, map(str.strip, value_list)))
|
value_list = list(filter(None, map(str.strip, value_list)))
|
||||||
if not value_list:
|
if not value_list:
|
||||||
raise exception.InvalidConfigurationValue(option=option,
|
raise exception.InvalidConfigurationValue(option=option,
|
||||||
value=value_list)
|
value=value_list)
|
||||||
return value_list
|
return value_list
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def match_any(full, patterns):
|
def match_any(full, patterns):
|
||||||
|
|
Loading…
Reference in New Issue