From ce575378da90ee3772438095b81a004ed7553102 Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Sat, 22 Aug 2015 06:28:32 -0400 Subject: [PATCH] Check sio_storage_pools in check_for_setup_error The ScaleIO driver fails to load if sio_storage_pools is not specified in cinder.conf. This patch checks it in check_for_setup_error and also check it in __init__. Change-Id: I0fed70848ad2ecf3899b07058fabfa68df07edbd Closes-Bug: #1497413 --- .../unit/volume/drivers/emc/scaleio/test_misc.py | 6 ++++++ cinder/volume/drivers/emc/scaleio.py | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/emc/scaleio/test_misc.py b/cinder/tests/unit/volume/drivers/emc/scaleio/test_misc.py index eea2c2da0..e7e20a474 100644 --- a/cinder/tests/unit/volume/drivers/emc/scaleio/test_misc.py +++ b/cinder/tests/unit/volume/drivers/emc/scaleio/test_misc.py @@ -84,6 +84,12 @@ class TestMisc(scaleio.TestScaleIODriver): self.assertRaises(exception.InvalidInput, self.driver.check_for_setup_error) + def test_no_storage_pools(self): + """No storage pools.""" + self.driver.storage_pools = None + self.assertRaises(exception.InvalidInput, + self.driver.check_for_setup_error) + def test_volume_size_round_true(self): self.driver._check_volume_size(1) diff --git a/cinder/volume/drivers/emc/scaleio.py b/cinder/volume/drivers/emc/scaleio.py index 27a572e89..c74d3951e 100644 --- a/cinder/volume/drivers/emc/scaleio.py +++ b/cinder/volume/drivers/emc/scaleio.py @@ -122,8 +122,13 @@ class ScaleIODriver(driver.VolumeDriver): 'user': self.server_username, 'verify_cert': self.verify_server_certificate}) - self.storage_pools = [e.strip() for e in - self.configuration.sio_storage_pools.split(',')] + self.storage_pools = None + if self.configuration.sio_storage_pools: + self.storage_pools = [ + e.strip() for e in + self.configuration.sio_storage_pools.split(',') + ] + self.storage_pool_name = self.configuration.sio_storage_pool_name self.storage_pool_id = self.configuration.sio_storage_pool_id if self.storage_pool_name is None and self.storage_pool_id is None: @@ -205,6 +210,12 @@ class ScaleIODriver(driver.VolumeDriver): msg = _("Must specify storage pool name or id.") raise exception.InvalidInput(reason=msg) + if not self.storage_pools: + msg = _( + "Must specify storage pools. Option: sio_storage_pools." + ) + raise exception.InvalidInput(reason=msg) + def _find_storage_pool_id_from_storage_type(self, storage_type): # Default to what was configured in configuration file if not defined. return storage_type.get(STORAGE_POOL_ID, -- 2.45.2