'Detach volume from instance.
This method is separated to make it easier for cells version
to override.'

def _detach_volume(self, context, instance, volume):

    try:
        self.volume_api.begin_detaching(context, volume['id'])
    except exception.InvalidInput as exc:
        raise exception.InvalidVolume(reason=exc.format_message())
    attachments = volume.get('attachments', {})
    attachment_id = None
    if (attachments and (instance.uuid in attachments)):
        attachment_id = attachments[instance.uuid]['attachment_id']
    self.compute_rpcapi.detach_volume(context, instance=instance, volume_id=volume['id'], attachment_id=attachment_id)
