'Removes a host from the specified aggregate.'

@extensions.expected_errors((404, 409))
@wsgi.action('remove_host')
@validation.schema(aggregates.remove_host)
def _remove_host(self, req, id, body):

    host = body['remove_host']['host']
    context = _get_context(req)
    context.can((aggr_policies.POLICY_ROOT % 'remove_host'))
    try:
        aggregate = self.api.remove_host_from_aggregate(context, id, host)
    except (exception.AggregateNotFound, exception.AggregateHostNotFound, exception.HostMappingNotFound, exception.ComputeHostNotFound):
        msg = (_('Cannot    remove    host    %(host)s    in    aggregate    %(id)s') % {'host': host, 'id': id})
        raise exc.HTTPNotFound(explanation=msg)
    except exception.InvalidAggregateAction:
        msg = (_('Cannot    remove    host    %(host)s    in    aggregate    %(id)s') % {'host': host, 'id': id})
        raise exc.HTTPConflict(explanation=msg)
    return self._marshall_aggregate(req, aggregate)
