本文整理汇总了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")
示例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)
示例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)
示例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)
示例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')
示例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})
示例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)
示例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)
示例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"]))
示例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)
示例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']))
示例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)
示例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)
示例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)
示例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)