From 5fdada85969ca770db60892e2c4f67d917efa0d5 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Thu, 26 Mar 2015 05:09:59 +0000 Subject: [PATCH] VMware: Fixed usage of volume instance_uuid instance_uuid and attached_host no longer exist in the volume object. They have been moved into the volume_attachment list attachments. This patch now tests for non-empty volume_attachment list instead of testing the existence of a non None value of instance_uuid. Change-Id: I04c46dc49849fb1e0abf955dcc6d7ec1ce5e57a5 Closes-Bug: 1436603 --- cinder/tests/test_vmware_vmdk.py | 8 +++----- cinder/volume/drivers/vmware/vmdk.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cinder/tests/test_vmware_vmdk.py b/cinder/tests/test_vmware_vmdk.py index 2f7cf2929..9ad433320 100644 --- a/cinder/tests/test_vmware_vmdk.py +++ b/cinder/tests/test_vmware_vmdk.py @@ -1125,8 +1125,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): image_meta['disk_format'] = 'novmdk' volume = FakeObject() volume['name'] = 'vol-name' - volume['instance_uuid'] = None - volume['attached_host'] = None + volume['volume_attachment'] = None m.ReplayAll() self.assertRaises(cinder_exceptions.ImageUnacceptable, @@ -1140,7 +1139,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): """Test copy_volume_to_image when volume is attached.""" m = self.mox volume = FakeObject() - volume['instance_uuid'] = 'my_uuid' + volume['volume_attachment'] = [mock.sentinel.volume_attachment] m.ReplayAll() self.assertRaises(cinder_exceptions.InvalidVolume, @@ -1174,8 +1173,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): size = size_gb * units.Gi volume['size'] = size_gb volume['project_id'] = project_id - volume['instance_uuid'] = None - volume['attached_host'] = None + volume['volume_attachment'] = None # volumeops.get_backing backing = FakeMor("VirtualMachine", "my_vm") m.StubOutWithMock(self._volumeops, 'get_backing') diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 0677c7729..29f951c89 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -1309,7 +1309,8 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver): """ # if volume is attached raise exception - if volume['instance_uuid'] or volume['attached_host']: + if (volume['volume_attachment'] and + len(volume['volume_attachment']) > 0): msg = _("Upload to glance of attached volume is not supported.") LOG.error(msg) raise exception.InvalidVolume(msg) -- 2.45.2