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


Python db.compute_node_get函数代码示例

本文整理汇总了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;未经允许,请勿转载。