def check_detach(self, context, volume, instance=None): if volume['status'] == "available": msg = "already detached" raise exception.InvalidVolume(reason=msg) if volume['attach_status'] == 'detached': msg = "Volume must be attached in order to detach." raise exception.InvalidVolume(reason=msg) if instance and not volume.get('attachments', {}).get(instance.uuid): raise exception.VolumeUnattached(volume_id=volume['id'])
def check_detach(self, context, volume, instance=None): # TODO(vish): abstract status checking? if volume['status'] == "available": msg = _("volume %s already detached") % volume['id'] raise exception.InvalidVolume(reason=msg) if volume['attach_status'] == 'detached': msg = _("Volume must be attached in order to detach.") raise exception.InvalidVolume(reason=msg) # NOTE(ildikov):Preparation for multiattach support, when a volume # can be attached to multiple hosts and/or instances, # so just check the attachment specific to this instance if instance is not None and instance.uuid not in volume['attachments']: # TODO(ildikov): change it to a better exception, when enable # multi-attach. raise exception.VolumeUnattached(volume_id=volume['id'])
def fake_swap_volume_unattached_volume(self, context, instance, volume_id, device): raise exception.VolumeUnattached(reason='', volume_id=volume_id)