• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.compute_nodes_get_by_service_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.db.compute_nodes_get_by_service_id函数的典型用法代码示例。如果您正苦于以下问题:Python compute_nodes_get_by_service_id函数的具体用法?Python compute_nodes_get_by_service_id怎么用?Python compute_nodes_get_by_service_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_get_by_service_id

 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_get_by_service_id(self.context, 456).AndReturn(
         [fake_compute_node])
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_service_id(self.context, 456)
     self.compare_obj(compute, fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:9,代码来源:test_compute_node.py


示例2: test_compute_node

 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_get_by_service_id(self.context, 123).AndReturn(
         [test_compute_node.fake_compute_node])
     self.mox.ReplayAll()
     service_obj = service.Service()
     service_obj._context = self.context
     service_obj.id = 123
     self.compare_obj(service_obj.compute_node,
                      test_compute_node.fake_compute_node,
                      subs=self.subs(),
                      allow_missing=OPTIONAL,
                      comparators=self.comparators())
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
开发者ID:dtroyer,项目名称:nova,代码行数:15,代码来源:test_service.py


示例3: get_by_host_and_nodename

 def get_by_host_and_nodename(cls, context, host, nodename):
     try:
         db_compute = db.compute_node_get_by_host_and_nodename(context, host, nodename)
     except exception.ComputeHostNotFound:
         # FIXME(sbauza): Some old computes can still have no host record
         # We need to provide compatibility by using the old service_id
         # record.
         # We assume the compatibility as an extra penalty of one more DB
         # call but that's necessary until all nodes are upgraded.
         try:
             service = objects.Service.get_by_compute_host(context, host)
             db_computes = db.compute_nodes_get_by_service_id(context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         db_compute = None
         for compute in db_computes:
             if compute["hypervisor_hostname"] == nodename:
                 db_compute = compute
                 # We can avoid an extra call to Service object in
                 # _from_db_object
                 db_compute["host"] = service.host
                 break
         if not db_compute:
             raise exception.ComputeHostNotFound(host=host)
     return cls._from_db_object(context, cls(), db_compute)
开发者ID:wenlongwljs,项目名称:nova,代码行数:26,代码来源:compute_node.py


示例4: _get_by_service

 def _get_by_service(cls, context, service_id, use_slave=False):
     try:
         db_computes = db.compute_nodes_get_by_service_id(context, service_id)
     except exception.ServiceNotFound:
         # NOTE(sbauza): Previous behaviour was returning an empty list
         # if the service was created with no computes, we need to keep it.
         db_computes = []
     return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
开发者ID:wenlongwljs,项目名称:nova,代码行数:8,代码来源:compute_node.py


示例5: get_all_by_host

 def get_all_by_host(cls, context, host, use_slave=False):
     try:
         db_computes = db.compute_node_get_all_by_host(context, host, use_slave)
     except exception.ComputeHostNotFound:
         # FIXME(sbauza): Some old computes can still have no host record
         # We need to provide compatibility by using the old service_id
         # record.
         # We assume the compatibility as an extra penalty of one more DB
         # call but that's necessary until all nodes are upgraded.
         try:
             service = objects.Service.get_by_compute_host(context, host, use_slave)
             db_computes = db.compute_nodes_get_by_service_id(context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         # We can avoid an extra call to Service object in _from_db_object
         for db_compute in db_computes:
             db_compute["host"] = service.host
     return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
开发者ID:wenlongwljs,项目名称:nova,代码行数:19,代码来源:compute_node.py


示例6: get_by_service_id

 def get_by_service_id(cls, context, service_id):
     db_computes = db.compute_nodes_get_by_service_id(context, service_id)
     # NOTE(sbauza): Old version was returning an item, we need to keep this
     # behaviour for backwards compatibility
     db_compute = db_computes[0]
     return cls._from_db_object(context, cls(), db_compute)
开发者ID:cotyb,项目名称:nova,代码行数:6,代码来源:compute_node.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.console_pool_get_by_host_type函数代码示例发布时间:2022-05-27
下一篇:
Python db.compute_node_update函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap