]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add support for customized cluster name
authorZhiteng Huang <zhithuang@ebaysf.com>
Thu, 16 Apr 2015 14:47:31 +0000 (22:47 +0800)
committerZhiteng Huang <zhithuang@ebaysf.com>
Thu, 16 Apr 2015 14:47:31 +0000 (22:47 +0800)
Current RBD driver assumes ceph cluster name to be 'ceph', for
cluster has a different name, the driver won't be able to connect
to the cluster.  This change add a new config option
'rbd_cluster_name' to address this issue.

DocImpact

Change-Id: I02ae1a255fd613fce291cc7ddf90cfd9175255a8
Closes-bug: #1444855

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

index fcd3bcc6303a4174a1ea1e2c89f7d38a318b8206..2cf0138c9a0a524e3d19c54615e83e190ec48750 100644 (file)
@@ -134,6 +134,7 @@ class RBDTestCase(test.TestCase):
         self.cfg = mock.Mock(spec=conf.Configuration)
         self.cfg.volume_tmp_dir = None
         self.cfg.image_conversion_dir = None
+        self.cfg.rbd_cluster_name = 'nondefault'
         self.cfg.rbd_pool = 'rbd'
         self.cfg.rbd_ceph_conf = None
         self.cfg.rbd_secret_uuid = None
index 7dae2ec2044465c6ce0206577a1ec7d868c5411c..a78921d3ab36ae0f7cbfaf131405ed02a88755c4 100644 (file)
@@ -44,6 +44,9 @@ except ImportError:
 LOG = logging.getLogger(__name__)
 
 rbd_opts = [
+    cfg.StrOpt('rbd_cluster_name',
+               default='ceph',
+               help='The name of ceph cluster'),
     cfg.StrOpt('rbd_pool',
                default='rbd',
                help='The RADOS pool where rbd volumes are stored'),
@@ -270,7 +273,8 @@ class RBDDriver(driver.VolumeDriver):
 
         # All string args used with librbd must be None or utf-8 otherwise
         # librbd will break.
-        for attr in ['rbd_user', 'rbd_ceph_conf', 'rbd_pool']:
+        for attr in ['rbd_cluster_name', 'rbd_user',
+                     'rbd_ceph_conf', 'rbd_pool']:
             val = getattr(self.configuration, attr)
             if val is not None:
                 setattr(self.configuration, attr, encodeutils.safe_encode(val))
@@ -299,8 +303,10 @@ class RBDDriver(driver.VolumeDriver):
         LOG.debug("opening connection to ceph cluster (timeout=%s)." %
                   (self.configuration.rados_connect_timeout))
 
-        client = self.rados.Rados(rados_id=self.configuration.rbd_user,
-                                  conffile=self.configuration.rbd_ceph_conf)
+        client = self.rados.Rados(
+            rados_id=self.configuration.rbd_user,
+            clustername=self.configuration.rbd_cluster_name,
+            conffile=self.configuration.rbd_ceph_conf)
         if pool is not None:
             pool = encodeutils.safe_encode(pool)
         else: