Merge "attach_volume first check for existing attachment"
This commit is contained in:
commit
7b304ce4aa
|
@ -279,6 +279,12 @@ class VolumeAttachDetachTestCase(base.BaseVolumeTestCase):
|
|||
instance_uuid, None,
|
||||
mountpoint, 'ro',
|
||||
volume=volume_passed)
|
||||
attachment2 = self.volume.attach_volume(self.user_context,
|
||||
volume_id,
|
||||
instance_uuid, None,
|
||||
mountpoint, 'ro',
|
||||
volume=volume_passed)
|
||||
self.assertEqual(attachment.id, attachment2.id)
|
||||
vol = objects.Volume.get_by_id(self.context, volume_id)
|
||||
self.assertEqual("in-use", vol.status)
|
||||
self.assertEqual(fields.VolumeAttachStatus.ATTACHED,
|
||||
|
|
|
@ -1013,11 +1013,6 @@ class VolumeManager(manager.CleanableManager,
|
|||
raise exception.InvalidVolume(
|
||||
reason=_("being attached by different mode"))
|
||||
|
||||
if (volume.status == 'in-use' and not volume.multiattach
|
||||
and not volume.migration_status):
|
||||
raise exception.InvalidVolume(
|
||||
reason=_("volume is already attached"))
|
||||
|
||||
host_name_sanitized = utils.sanitize_hostname(
|
||||
host_name) if host_name else None
|
||||
if instance_uuid:
|
||||
|
@ -1036,6 +1031,11 @@ class VolumeManager(manager.CleanableManager,
|
|||
volume.save()
|
||||
return attachment
|
||||
|
||||
if (volume.status == 'in-use' and not volume.multiattach
|
||||
and not volume.migration_status):
|
||||
raise exception.InvalidVolume(
|
||||
reason=_("volume is already attached"))
|
||||
|
||||
self._notify_about_volume_usage(context, volume,
|
||||
"attach.start")
|
||||
|
||||
|
|
Loading…
Reference in New Issue