@wrap_check_policy
def delete(self, context, volume):
    volume_id = volume['id']
    if (not volume['host']):
        self.db.volume_destroy(context, volume_id)
        return
    if (volume['status'] not in ['available', 'error']):
        msg = _('Volume status must be available or error')
        raise exception.InvalidVolume(reason=msg)
    snapshots = self.db.snapshot_get_all_for_volume(context, volume_id)
    if len(snapshots):
        msg = (_('Volume still has %d dependent snapshots') % len(snapshots))
        raise exception.InvalidVolume(reason=msg)
    now = timeutils.utcnow()
    self.db.volume_update(context, volume_id, {'status': 'deleting', 'terminated_at': now})
    host = volume['host']
    rpc.cast(context, rpc.queue_get_for(context, FLAGS.volume_topic, host), {'method': 'delete_volume', 'args': {'volume_id': volume_id}})
@wrap_check_policy
def delete(self, context, volume):
    volume_id = volume['id']
    if (not volume['host']):
        self.db.volume_destroy(context, volume_id)
        return
    if (volume['status'] not in ['available', 'error']):
        msg = _('Volume status must be available or error')
        raise exception.InvalidVolume(reason=msg)
    snapshots = self.db.snapshot_get_all_for_volume(context, volume_id)
    if len(snapshots):
        msg = (_('Volume still has %d dependent snapshots') % len(snapshots))
        raise exception.InvalidVolume(reason=msg)
    now = timeutils.utcnow()
    self.db.volume_update(context, volume_id, {'status': 'deleting', 'terminated_at': now})
    host = volume['host']
    rpc.cast(context, rpc.queue_get_for(context, FLAGS.volume_topic, host), {'method': 'delete_volume', 'args': {'volume_id': volume_id}})