Add attribute 'name' to class RBDVolume.

If we create backup for volume  in-use, volume
driver will clone a temporary volume, and create
a snapshot based on the temporary volume, then
create backup for the snapshot. So, the src_name
passed to method _rbd_diff_transfer should be the
name of the temporary volume instead of the original
volume's name. In order to get this name, we need
add self.name to class os_brick.initiator.linuxrbd.
RBDVolume, that's because ceph provides rbd.so to
cinder, but we can't get volume name from rbd.Image
directly.

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: Ic2732e985b75ae710da3814c2d5b2253ced74534
Closes-Bug: #1663504
This commit is contained in:
Zhao Liqiang 2017-02-10 16:59:34 +08:00 committed by Ivan Kolodyazhny
parent 10a5e3f5d5
commit ccafe98b97
2 changed files with 12 additions and 0 deletions

View File

@ -110,6 +110,11 @@ class RBDVolume(object):
client.disconnect()
raise
# Ceph provides rbd.so to cinder, but we can't
# get volume name from rbd.Image, so, we record
# name here, so other modules can easily get
# volume name.
self.name = name
self.client = client
def close(self):

View File

@ -156,3 +156,10 @@ class RBDVolumeIOWrapperTestCase(base.TestCase):
linuxrbd.RBDImageMetadata(rbd_volume, 'pool', 'user', None))
rbd_handle.close()
self.assertEqual(1, rbd_disconnect.call_count)
class RBDVolumeTestCase(base.TestCase):
def test_name_attribute(self):
mock_client = mock.Mock()
rbd_volume = linuxrbd.RBDVolume(mock_client, 'volume')
self.assertEqual('volume', rbd_volume.name)