當前位置: 首頁>>代碼示例>>Python>>正文


Python PsDashRunner.get_nodes方法代碼示例

本文整理匯總了Python中psdash.run.PsDashRunner.get_nodes方法的典型用法代碼示例。如果您正苦於以下問題:Python PsDashRunner.get_nodes方法的具體用法?Python PsDashRunner.get_nodes怎麽用?Python PsDashRunner.get_nodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在psdash.run.PsDashRunner的用法示例。


在下文中一共展示了PsDashRunner.get_nodes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_nodes_from_config

# 需要導入模塊: from psdash.run import PsDashRunner [as 別名]
# 或者: from psdash.run.PsDashRunner import get_nodes [as 別名]
 def test_nodes_from_config(self):
     config = {
         'PSDASH_NODES': [
             {
                 'name': 'test-node',
                 'host': 'remotehost.org',
                 'port': 5000
             }
         ]
     }
     r = PsDashRunner(config)
     self.assertEqual(len(r.get_nodes()), 2)
     self.assertIn('remotehost.org:5000', r.get_nodes())
     self.assertEqual(r.get_nodes()['remotehost.org:5000'].name, 'test-node')
     self.assertEqual(r.get_nodes()['remotehost.org:5000'].host, 'remotehost.org')
     self.assertEqual(r.get_nodes()['remotehost.org:5000'].port, 5000)
開發者ID:ArcherSys,項目名稱:psdash,代碼行數:18,代碼來源:test_run.py

示例2: test_register_agent_to_auth_protected_host

# 需要導入模塊: from psdash.run import PsDashRunner [as 別名]
# 或者: from psdash.run.PsDashRunner import get_nodes [as 別名]
    def test_register_agent_to_auth_protected_host(self):
        r = PsDashRunner({
            'PSDASH_AUTH_USERNAME': 'user',
            'PSDASH_AUTH_PASSWORD': 'pass'
        })
        agent = PsDashRunner({
            'PSDASH_AGENT': True,
            'PSDASH_PORT': 5001,
            'PSDASH_REGISTER_TO': 'http://localhost:5000',
            'PSDASH_AUTH_USERNAME': 'user',
            'PSDASH_AUTH_PASSWORD': 'pass'
        })
        jobs = []
        jobs.append(gevent.spawn(r.run))
        gevent.sleep(0.3)
        jobs.append(gevent.spawn(agent.run))
        gevent.sleep(0.3)

        self.assertIn('127.0.0.1:5001', r.get_nodes())
        self.assertEquals(r.get_node('127.0.0.1:5001').name, socket.gethostname())
        self.assertEquals(r.get_node('127.0.0.1:5001').port, 5001)

        r.server.close()
        agent.server.close()
        gevent.killall(jobs)
開發者ID:ArcherSys,項目名稱:psdash,代碼行數:27,代碼來源:test_run.py

示例3: test_register_agent_without_name_defaults_to_hostname

# 需要導入模塊: from psdash.run import PsDashRunner [as 別名]
# 或者: from psdash.run.PsDashRunner import get_nodes [as 別名]
    def test_register_agent_without_name_defaults_to_hostname(self):
        agent_options = {
            'PSDASH_AGENT': True,
            'PSDASH_PORT': 5001,
            'PSDASH_REGISTER_TO': 'http://localhost:5000'
        }
        r = PsDashRunner()
        agent = PsDashRunner(agent_options)
        jobs = []
        jobs.append(gevent.spawn(r.run))
        gevent.sleep(0.3)
        jobs.append(gevent.spawn(agent.run))
        gevent.sleep(0.3)

        self.assertIn('127.0.0.1:5001', r.get_nodes())
        self.assertEquals(r.get_node('127.0.0.1:5001').name, socket.gethostname())
        self.assertEquals(r.get_node('127.0.0.1:5001').port, 5001)

        r.server.close()
        agent.server.close()
        gevent.killall(jobs)
開發者ID:ArcherSys,項目名稱:psdash,代碼行數:23,代碼來源:test_run.py

示例4: test_register_agent

# 需要導入模塊: from psdash.run import PsDashRunner [as 別名]
# 或者: from psdash.run.PsDashRunner import get_nodes [as 別名]
    def test_register_agent(self):
        agent_options = {
            'PSDASH_AGENT': True,
            'PSDASH_PORT': 5001,
            'PSDASH_REGISTER_TO': 'localhost:5000',
            'PSDASH_REGISTER_AS': 'the_agent'
        }
        r = PsDashRunner()
        agent = PsDashRunner(agent_options)
        jobs = []
        jobs.append(gevent.spawn(r.run))
        gevent.sleep(0.2)
        jobs.append(gevent.spawn(agent.run))
        gevent.sleep(0.2)

        self.assertIn('127.0.0.1:5001', r.get_nodes())
        self.assertEquals(r.get_node('127.0.0.1:5001').name, 'the_agent')
        self.assertEquals(r.get_node('127.0.0.1:5001').port, 5001)

        r.server.close()
        agent.server.close()
        gevent.killall(jobs)
開發者ID:achun2080,項目名稱:psdash,代碼行數:24,代碼來源:test_run.py

示例5: test_get_all_nodes

# 需要導入模塊: from psdash.run import PsDashRunner [as 別名]
# 或者: from psdash.run.PsDashRunner import get_nodes [as 別名]
 def test_get_all_nodes(self):
     r = PsDashRunner()
     r.register_node('examplehost', 'example.org', 5000)
     self.assertEqual(len(r.get_nodes()), 2) # local + registered
開發者ID:ArcherSys,項目名稱:psdash,代碼行數:6,代碼來源:test_run.py


注:本文中的psdash.run.PsDashRunner.get_nodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。