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
This commit is contained in:
Walter A. Boring IV 2015-03-26 05:09:59 +00:00 committed by Vipin Balachandran
parent e759f11828
commit 5fdada8596
2 changed files with 5 additions and 6 deletions

View 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')

View 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)