Merge "VMware: Fix inventory folder after volume transfer"

This commit is contained in:
Jenkins 2017-01-04 14:41:16 +00:00 committed by Gerrit Code Review
commit 2275128d8b
2 changed files with 32 additions and 0 deletions

View File

@ -2840,6 +2840,30 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
volume, new_size)
extend_backing.assert_called_once_with(backing, new_size)
@mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, '_get_volume_group_folder')
def test_accept_transfer(self, get_volume_group_folder, vops):
backing = mock.sentinel.backing
vops.get_backing.return_value = backing
dc = mock.sentinel.dc
vops.get_dc.return_value = dc
new_folder = mock.sentinel.new_folder
get_volume_group_folder.return_value = new_folder
context = mock.sentinel.context
volume = self._create_volume_obj()
new_project = mock.sentinel.new_project
self._driver.accept_transfer(context, volume, mock.sentinel.new_user,
new_project)
vops.get_backing.assert_called_once_with(volume.name)
vops.get_dc.assert_called_once_with(backing)
get_volume_group_folder.assert_called_once_with(dc, new_project)
vops.move_backing_to_folder.assert_called_once_with(backing,
new_folder)
class ImageDiskTypeTest(test.TestCase):
"""Unit tests for ImageDiskType."""

View File

@ -2123,3 +2123,11 @@ class VMwareVcVmdkDriver(driver.VolumeDriver):
:param src_vref: Source Volume object
"""
self._create_cloned_volume(volume, src_vref)
def accept_transfer(self, context, volume, new_user, new_project):
"""Accept the transfer of a volume for a new user/project."""
backing = self.volumeops.get_backing(volume.name)
if backing:
dc = self.volumeops.get_dc(backing)
new_folder = self._get_volume_group_folder(dc, new_project)
self.volumeops.move_backing_to_folder(backing, new_folder)