コード例 #1
0
ファイル: test_utils_locate.py プロジェクト: kowalski/feat
 def testLocating(self):
     host1 = yield locate(self.connection, self.host1.doc_id)
     self.assertEqual('host1', host1)
     host1 = yield locate(self.connection, self.agent1.doc_id)
     self.assertEqual('host1', host1)
     none = yield locate(self.connection, self.agent2.doc_id)
     self.assertIs(None, none)
コード例 #2
0
ファイル: agency.py プロジェクト: zaheerm/feat
 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:
             defer.returnValue(None)
         else:
             defer.returnValue((host, port, True, ))
コード例 #3
0
ファイル: agency.py プロジェクト: f3at/feat
    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))
コード例 #4
0
ファイル: api.py プロジェクト: f3at/feat
    def locate_agent(self, agent_id):
        db = self.db()
        agency = self.source

        medium = agency.get_agent(agent_id)
        if medium is not None:
            defer.returnValue(medium.get_agent())

        host = yield locate.locate(db, agent_id)

        if host is None:
            return
        port = self.source.config['gateway']['port']
        res = reference.Absolute((host, port), "apps", "dns", "servers",
                                 agent_id)
        defer.returnValue(res)
コード例 #5
0
ファイル: api.py プロジェクト: f3at/feat
    def _locate_agent(self, name):
        db = self.db()
        view = yield db.query_view(DnsZones, key=name)
        if not view:
            return
        agent_id = view[0].agent_id

        agency = self.source

        medium = agency.get_agent(agent_id)
        if medium is not None:
            defer.returnValue(medium.get_agent())

        host = yield locate.locate(db, agent_id)

        if host is None:
            return
        port = self.source.config['gateway']['port']
        res = reference.Absolute((host, port), "apps", "dns", "entries")
        defer.returnValue(res)
コード例 #6
0
ファイル: agency.py プロジェクト: kowalski/feat
 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, pb.RemoteReference):
         host = self.get_hostname()
         port = yield found.callRemote('get_gateway_port')
         defer.returnValue((host, port, True, ))
     else: # None
         db = self._database.get_connection()
         host = yield locate.locate(db, agent_id)
         port = self.config["gateway"]["port"]
         if host is None:
             defer.returnValue(None)
         else:
             defer.returnValue((host, port, True, ))