'Removes host from the aggregate.'

@wrap_exception()
def remove_host_from_aggregate(self, context, aggregate_id, host_name):

    aggregate_payload = {'aggregate_id': aggregate_id, 'host_name': host_name}
    compute_utils.notify_about_aggregate_update(context, 'removehost.start', aggregate_payload)
    mapping = objects.HostMapping.get_by_host(context, host_name)
    nova_context.set_target_cell(context, mapping.cell_mapping)
    objects.Service.get_by_compute_host(context, host_name)
    aggregate = objects.Aggregate.get_by_id(context, aggregate_id)
    aggregate.delete_host(host_name)
    self.scheduler_client.update_aggregates(context, [aggregate])
    self._update_az_cache_for_host(context, host_name, aggregate.metadata)
    self.compute_rpcapi.remove_aggregate_host(context, aggregate=aggregate, host_param=host_name, host=host_name)
    compute_utils.notify_about_aggregate_update(context, 'removehost.end', aggregate_payload)
    return aggregate
