image_meta['disk_format'] = 'novmdk'
volume = FakeObject()
volume['name'] = 'vol-name'
- volume['status'] = 'available'
+ volume['instance_uuid'] = None
+ volume['attached_host'] = None
m.ReplayAll()
self.assertRaises(exception.ImageUnacceptable,
"""Test copy_volume_to_image when volume is attached."""
m = self.mox
volume = FakeObject()
- volume['status'] = 'in-use'
+ volume['instance_uuid'] = 'my_uuid'
m.ReplayAll()
self.assertRaises(exception.InvalidVolume,
volume = FakeObject()
volume['name'] = vol_name
volume['project_id'] = project_id
- volume['status'] = 'available'
+ volume['instance_uuid'] = None
+ volume['attached_host'] = None
# volumeops.get_backing
backing = FakeMor("VirtualMachine", "my_vm")
m.StubOutWithMock(self._volumeops, 'get_backing')
4. Delete the coalesced .vmdk and -flat.vmdk created.
"""
- if volume['status'] != 'available':
- msg = _("Upload to glance of volume not supported in state: %s.")
- LOG.error(msg % volume['status'])
- raise exception.InvalidVolume(msg % volume['status'])
+ if volume['instance_uuid'] or volume['attached_host']:
+ msg = _("Upload to glance of attached volume is not supported.")
+ LOG.error(msg)
+ raise exception.InvalidVolume(msg)
LOG.debug(_("Copy Volume: %s to new image.") % volume['name'])
VMwareEsxVmdkDriver._validate_disk_format(image_meta['disk_format'])