当前位置: 首页>>代码示例>>Python>>正文


Python Host.find方法代码示例

本文整理汇总了Python中hm.model.host.Host.find方法的典型用法代码示例。如果您正苦于以下问题:Python Host.find方法的具体用法?Python Host.find怎么用?Python Host.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hm.model.host.Host的用法示例。


在下文中一共展示了Host.find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_storage_use_uri_conf

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_storage_use_uri_conf(self):
     conf = {
         "DBAAS_MONGODB_ENDPOINT": "mongodb://127.0.0.1:27017/some_other_db",
         "MONGO_URI": "mongodb://127.0.0.1:27017/ignored",
     }
     storage.MongoDBStorage(conf)._hosts_collection().remove()
     host_config = {
         "HOST_ID": "fake-id-x"
     }
     host_config.update(conf)
     h1 = Host.create('fake', 'my-group1', host_config)
     stor = h1.storage()
     self.assertEqual(stor.mongo_database, "some_other_db")
     self.assertEqual(stor.db.name, "some_other_db")
     h1.destroy()
     db_host = Host.find('fake-id-x')
     self.assertIsNone(db_host)
     conf = {
         "MONGO_URI": "mongodb://127.0.0.1:27017/now_used",
     }
     storage.MongoDBStorage(conf)._hosts_collection().remove()
     host_config = {
         "HOST_ID": "fake-id-x"
     }
     host_config.update(conf)
     h1 = Host.create('fake', 'my-group1', host_config)
     stor = h1.storage()
     self.assertEqual(stor.mongo_database, "now_used")
     self.assertEqual(stor.db.name, "now_used")
     h1.destroy()
     db_host = Host.find('fake-id-x')
     self.assertIsNone(db_host)
开发者ID:digideskio,项目名称:hm,代码行数:34,代码来源:test_host.py

示例2: test_destroy_ignores_manager_error

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_destroy_ignores_manager_error(self, log):
     host = Host.create('fake', 'my-group', {"HOST_ID": "explode"})
     self.assertEqual(host.id, "explode")
     host.destroy()
     self.assertEqual(log.call_args, call("Error trying to destroy host 'explode' "
                                          "in 'fake': failure to destroy"))
     db_host = Host.find('explode')
     self.assertIsNone(db_host)
开发者ID:digideskio,项目名称:hm,代码行数:10,代码来源:test_host.py

示例3: test_restore_log_and_raises_exception_on_error

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_restore_log_and_raises_exception_on_error(self, log):
     host = Host.create('fake', 'my-group', {"HOST_ID": "explode"})
     self.assertEqual(host.id, "explode")
     self.assertRaises(Exception, host.restore)
     self.assertEqual(log.call_args, call("Error trying to restore host 'explode' "
                                          "in 'fake': failure to restore"))
     db_host = Host.find('explode')
     self.assertEqual(db_host.id, "explode")
开发者ID:digideskio,项目名称:hm,代码行数:10,代码来源:test_host.py

示例4: test_storage_use_database_conf

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_storage_use_database_conf(self):
     storage.MongoDBStorage({"MONGO_DATABASE": "alternative_host_manager"})._hosts_collection().remove()
     h1 = Host.create('fake', 'my-group1', {
         "HOST_ID": "fake-id-x", "MONGO_DATABASE": "alternative_host_manager"
     })
     stor = h1.storage()
     self.assertEqual(stor.mongo_database, "alternative_host_manager")
     self.assertEqual(stor.db.name, "alternative_host_manager")
     h1.destroy()
     db_host = Host.find('fake-id-x')
     self.assertIsNone(db_host)
开发者ID:digideskio,项目名称:hm,代码行数:13,代码来源:test_host.py

示例5: test_create

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_create(self):
     conf = {"HOST_ID": "fake-id"}
     host = Host.create('fake', 'my-group', conf)
     self.assertEqual(host.id, "fake-id")
     self.assertEqual(host.dns_name, "fake-id.my-group.com")
     self.assertEqual(host.manager, "fake")
     self.assertEqual(host.group, "my-group")
     self.assertEqual(host.config, conf)
     self.assertEqual(host.alternative_id, 0)
     db_host = Host.find('fake-id', conf=conf)
     self.assertEqual(db_host.id, "fake-id")
     self.assertEqual(db_host.dns_name, "fake-id.my-group.com")
     self.assertEqual(db_host.manager, "fake")
     self.assertEqual(db_host.group, "my-group")
     self.assertEqual(db_host.config, conf)
     self.assertEqual(db_host.alternative_id, 0)
开发者ID:digideskio,项目名称:hm,代码行数:18,代码来源:test_host.py

示例6: test_destroy

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_destroy(self):
     host = Host.create('fake', 'my-group', {"HOST_ID": "fake-id"})
     self.assertEqual(host.id, "fake-id")
     host.destroy()
     db_host = Host.find('fake-id')
     self.assertIsNone(db_host)
开发者ID:digideskio,项目名称:hm,代码行数:8,代码来源:test_host.py

示例7: test_destroy_ignores_manager_error

# 需要导入模块: from hm.model.host import Host [as 别名]
# 或者: from hm.model.host.Host import find [as 别名]
 def test_destroy_ignores_manager_error(self):
     host = Host.create('fake', 'my-group', {"HOST_ID": "explode"})
     self.assertEqual(host.id, "explode")
     host.destroy()
     db_host = Host.find('explode')
     self.assertIsNone(db_host)
开发者ID:carriercomm,项目名称:hm,代码行数:8,代码来源:test_host.py


注:本文中的hm.model.host.Host.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。