locate_agent(recp): Return (host, port, should_redirect) tuple.

def locate_agent(self, recp):
        '''locate_agent(recp): Return (host, port, should_redirect) tuple.
        '''
        if recipient.IRecipient.providedBy(recp):
            agent_id = recp.key
        else:
            agent_id = recp
        found = yield self.find_agent(agent_id)
        if isinstance(found, agency.AgencyAgent):
            host = self.get_hostname()
            port = self.gateway_port
            defer.returnValue((host, port, False, ))
        elif isinstance(found, broker.AgentReference):
            host = self.get_hostname()
            port = yield found.reference.callRemote('get_gateway_port')
            defer.returnValue((host, port, True, ))
        else: # None
            # lazy import not to load descriptor before feat is loaded
            from feat.utils import locate
            db = self._database.get_connection()
            host = yield locate.locate(db, agent_id)
            port = self.config.gateway.port
            if host is None or (self._broker.is_master() and
                                host == self.get_hostname()):
                # Second condition reflects the situation when the agent
                # has its descriptor in the database but is not running.
                # It breaks the infinite redirect loop.
                defer.returnValue(None)
            else:
                defer.returnValue((host, port, True, ))