Merge "Empty option value maybe cause Unity driver failed to initialize" into stable/queens

This commit is contained in:
Zuul 2018-06-12 19:22:28 +00:00 committed by Gerrit Code Review
commit 24782fa855
5 changed files with 38 additions and 6 deletions

View File

@ -133,7 +133,8 @@ class UnityDriverTest(unittest.TestCase):
def test_default_initialize(self):
config = conf.Configuration(None)
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.assertEqual('', config.san_ip)
self.assertEqual('admin', config.san_login)

View File

@ -258,3 +258,24 @@ class UnityUtilsTest(unittest.TestCase):
ret = utils.get_backend_qos_specs(volume)
expected = {'maxBWS': 2, 'id': 'max_2_mbps', 'maxIOPS': None}
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)

View File

@ -31,11 +31,11 @@ CONF = cfg.CONF
UNITY_OPTS = [
cfg.ListOpt('unity_storage_pool_names',
default=None,
default=[],
help='A comma-separated list of storage pool names to be '
'used.'),
cfg.ListOpt('unity_io_ports',
default=None,
default=[],
help='A comma-separated list of iSCSI or FC ports to be used. '
'Each port can be Unix-style glob expressions.'),
cfg.BoolOpt('remove_empty_host',
@ -64,9 +64,12 @@ class UnityDriver(driver.ManageableVD,
3.1.2 - Fixes bug 1759175 to detach the lun correctly when auto zone
was enabled and the lun was the last one attached to the host.
3.1.3 - Support remove empty host
3.1.4 - Fixes bug 1775518 to make sure driver succeed to initialize
even though the value of unity_io_ports and
unity_storage_pool_names are empty
"""
VERSION = '03.01.03'
VERSION = '03.01.04'
VENDOR = 'Dell EMC'
# ThirdPartySystems wiki page
CI_WIKI_NAME = "EMC_UNITY_CI"

View File

@ -273,12 +273,13 @@ def get_backend_qos_specs(volume):
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)))
if not value_list:
raise exception.InvalidConfigurationValue(option=option,
value=value_list)
return value_list
return value_list
return None
def match_any(full, patterns):

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Dell EMC Unity: Fixes bug 1775518 to make sure driver succeed
to initialize even though the value of unity_io_ports and
unity_storage_pool_names are empty