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

Python db.compute_node_get函数代码示例

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

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



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

示例1: test_get_by_id

 def test_get_by_id(self):
     self.mox.StubOutWithMock(db, 'compute_node_get')
     db.compute_node_get(self.context, 123).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_id(self.context, 123)
     self.compare_obj(compute, fake_compute_node,
                      comparators={'stats': self.json_comparator})
开发者ID:baoguodong,项目名称:nova,代码行数:7,代码来源:test_compute_node.py


示例2: test_get_by_id

 def test_get_by_id(self):
     ctxt = context.get_admin_context()
     self.mox.StubOutWithMock(db, 'compute_node_get')
     db.compute_node_get(ctxt, 123).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_id(ctxt, 123)
     self._compare(compute, fake_compute_node)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:7,代码来源:test_compute_node.py


示例3: create

    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.obj_get_changes()
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']

        self._convert_stats_to_db_format(updates)
        self._convert_host_ip_to_db_format(updates)
        self._convert_supported_instances_to_db_format(updates)
        self._convert_pci_stats_to_db_format(updates)

        if self._should_manage_inventory():
            self._create_inventory(updates)

        db_compute = db.compute_node_create(self._context, updates)
        # NOTE(danms): compute_node_create() operates on (and returns) the
        # compute node model only. We need to get the full inventory-based
        # result in order to satisfy _from_db_object(). So, we do a double
        # query here. This can be removed in Newton once we're sure that all
        # compute nodes are inventory-based
        db_compute = db.compute_node_get(self._context, db_compute['id'])
        self._from_db_object(self._context, self, db_compute)
开发者ID:BeyondTheClouds,项目名称:nova,代码行数:25,代码来源:compute_node.py


示例4: show

 def show(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         hyp = db.compute_node_get(context, int(id))
     except (ValueError, exception.ComputeHostNotFound):
         msg = _("Hypervisor with ID '%s' could not be found.") % id
         raise webob.exc.HTTPNotFound(explanation=msg)
     return dict(hypervisor=self._view_hypervisor(hyp, True))
开发者ID:chemikadze,项目名称:nova,代码行数:9,代码来源:hypervisors.py


示例5: show

 def show(self, req, resp_obj, id):
     context = req.environ['nova.context']
     resp_obj.attach(xml=PciHypervisorTemplate())
     hypervisor = resp_obj.obj['hypervisor']
     # TODO(yjiang5): Change to compute node object after that change merged
     #compute_node = compute_obj.ComputeNode.get_by_id(
     #    context, hypervisor['id'])
     compute_node = db.compute_node_get(context, hypervisor['id'])
     self._extend_hypervisor(hypervisor, compute_node)
开发者ID:wu330,项目名称:pci_api,代码行数:9,代码来源:pci.py


示例6: detail

 def detail(self, req, resp_obj):
     context = req.environ['nova.context']
     hypervisors = list(resp_obj.obj['hypervisors'])
     for hypervisor in hypervisors:
         # TODO(yjiang5): Change to compute node object after
         # that changes merged
         # compute_node = compute_obj.ComputeNode.get_by_id(
         #    context, hypervisor['id'])
         compute_node = db.compute_node_get(context, hypervisor['id'])
         hypervisor['os-pci:pci_stats'] = compute_node['pci_stats']
开发者ID:wu330,项目名称:pci_api,代码行数:10,代码来源:pci.py


示例7: uptime

    def uptime(self, req, id):
        context = req.environ['nova.context']
        authorize(context)
        try:
            hyp = db.compute_node_get(context, int(id))
        except (ValueError, exception.ComputeHostNotFound):
            msg = _("Hypervisor with ID '%s' could not be found.") % id
            raise webob.exc.HTTPNotFound(explanation=msg)

        # Get the uptime
        try:
            uptime = self.api.get_host_uptime(context, hyp)
        except NotImplementedError:
            msg = _("Virt driver does not implement uptime function.")
            raise webob.exc.HTTPNotImplemented(explanation=msg)

        return dict(hypervisor=self._view_hypervisor(hyp, False,
                                                     uptime=uptime))
开发者ID:chemikadze,项目名称:nova,代码行数:18,代码来源:hypervisors.py


示例8: save

    def save(self, prune_stats=False):
        # NOTE(belliott) ignore prune_stats param, no longer relevant

        updates = self.obj_get_changes()
        updates.pop('id', None)
        self._convert_stats_to_db_format(updates)
        self._convert_host_ip_to_db_format(updates)
        self._convert_supported_instances_to_db_format(updates)
        self._convert_pci_stats_to_db_format(updates)

        db_compute = db.compute_node_update(self._context, self.id, updates)
        # NOTE(danms): compute_node_update() operates on (and returns) the
        # compute node model only. We need to get the full inventory-based
        # result in order to satisfy _from_db_object(). So, we do a double
        # query here. This can be removed in Newton once we're sure that all
        # compute nodes are inventory-based
        db_compute = db.compute_node_get(self._context, self.id)
        self._from_db_object(self._context, self, db_compute)
开发者ID:akashgangil,项目名称:nova,代码行数:18,代码来源:compute_node.py


示例9: get_by_id

 def get_by_id(cls, context, compute_id):
     db_compute = db.compute_node_get(context, compute_id)
     return cls._from_db_object(context, cls(), db_compute)
开发者ID:ubuntuserver,项目名称:nova,代码行数:3,代码来源:compute_node.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db.compute_node_get_all函数代码示例发布时间:2022-05-27
下一篇:
Python db.compute_node_delete函数代码示例发布时间: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