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


Python Network.get_host_id方法代碼示例

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


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

示例1: test_get_host_id_of_localhost

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
 def test_get_host_id_of_localhost(self):  # todo: this is an integration test -- move it to integration dir
     local_host_name = socket.gethostname()
     self.assertEqual(
         Network.get_host_id('localhost'),
         Network.get_host_id(local_host_name),
         'Host id of "localhost" is not the same as host id of "{}"'.format(local_host_name),
     )
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:9,代碼來源:test_network.py

示例2: test_get_host_id_of_localhost

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
 def test_get_host_id_of_localhost(self):
     local_host_name = socket.gethostname()
     self.assertEqual(
         Network.get_host_id('localhost'),
         Network.get_host_id(local_host_name),
         'Host id of "localhost" is not the same as host id of "{}"'.format(local_host_name),
     )
開發者ID:OspreyX,項目名稱:ClusterRunner,代碼行數:9,代碼來源:test_network.py

示例3: all_slaves_registered

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
 def all_slaves_registered():
     registered_slave_uids = set(
         [Network.get_host_id(x) for x in self._registered_slave_hostnames(slave_api_url, network)]
     )
     slaves_to_validate_uids = set(
         [Network.get_host_id(x) for x in slaves_to_validate]
     )
     return registered_slave_uids == slaves_to_validate_uids
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:10,代碼來源:deploy_subcommand.py

示例4: _non_registered_slaves

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
    def _non_registered_slaves(self, registered_slaves, slaves_to_validate):
        """
        Return list of slave hosts that have failed to register with the master service.

        :param slaves_to_validate: list of slave hostnames to check for
        :type slaves_to_validate: list[str]
        :return: list of slave hostnames that haven't registered with the master service yet
        :rtype: list[str]
        """
        registered_host_ids = [Network.get_host_id(slave) for slave in registered_slaves]

        slaves_to_validate_host_id_pairs = {
            Network.get_host_id(slave): slave
            for slave in slaves_to_validate
        }

        non_registered_slave_hosts = [
            slaves_to_validate_host_id_pairs[host_id] for host_id in slaves_to_validate_host_id_pairs
            if host_id not in registered_host_ids
        ]

        return non_registered_slave_hosts
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:24,代碼來源:deploy_subcommand.py

示例5: test_get_host_id_returns_ip_of_the_host

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
 def test_get_host_id_returns_ip_of_the_host(self):
     self._patch_socket_gethostbyname(side_effect=[self._ip])
     self.assertEqual(Network.get_host_id(self._hostname), self._ip)
     self._mock_get_host_by_name.assert_called_once_with(self._hostname)
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:6,代碼來源:test_network.py

示例6: test_get_host_id_returns_none_if_gaierror

# 需要導入模塊: from app.util.network import Network [as 別名]
# 或者: from app.util.network.Network import get_host_id [as 別名]
 def test_get_host_id_returns_none_if_gaierror(self):
     self._patch_socket_gethostbyname(side_effect=socket.gaierror)
     self.assertIsNone(Network.get_host_id(self._hostname))
     self._mock_get_host_by_name.assert_called_once_with(self._hostname)
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:6,代碼來源:test_network.py


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