]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check min config requirements for rbd driver
authorYuriy Nesenenko <ynesenenko@mirantis.com>
Thu, 17 Dec 2015 09:51:24 +0000 (11:51 +0200)
committerYuriy Nesenenko <ynesenenko@mirantis.com>
Wed, 23 Dec 2015 15:51:07 +0000 (17:51 +0200)
The RBD driver should check that required configs are set on startup
and fail to start if they are not.

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: I73c9b65f6351b46210de2da29fe73df00d839b52
Closes-Bug: 1276626

cinder/tests/unit/test_rbd.py
cinder/volume/drivers/rbd.py

index a163dfb352b16fc0325701801dba4a98024bd800..c8343ea157aa55a2757ede194ec4895c3eee7eb0 100644 (file)
@@ -15,7 +15,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-
+import ddt
 import math
 import os
 import tempfile
@@ -121,6 +121,7 @@ CEPH_MON_DUMP = """dumped monmap epoch 1
 """
 
 
+@ddt.ddt
 class RBDTestCase(test.TestCase):
 
     def setUp(self):
@@ -153,6 +154,17 @@ class RBDTestCase(test.TestCase):
         self.snapshot = dict(volume_name=self.volume_name,
                              name=self.snapshot_name)
 
+    @ddt.data({'cluster_name': None, 'pool_name': 'rbd'},
+              {'cluster_name': 'volumes', 'pool_name': None})
+    @ddt.unpack
+    def test_min_config(self, cluster_name, pool_name):
+        self.cfg.rbd_cluster_name = cluster_name
+        self.cfg.rbd_pool = pool_name
+
+        with mock.patch('cinder.volume.drivers.rbd.rados'):
+            self.assertRaises(exception.InvalidConfigurationValue,
+                              self.driver.check_for_setup_error)
+
     @common_mocks
     def test_create_volume(self):
         client = self.mock_client.return_value
index 6dc66aca07de95cee43b68232ba27720b672720d..d0d25219e8d1bebeebf102646f57c86136cc44ff 100644 (file)
@@ -290,6 +290,11 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
             msg = _('rados and rbd python libraries not found')
             raise exception.VolumeBackendAPIException(data=msg)
 
+        for attr in ['rbd_cluster_name', 'rbd_pool']:
+            val = getattr(self.configuration, attr)
+            if not val:
+                raise exception.InvalidConfigurationValue(option=attr,
+                                                          value=val)
         # NOTE: Checking connection to ceph
         # RADOSClient __init__ method invokes _connect_to_rados
         # so no need to check for self.rados.Error here.