From: Zhiteng Huang Date: Thu, 16 Apr 2015 14:47:31 +0000 (+0800) Subject: Add support for customized cluster name X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6db57c53a1363ff267e58f88b0937cd5d0e842c4;p=openstack-build%2Fcinder-build.git Add support for customized cluster name 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 --- diff --git a/cinder/tests/test_rbd.py b/cinder/tests/test_rbd.py index fcd3bcc63..2cf0138c9 100644 --- a/cinder/tests/test_rbd.py +++ b/cinder/tests/test_rbd.py @@ -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 diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 7dae2ec20..a78921d3a 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -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: