'Remove a compute host from an aggregate.'

def remove_from_aggregate(self, context, aggregate, host, slave_info=None):

    slave_info = (slave_info or dict())
    if (not pool_states.is_hv_pool(aggregate.metadata)):
        return
    invalid = {pool_states.CREATED: _('no    hosts    to    remove'), pool_states.CHANGING: _('setup    in    progress'), pool_states.DISMISSED: _('aggregate    deleted')}
    if (aggregate.metadata[pool_states.KEY] in invalid.keys()):
        raise exception.InvalidAggregateActionDelete(aggregate_id=aggregate.id, reason=invalid[aggregate.metadata[pool_states.KEY]])
    master_compute = aggregate.metadata['master_compute']
    if ((master_compute == CONF.host) and (master_compute != host)):
        host_uuid = aggregate.metadata[host]
        self._eject_slave(aggregate.id, slave_info.get('compute_uuid'), host_uuid)
        aggregate.update_metadata({host: None})
    elif (master_compute == host):
        if (len(aggregate.hosts) > 1):
            raise exception.InvalidAggregateActionDelete(aggregate_id=aggregate.id, reason=(_('Unable    to    eject    %s    from    the    pool;    pool    not    empty') % host))
        self._clear_pool(aggregate.id)
        aggregate.update_metadata({'master_compute': None, host: None})
    elif (master_compute and (master_compute != host)):
        slave_info = self._create_slave_info()
        self.compute_rpcapi.remove_aggregate_host(context, host, aggregate.id, master_compute, slave_info)
    else:
        raise exception.AggregateError(aggregate_id=aggregate.id, action='remove_from_aggregate', reason=(_('Unable    to    eject    %s    from    the    pool;    No    master    found') % host))
