]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
VMware: Fixed usage of volume instance_uuid
authorWalter A. Boring IV <walter.boring@hp.com>
Thu, 26 Mar 2015 05:09:59 +0000 (05:09 +0000)
committerVipin Balachandran <vbala@vmware.com>
Thu, 26 Mar 2015 10:56:21 +0000 (03:56 -0700)
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
cinder/volume/drivers/vmware/vmdk.py

index 2f7cf29295ee9d80a244bb9a243c9d1c4fc18dd9..9ad4333206643ebba648044888005610095eb5dc 100644 (file)
@@ -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')
index 0677c7729e40b06543cf4e5f7c300528d8ac32b8..29f951c8928d7b03db43b2f6227016df25663dbc 100644 (file)
@@ -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)