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


Python db.compute_node_update函数代码示例

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


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

示例1: test_compute_node_update

 def test_compute_node_update(self):
     node = {"id": "fake-id"}
     self.mox.StubOutWithMock(db, "compute_node_update")
     db.compute_node_update(self.context, node["id"], "fake-values", False).AndReturn("fake-result")
     self.mox.ReplayAll()
     result = self.conductor.compute_node_update(self.context, node, "fake-values", False)
     self.assertEqual(result, "fake-result")
开发者ID:jdurgin,项目名称:nova,代码行数:7,代码来源:test_conductor.py

示例2: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-coompute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """

        dic = self._max_phy_resouces(ctxt)
        #dic = self._sum_phy_hosts(ctxt)
        dic['hypervisor_type'] = 'physical'
        dic['hypervisor_version'] = 1
        dic['cpu_info'] = 'physical cpu'
        
        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        dic['service_id'] = service_ref['id']

        compute_node_ref = service_ref['compute_node']
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:jeffreycoho,项目名称:nova-folsom-201204271932,代码行数:31,代码来源:driver.py

示例3: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

           Since we don't have a real hypervisor, pretend we have lots of
           disk and ram.
        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {'vcpus': 1,
               'memory_mb': 4096,
               'local_gb': 1028,
               'vcpus_used': 0,
               'memory_mb_used': 0,
               'local_gb_used': 0,
               'hypervisor_type': 'fake',
               'hypervisor_version': '1.0',
                  'service_id': service_ref['id'],
                 'cpu_info': '?'}

        compute_node_ref = service_ref['compute_node']
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:kopertop,项目名称:nova,代码行数:31,代码来源:fake.py

示例4: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

           Since we don't have a real hypervisor, pretend we have lots of
           disk and ram.
        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {
            "vcpus": 1,
            "memory_mb": 4096,
            "local_gb": 1028,
            "vcpus_used": 0,
            "memory_mb_used": 0,
            "local_gb_used": 0,
            "hypervisor_type": "fake",
            "hypervisor_version": "1.0",
            "service_id": service_ref["id"],
            "cpu_info": "?",
        }

        compute_node_ref = service_ref["compute_node"]
        if not compute_node_ref:
            LOG.info(_("Compute_service record created for %s ") % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_("Compute_service record updated for %s ") % host)
            db.compute_node_update(ctxt, compute_node_ref[0]["id"], dic)
开发者ID:erictchiu,项目名称:nova,代码行数:33,代码来源:fake.py

示例5: test_compute_node_update

 def test_compute_node_update(self):
     node = {'id': 'fake-id'}
     self.mox.StubOutWithMock(db, 'compute_node_update')
     db.compute_node_update(self.context, node['id'], 'fake-values',
                            False).AndReturn('fake-result')
     self.mox.ReplayAll()
     result = self.conductor.compute_node_update(self.context, node,
                                                 'fake-values', False)
     self.assertEqual(result, 'fake-result')
开发者ID:gminator,项目名称:nova,代码行数:9,代码来源:test_conductor.py

示例6: test_save

 def test_save(self):
     self.mox.StubOutWithMock(db, 'compute_node_update')
     db.compute_node_update(self.context, 123, {'vcpus_used': 3}).\
             AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode()
     compute.id = 123
     compute.vcpus_used = 3
     compute.save(self.context)
     self.compare_obj(compute, fake_compute_node,
                      comparators={'stats': self.json_comparator})
开发者ID:baoguodong,项目名称:nova,代码行数:11,代码来源:test_compute_node.py

示例7: test_save

 def test_save(self):
     self.mox.StubOutWithMock(db, 'compute_node_update')
     db.compute_node_update(self.context, 123, {'vcpus_used': 3},
                            prune_stats=False
                            ).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode()
     compute.id = 123
     compute.vcpus_used = 3
     compute.save(self.context)
     self.compare_obj(compute, fake_compute_node)
开发者ID:674009287,项目名称:nova,代码行数:11,代码来源:test_compute_node.py

示例8: save

 def save(self, context, prune_stats=False):
     updates = {}
     for key in self.obj_what_changed():
         updates[key] = self[key]
     updates.pop("id", None)
     db_compute = db.compute_node_update(context, self.id, updates, prune_stats=prune_stats)
     self._from_db_object(context, self, db_compute)
开发者ID:prometheanfire,项目名称:nova,代码行数:7,代码来源:compute_node.py

示例9: test_compute_node_stat_prune

    def test_compute_node_stat_prune(self):
        item = self._create_helper("host1")
        for stat in item["stats"]:
            if stat["key"] == "num_instances":
                num_instance_stat = stat
                break

        values = {"stats": dict(num_instances=1)}
        db.compute_node_update(self.ctxt, item["id"], values, prune_stats=True)
        item = db.compute_node_get_all(self.ctxt)[0]
        self.assertEqual(1, len(item["stats"]))

        stat = item["stats"][0]
        self.assertEqual(num_instance_stat["id"], stat["id"])
        self.assertEqual(num_instance_stat["key"], stat["key"])
        self.assertEqual(1, int(stat["value"]))
开发者ID:NewpTone,项目名称:stacklab-nova,代码行数:16,代码来源:test_db_api.py

示例10: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-coompute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {
            "vcpus": self.get_vcpu_total(),
            "memory_mb": self.get_memory_mb_total(),
            "local_gb": self.get_local_gb_total(),
            "vcpus_used": self.get_vcpu_used(),
            "memory_mb_used": self.get_memory_mb_used(),
            "local_gb_used": self.get_local_gb_used(),
            "hypervisor_type": self.get_hypervisor_type(),
            "hypervisor_version": self.get_hypervisor_version(),
            "cpu_info": self.get_cpu_info(),
            "cpu_arch": FLAGS.cpu_arch,
            "xpu_arch": FLAGS.xpu_arch,
            "xpus": FLAGS.xpus,
            "xpu_info": FLAGS.xpu_info,
            "net_arch": FLAGS.net_arch,
            "net_info": FLAGS.net_info,
            "net_mbps": FLAGS.net_mbps,
            "service_id": service_ref["id"],
        }

        compute_node_ref = service_ref["compute_node"]
        LOG.info(_("#### RLK: cpu_arch = %s ") % FLAGS.cpu_arch)
        if not compute_node_ref:
            LOG.info(_("Compute_service record created for %s ") % host)
            dic["service_id"] = service_ref["id"]
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_("Compute_service record updated for %s ") % host)
            db.compute_node_update(ctxt, compute_node_ref[0]["id"], dic)
开发者ID:OpenStack-Kha,项目名称:nova,代码行数:46,代码来源:proxy.py

示例11: test_compute_node_stat_prune

    def test_compute_node_stat_prune(self):
        item = self._create_helper('host1')
        for stat in item['stats']:
            if stat['key'] == 'num_instances':
                num_instance_stat = stat
                break

        values = {
            'stats': dict(num_instances=1)
        }
        db.compute_node_update(self.ctxt, item['id'], values, prune_stats=True)
        item = db.compute_node_get_all(self.ctxt)[0]
        self.assertEqual(1, len(item['stats']))

        stat = item['stats'][0]
        self.assertEqual(num_instance_stat['id'], stat['id'])
        self.assertEqual(num_instance_stat['key'], stat['key'])
        self.assertEqual(1, int(stat['value']))
开发者ID:mapleoin,项目名称:nova,代码行数:18,代码来源:test_db_api.py

示例12: save

    def save(self, context, 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)

        db_compute = db.compute_node_update(context, self.id, updates)
        self._from_db_object(context, self, db_compute)
开发者ID:B-Rich,项目名称:nova-1,代码行数:9,代码来源:compute_node.py

示例13: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-coompute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """

        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        # Updating host information
        dic = {'vcpus': self.get_vcpu_total(),
               'memory_mb': self.get_memory_mb_total(),
               'local_gb': self.get_local_gb_total(),
               'vcpus_used': self.get_vcpu_used(),
               'memory_mb_used': self.get_memory_mb_used(),
               'local_gb_used': self.get_local_gb_used(),
               'hypervisor_type': self.get_hypervisor_type(),
               'hypervisor_version': self.get_hypervisor_version(),
               'cpu_info': self.get_cpu_info(),
               'cpu_arch': FLAGS.cpu_arch,
               'xpu_arch': FLAGS.xpu_arch,
               'xpus': FLAGS.xpus,
               'xpu_info': FLAGS.xpu_info,
               'net_arch': FLAGS.net_arch,
               'net_info': FLAGS.net_info,
               'net_mbps': FLAGS.net_mbps,
               'service_id': service_ref['id']}

        compute_node_ref = service_ref['compute_node']
        LOG.info(_('#### RLK: cpu_arch = %s ') % FLAGS.cpu_arch)
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            dic['service_id'] = service_ref['id']
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:derekhiggins,项目名称:nova,代码行数:44,代码来源:proxy.py

示例14: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-compute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """
        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        host_stats = self.get_host_stats(refresh=True)

        # Updating host information
        total_ram_mb = host_stats["host_memory_total"] / (1024 * 1024)
        free_ram_mb = host_stats["host_memory_free"] / (1024 * 1024)
        total_disk_gb = host_stats["disk_total"] / (1024 * 1024 * 1024)
        used_disk_gb = host_stats["disk_used"] / (1024 * 1024 * 1024)

        dic = {
            "vcpus": 0,
            "memory_mb": total_ram_mb,
            "local_gb": total_disk_gb,
            "vcpus_used": 0,
            "memory_mb_used": total_ram_mb - free_ram_mb,
            "local_gb_used": used_disk_gb,
            "hypervisor_type": "xen",
            "hypervisor_version": 0,
            "hypervisor_hostname": host_stats["host_hostname"],
            "service_id": service_ref["id"],
            "cpu_info": host_stats["host_cpu_info"]["cpu_count"],
        }

        compute_node_ref = service_ref["compute_node"]
        if not compute_node_ref:
            LOG.info(_("Compute_service record created for %s ") % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_("Compute_service record updated for %s ") % host)
            db.compute_node_update(ctxt, compute_node_ref[0]["id"], dic)
开发者ID:Nesrine85,项目名称:nova,代码行数:44,代码来源:connection.py

示例15: update_available_resource

    def update_available_resource(self, ctxt, host):
        """Updates compute manager resource info on ComputeNode table.

        This method is called when nova-compute launches, and
        whenever admin executes "nova-manage service update_resource".

        :param ctxt: security context
        :param host: hostname that compute manager is currently running

        """
        try:
            service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=host)

        host_stats = self.get_host_stats(refresh=True)

        # Updating host information
        total_ram_mb = host_stats['host_memory_total'] / (1024 * 1024)
        free_ram_mb = host_stats['host_memory_free'] / (1024 * 1024)
        total_disk_gb = host_stats['disk_total'] / (1024 * 1024 * 1024)
        used_disk_gb = host_stats['disk_used'] / (1024 * 1024 * 1024)

        dic = {'vcpus': 0,
               'memory_mb': total_ram_mb,
               'local_gb': total_disk_gb,
               'vcpus_used': 0,
               'memory_mb_used': total_ram_mb - free_ram_mb,
               'local_gb_used': used_disk_gb,
               'hypervisor_type': 'xen',
               'hypervisor_version': 0,
               'hypervisor_hostname': host_stats['host_hostname'],
               'service_id': service_ref['id'],
               'cpu_info': host_stats['host_cpu_info']['cpu_count']}

        compute_node_ref = service_ref['compute_node']
        if not compute_node_ref:
            LOG.info(_('Compute_service record created for %s ') % host)
            db.compute_node_create(ctxt, dic)
        else:
            LOG.info(_('Compute_service record updated for %s ') % host)
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
开发者ID:bhuvan,项目名称:nova,代码行数:42,代码来源:driver.py


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