本文整理汇总了Python中nova.db.compute_node_create函数的典型用法代码示例。如果您正苦于以下问题:Python compute_node_create函数的具体用法?Python compute_node_create怎么用?Python compute_node_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compute_node_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _create_compute_service
def _create_compute_service(self, **kwargs):
"""Create a compute service."""
dic = {"binary": "nova-compute", "topic": "compute", "report_count": 0, "availability_zone": "dummyzone"}
dic["host"] = kwargs.get("host", "dummy")
s_ref = db.service_create(self.context, dic)
if "created_at" in kwargs.keys() or "updated_at" in kwargs.keys():
t = utils.utcnow() - datetime.timedelta(0)
dic["created_at"] = kwargs.get("created_at", t)
dic["updated_at"] = kwargs.get("updated_at", t)
db.service_update(self.context, s_ref["id"], dic)
dic = {
"service_id": s_ref["id"],
"vcpus": 16,
"memory_mb": 32,
"local_gb": 100,
"vcpus_used": 16,
"local_gb_used": 10,
"hypervisor_type": "qemu",
"hypervisor_version": 12003,
"cpu_info": "",
}
dic["memory_mb_used"] = kwargs.get("memory_mb_used", 32)
dic["hypervisor_type"] = kwargs.get("hypervisor_type", "qemu")
dic["hypervisor_version"] = kwargs.get("hypervisor_version", 12003)
db.compute_node_create(self.context, dic)
return db.service_get(self.context, s_ref["id"])
开发者ID:rajarammallya,项目名称:openstack-nova,代码行数:28,代码来源:test_scheduler.py
示例2: test_create
def test_create(self, mock_get):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(
self.context,
{
'service_id': 456,
'stats': fake_stats_db_format,
'host_ip': fake_host_ip,
'supported_instances': fake_supported_hv_specs_db_format,
'uuid': uuidsentinel.fake_compute_node,
}).AndReturn(fake_compute_node)
self.mox.ReplayAll()
compute = compute_node.ComputeNode(context=self.context)
compute.service_id = 456
compute.uuid = uuidsentinel.fake_compute_node
compute.stats = fake_stats
# NOTE (pmurray): host_ip is coerced to an IPAddress
compute.host_ip = fake_host_ip
compute.supported_hv_specs = fake_supported_hv_specs
with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
compute.create()
self.assertFalse(mock_gu.called)
self.compare_obj(compute, fake_compute_node,
subs=self.subs(),
comparators=self.comparators())
开发者ID:binarycode,项目名称:nova,代码行数:25,代码来源:test_compute_node.py
示例3: _create_compute_service
def _create_compute_service(self):
"""Create compute-manager(ComputeNode and Service record)."""
ctxt = context.get_admin_context()
dic = {
"host": "dummy",
"binary": "nova-compute",
"topic": "compute",
"report_count": 0,
"availability_zone": "dummyzone",
}
s_ref = db.service_create(ctxt, dic)
dic = {
"service_id": s_ref["id"],
"vcpus": 16,
"memory_mb": 32,
"local_gb": 100,
"vcpus_used": 16,
"memory_mb_used": 32,
"local_gb_used": 10,
"hypervisor_type": "qemu",
"hypervisor_version": 12003,
"cpu_info": "",
}
db.compute_node_create(ctxt, dic)
return db.service_get(ctxt, s_ref["id"])
开发者ID:nati,项目名称:nova,代码行数:27,代码来源:test_hosts.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:kopertop,项目名称:nova,代码行数:31,代码来源:fake.py
示例5: 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
示例6: 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
示例7: test_compute_node_create
def test_compute_node_create(self):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(self.context, 'fake-values').AndReturn(
'fake-result')
self.mox.ReplayAll()
result = self.conductor.compute_node_create(self.context,
'fake-values')
self.assertEqual(result, 'fake-result')
开发者ID:gminator,项目名称:nova,代码行数:8,代码来源:test_conductor.py
示例8: test_recreate_fails
def test_recreate_fails(self):
self.mox.StubOutWithMock(db, "compute_node_create")
db.compute_node_create(self.context, {"service_id": 456}).AndReturn(fake_compute_node)
self.mox.ReplayAll()
compute = compute_node.ComputeNode(context=self.context)
compute.service_id = 456
compute.create()
self.assertRaises(exception.ObjectActionError, compute.create, self.context)
开发者ID:mathslinux,项目名称:nova,代码行数:8,代码来源:test_compute_node.py
示例9: test_create
def test_create(self):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(self.context, {'service_id': 456}).AndReturn(
fake_compute_node)
self.mox.ReplayAll()
compute = compute_node.ComputeNode()
compute.service_id = 456
compute.create(self.context)
self.compare_obj(compute, fake_compute_node)
开发者ID:674009287,项目名称:nova,代码行数:9,代码来源:test_compute_node.py
示例10: test_recreate_fails
def test_recreate_fails(self, mock_get):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(
self.context, {'service_id': 456,
'uuid': uuidsentinel.fake_compute_node}).AndReturn(
fake_compute_node)
self.mox.ReplayAll()
compute = compute_node.ComputeNode(context=self.context)
compute.service_id = 456
compute.uuid = uuidsentinel.fake_compute_node
compute.create()
self.assertRaises(exception.ObjectActionError, compute.create)
开发者ID:binarycode,项目名称:nova,代码行数:12,代码来源:test_compute_node.py
示例11: test_query_allocates_uuid
def test_query_allocates_uuid(self):
fake = dict(fake_compute_node)
fake.pop('uuid')
db.compute_node_create(self.context, fake)
with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
mock_gu.return_value = uuidsentinel.fake_compute_node
obj = objects.ComputeNode.get_by_id(self.context, fake['id'])
mock_gu.assert_called_once_with()
self.assertEqual(uuidsentinel.fake_compute_node, obj.uuid)
self.assertNotIn('uuid', obj.obj_get_changes())
with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
obj = objects.ComputeNode.get_by_id(self.context, fake['id'])
self.assertEqual(uuidsentinel.fake_compute_node, obj.uuid)
self.assertFalse(mock_gu.called)
开发者ID:JioCloudCompute,项目名称:nova,代码行数:14,代码来源:test_compute_node.py
示例12: test_create
def test_create(self):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(
self.context,
{
'service_id': 456,
'stats': fake_stats_db_format
}).AndReturn(fake_compute_node)
self.mox.ReplayAll()
compute = compute_node.ComputeNode()
compute.service_id = 456
compute.stats = fake_stats
compute.create(self.context)
self.compare_obj(compute, fake_compute_node,
comparators={'stats': self.json_comparator})
开发者ID:B-Rich,项目名称:nova-1,代码行数:15,代码来源:test_compute_node.py
示例13: _create_compute_service
def _create_compute_service(self):
"""Create compute-manager(ComputeNode and Service record)."""
ctxt = context.get_admin_context()
dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute',
'report_count': 0, 'availability_zone': 'dummyzone'}
s_ref = db.service_create(ctxt, dic)
dic = {'service_id': s_ref['id'],
'vcpus': 16, 'memory_mb': 32, 'local_gb': 100,
'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10,
'hypervisor_type': 'qemu', 'hypervisor_version': 12003,
'cpu_info': '', 'stats': {}}
db.compute_node_create(ctxt, dic)
return db.service_get(ctxt, s_ref['id'])
开发者ID:gajen,项目名称:nova,代码行数:15,代码来源:test_hosts.py
示例14: 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
示例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-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
示例16: create
def create(self, context):
if self.obj_attr_is_set('id'):
raise exception.ObjectActionError(action='create',
reason='already created')
updates = self.obj_get_changes()
updates.pop('id', None)
db_compute = db.compute_node_create(context, updates)
self._from_db_object(context, self, db_compute)
开发者ID:baoguodong,项目名称:nova,代码行数:8,代码来源:compute_node.py
示例17: _create_compute_service
def _create_compute_service(self):
"""Create compute-manager(ComputeNode and Service record)."""
ctxt = self.req.environ["nova.context"]
dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute',
'report_count': 0}
s_ref = db.service_create(ctxt, dic)
dic = {'service_id': s_ref['id'],
'host': s_ref['host'],
'uuid': uuidsentinel.compute_node,
'vcpus': 16, 'memory_mb': 32, 'local_gb': 100,
'vcpus_used': 16, 'memory_mb_used': 32, 'local_gb_used': 10,
'hypervisor_type': 'qemu', 'hypervisor_version': 12003,
'cpu_info': '', 'stats': ''}
db.compute_node_create(ctxt, dic)
return db.service_get(ctxt, s_ref['id'])
开发者ID:4everming,项目名称:nova,代码行数:17,代码来源:test_hosts.py
示例18: generate_data
def generate_data():
def _generate_stats(id_num):
stats = {}
i = 0
while i < CONF.num_stat:
key = 'key%d' % i
stats[key] = id_num + i
i = i + 1
return stats
print "Starting prepare data in DB"
ctx = context.get_admin_context()
for i in range(CONF.num_comp):
if i *100.0 % CONF.num_comp == 0:
sys.stdout.write("prepared %d%% data\r" % (i * 100.0 / CONF.num_comp))
sys.stdout.flush()
svc_values = {
'host': 'host-%d' % i,
'binary': 'novadbtest',
'topic': 'novadbtest',
'report_count': 0,
}
#created service record
service_ref = jsonutils.to_primitive(
db.service_get_by_host_and_topic(ctx,
svc_values['host'],
svc_values['topic']))
if not service_ref:
service_ref = jsonutils.to_primitive(
db.service_create(ctx, svc_values))
LOG.info('Service record created for id %d', service_ref['id'])
#create/update compute node record
comp_values = {
'service_id': service_ref['id'],
'vcpus': i,
'memory_mb': i,
'local_gb': i,
'vcpus_used': i,
'memory_mb_used': i,
'local_gb_used': i,
'hypervisor_type': 'qemu',
'hypervisor_version': 1,
'hypervisor_hostname': 'test',
'free_ram_mb': i,
'free_disk_gb': i,
'current_workload': i,
'running_vms': i,
'disk_available_least': i,
}
comp_values['cpu_info'] = jsonutils.dumps(_generate_stats(i))
if hasattr(ComputeNode, 'metrics'):
comp_values['metrics'] = jsonutils.dumps(_generate_stats(i))
if CONF.join_stats:
comp_values['stats'] = _generate_stats(i)
compute_ref = jsonutils.to_primitive(
db.compute_node_create(ctx, comp_values))
LOG.info('Compute node record created for id %d', compute_ref['id'])
print "Finish preparing data in DB"
开发者ID:lianhao,项目名称:novadbtest,代码行数:58,代码来源:novadbtest-initdb.py
示例19: 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
示例20: 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
注:本文中的nova.db.compute_node_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论