当前位置: 首页>>代码示例>>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;未经允许,请勿转载。