From de09563ce25743ae3debce961e99196caed19daa Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Sat, 20 Jun 2015 12:43:34 -0700 Subject: [PATCH] rbd: add volume_id to connection_info in initialize_connection Most other volume drivers have a 'volume_id' key in the connection_info['data'] dict returned from initialize_connection, this adds it to the rbd volume driver. This is part of a bigger effort to standardize the connection_info dict so that consumers like Nova can rely on a common set of keys when processing connection_info. Change-Id: I7aed56a93c4cc3be5e0e49da6ddc1f009fed3c18 --- cinder/tests/unit/test_rbd.py | 7 +++++-- cinder/volume/drivers/rbd.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cinder/tests/unit/test_rbd.py b/cinder/tests/unit/test_rbd.py index b56758fa7..16614b5f4 100644 --- a/cinder/tests/unit/test_rbd.py +++ b/cinder/tests/unit/test_rbd.py @@ -730,6 +730,7 @@ class RBDTestCase(test.TestCase): mock_get_mon_addrs: mock_get_mon_addrs.return_value = (hosts, ports) + volume_id = '0a83f0a3-ef6e-47b6-a8aa-20436bc9ed01' expected = { 'driver_volume_type': 'rbd', 'data': { @@ -740,9 +741,11 @@ class RBDTestCase(test.TestCase): 'auth_enabled': False, 'auth_username': None, 'secret_type': 'ceph', - 'secret_uuid': None, } + 'secret_uuid': None, + 'volume_id': volume_id + } } - volume = dict(name=self.volume_name) + volume = dict(name=self.volume_name, id=volume_id) actual = self.driver.initialize_connection(volume, None) self.assertDictMatch(expected, actual) self.assertTrue(mock_get_mon_addrs.called) diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 346888f8e..ed665751b 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -791,7 +791,9 @@ class RBDDriver(driver.RetypeVD, driver.TransferVD, driver.ExtendVD, 'auth_enabled': (self.configuration.rbd_user is not None), 'auth_username': self.configuration.rbd_user, 'secret_type': 'ceph', - 'secret_uuid': self.configuration.rbd_secret_uuid, } + 'secret_uuid': self.configuration.rbd_secret_uuid, + 'volume_id': volume['id'], + } } LOG.debug('connection data: %s', data) return data -- 2.45.2