本文整理汇总了Python中nova.db.aggregate_create函数的典型用法代码示例。如果您正苦于以下问题:Python aggregate_create函数的具体用法?Python aggregate_create怎么用?Python aggregate_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了aggregate_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_recreate_fails
def test_recreate_fails(self):
self.mox.StubOutWithMock(db, "aggregate_create")
db.aggregate_create(self.context, {"name": "foo"}, metadata={"one": "two"}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate(context=self.context)
agg.name = "foo"
agg.metadata = {"one": "two"}
agg.create()
self.assertRaises(exception.ObjectActionError, agg.create, self.context)
开发者ID:wenlongwljs,项目名称:nova,代码行数:9,代码来源:test_aggregate.py
示例2: test_create
def test_create(self):
self.mox.StubOutWithMock(db, "aggregate_create")
db.aggregate_create(self.context, {"name": "foo"}, metadata={"one": "two"}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate(context=self.context)
agg.name = "foo"
agg.metadata = {"one": "two"}
agg.create()
self.compare_obj(agg, fake_aggregate, subs=SUBS)
开发者ID:wenlongwljs,项目名称:nova,代码行数:9,代码来源:test_aggregate.py
示例3: test_create
def test_create(self):
self.mox.StubOutWithMock(db, 'aggregate_create')
db.aggregate_create(self.context, {'name': 'foo'},
metadata={'one': 'two'}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate()
agg.name = 'foo'
agg.metadata = {'one': 'two'}
agg.create(self.context)
self.compare_obj(agg, fake_aggregate, subs=SUBS)
开发者ID:CrazyTeaFs,项目名称:nova,代码行数:10,代码来源:test_aggregate.py
示例4: test_recreate_fails
def test_recreate_fails(self):
self.mox.StubOutWithMock(db, 'aggregate_create')
db.aggregate_create(self.context, {'name': 'foo'},
metadata={'one': 'two'}).AndReturn(fake_aggregate)
self.mox.ReplayAll()
agg = aggregate.Aggregate(context=self.context)
agg.name = 'foo'
agg.metadata = {'one': 'two'}
agg.create()
self.assertRaises(exception.ObjectActionError, agg.create)
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:10,代码来源:test_aggregate.py
示例5: test_migration
def test_migration(self):
db.aggregate_create(self.context, {'name': 'foo'})
main_aggregates_len = len(db.aggregate_get_all(self.context))
match, done = aggregate_obj.migrate_aggregates(self.context, 50)
self.assertEqual(1, main_aggregates_len)
self.assertEqual(main_aggregates_len, match)
self.assertEqual(main_aggregates_len, done)
self.assertEqual(0, len(db.aggregate_get_all(self.context)))
self.assertEqual(main_aggregates_len,
len(aggregate_obj.AggregateList.get_all(
self.context)))
开发者ID:4everming,项目名称:nova,代码行数:11,代码来源:test_aggregate.py
示例6: create_aggregate
def create_aggregate(context, db_id, in_api=True):
if in_api:
fake_aggregate = _get_fake_aggregate(db_id, in_api=False, result=False)
aggregate_obj._aggregate_create_in_db(context, fake_aggregate,
metadata=_get_fake_metadata(db_id))
for host in _get_fake_hosts(db_id):
aggregate_obj._host_add_to_db(context, fake_aggregate['id'], host)
else:
fake_aggregate = _get_fake_aggregate(db_id, in_api=False, result=False)
db.aggregate_create(context, fake_aggregate,
metadata=_get_fake_metadata(db_id))
for host in _get_fake_hosts(db_id):
db.aggregate_host_add(context, fake_aggregate['id'], host)
开发者ID:4everming,项目名称:nova,代码行数:13,代码来源:test_aggregate.py
示例7: create
def create(self):
if self.obj_attr_is_set('id'):
raise exception.ObjectActionError(action='create',
reason='already created')
self._assert_no_hosts('create')
updates = self.obj_get_changes()
payload = dict(updates)
if 'metadata' in updates:
# NOTE(danms): For some reason the notification format is weird
payload['meta_data'] = payload.pop('metadata')
if 'uuid' not in updates:
updates['uuid'] = uuidutils.generate_uuid()
LOG.debug('Generated uuid %(uuid)s for aggregate',
dict(uuid=updates['uuid']))
compute_utils.notify_about_aggregate_update(self._context,
"create.start",
payload)
metadata = updates.pop('metadata', None)
db_aggregate = db.aggregate_create(self._context, updates,
metadata=metadata)
self._from_db_object(self._context, self, db_aggregate)
payload['aggregate_id'] = self.id
compute_utils.notify_about_aggregate_update(self._context,
"create.end",
payload)
开发者ID:unicell,项目名称:nova,代码行数:25,代码来源:aggregate.py
示例8: test_create_instance_with_availability_zone
def test_create_instance_with_availability_zone(self):
def create(*args, **kwargs):
self.assertIn("availability_zone", kwargs)
return old_create(*args, **kwargs)
old_create = compute_api.API.create
self.stubs.Set(compute_api.API, "create", create)
image_href = "76fa36fc-c930-4bf3-8c8a-ea2a2420deb6"
flavor_ref = "http://localhost/v3/flavors/3"
body = {
"server": {
"name": "config_drive_test",
"image_ref": image_href,
"flavor_ref": flavor_ref,
"metadata": {"hello": "world", "open": "stack"},
"personality": {},
"availability_zone": "nova",
}
}
req = fakes.HTTPRequestV3.blank("/v3/servers")
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"
admin_context = context.get_admin_context()
service1 = db.service_create(
admin_context, {"host": "host1_zones", "binary": "nova-compute", "topic": "compute", "report_count": 0}
)
agg = db.aggregate_create(admin_context, {"name": "agg1"}, {"availability_zone": "nova"})
db.aggregate_host_add(admin_context, agg["id"], "host1_zones")
res = self.controller.create(req, body).obj
server = res["server"]
self.assertEqual(FAKE_UUID, server["id"])
开发者ID:polettix,项目名称:nova,代码行数:33,代码来源:test_availability_zone.py
示例9: _create_instance_with_availability_zone
def _create_instance_with_availability_zone(self, zone_name):
def create(*args, **kwargs):
self.assertIn("availability_zone", kwargs)
self.assertEqual("nova", kwargs["availability_zone"])
return old_create(*args, **kwargs)
old_create = compute_api.API.create
self.stubs.Set(compute_api.API, "create", create)
image_href = "76fa36fc-c930-4bf3-8c8a-ea2a2420deb6"
flavor_ref = "http://localhost" + self.base_url + "flavors/3"
body = {
"server": {
"name": "server_test",
"imageRef": image_href,
"flavorRef": flavor_ref,
"metadata": {"hello": "world", "open": "stack"},
"availability_zone": zone_name,
}
}
req = fakes.HTTPRequest.blank(self.base_url + "servers")
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"
admin_context = context.get_admin_context()
db.service_create(
admin_context, {"host": "host1_zones", "binary": "nova-compute", "topic": "compute", "report_count": 0}
)
agg = db.aggregate_create(admin_context, {"name": "agg1"}, {"availability_zone": "nova"})
db.aggregate_host_add(admin_context, agg["id"], "host1_zones")
return req, body
开发者ID:gilmeir,项目名称:nova,代码行数:31,代码来源:test_availability_zone.py
示例10: _create_instance_with_availability_zone
def _create_instance_with_availability_zone(self, zone_name):
def create(*args, **kwargs):
self.assertIn('availability_zone', kwargs)
self.assertEqual('nova', kwargs['availability_zone'])
return old_create(*args, **kwargs)
old_create = compute_api.API.create
self.stubs.Set(compute_api.API, 'create', create)
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
flavor_ref = ('http://localhost' + self.base_url + 'flavors/3')
body = {
'server': {
'name': 'server_test',
'imageRef': image_href,
'flavorRef': flavor_ref,
'metadata': {
'hello': 'world',
'open': 'stack',
},
'availability_zone': zone_name,
},
}
admin_context = context.get_admin_context()
db.service_create(admin_context, {'host': 'host1_zones',
'binary': "nova-compute",
'topic': 'compute',
'report_count': 0})
agg = db.aggregate_create(admin_context,
{'name': 'agg1'}, {'availability_zone': 'nova'})
db.aggregate_host_add(admin_context, agg['id'], 'host1_zones')
return self.req, body
开发者ID:ezhangle,项目名称:nova,代码行数:32,代码来源:test_availability_zone.py
示例11: _create_az
def _create_az(self, agg_name, az_name):
agg_meta = {'name': agg_name, 'uuid': uuidsentinel.agg_uuid}
agg = db.aggregate_create(self.context, agg_meta)
metadata = {'availability_zone': az_name}
db.aggregate_metadata_add(self.context, agg['id'], metadata)
return agg
开发者ID:Juniper,项目名称:nova,代码行数:8,代码来源:test_availability_zones.py
示例12: _create_az
def _create_az(self, agg_name, az_name):
agg_meta = {"name": agg_name}
agg = db.aggregate_create(self.context, agg_meta)
metadata = {"availability_zone": az_name}
db.aggregate_metadata_add(self.context, agg["id"], metadata)
return agg
开发者ID:kobtea,项目名称:nova,代码行数:8,代码来源:test_availability_zones.py
示例13: _setup_aggregate_with_host
def _setup_aggregate_with_host(self):
aggregate_ref = db.aggregate_create(self.context.elevated(), {"name": "foo", "availability_zone": "foo"})
self.conductor.aggregate_host_add(self.context, aggregate_ref, "bar")
aggregate_ref = db.aggregate_get(self.context.elevated(), aggregate_ref["id"])
return aggregate_ref
开发者ID:nobuking,项目名称:nova,代码行数:8,代码来源:test_conductor.py
示例14: _create_aggregate_with_host
def _create_aggregate_with_host(self, name='fake_aggregate',
metadata=None,
hosts=['host1']):
values = {'name': name,
'availability_zone': 'fake_avail_zone', }
result = db.aggregate_create(self.context.elevated(), values, metadata)
for host in hosts:
db.aggregate_host_add(self.context.elevated(), result.id, host)
return result
开发者ID:bhuvan,项目名称:nova,代码行数:9,代码来源:test_host_filters.py
示例15: create_availability_zone
def create_availability_zone(context, hosts):
az = create_uuid()
# Create a new host aggregate
aggregate = db.aggregate_create(context, {'name': az}, metadata={'availability_zone': az})
for host in hosts:
db.aggregate_host_add(context, aggregate['id'], host)
return az
开发者ID:alanmeadows,项目名称:cobalt,代码行数:9,代码来源:utils.py
示例16: _setup_aggregate_with_host
def _setup_aggregate_with_host(self):
aggregate_ref = db.aggregate_create(self.context.elevated(),
{'name': 'foo'}, metadata={'availability_zone': 'foo'})
self.conductor.aggregate_host_add(self.context, aggregate_ref, 'bar')
aggregate_ref = db.aggregate_get(self.context.elevated(),
aggregate_ref['id'])
return aggregate_ref
开发者ID:gminator,项目名称:nova,代码行数:10,代码来源:test_conductor.py
示例17: setUp
def setUp(self):
super(AvailabilityZoneTestCases, self).setUp()
self.host = 'me'
self.availability_zone = 'nova-test'
self.default_az = CONF.default_availability_zone
self.default_in_az = CONF.internal_service_availability_zone
self.context = context.get_admin_context()
agg = {'name': 'agg1'}
self.agg = db.aggregate_create(self.context, agg)
metadata = {'availability_zone': self.availability_zone}
db.aggregate_metadata_add(self.context, self.agg['id'], metadata)
开发者ID:beride,项目名称:nova,代码行数:13,代码来源:test_availability_zones.py
示例18: create
def create(self, context):
self._assert_no_hosts("create")
updates = self.obj_get_changes()
payload = dict(updates)
if "metadata" in updates:
# NOTE(danms): For some reason the notification format is weird
payload["meta_data"] = payload.pop("metadata")
compute_utils.notify_about_aggregate_update(context, "create.start", payload)
metadata = updates.pop("metadata", None)
db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
self._from_db_object(context, self, db_aggregate)
payload["aggregate_id"] = self.id
compute_utils.notify_about_aggregate_update(context, "create.end", payload)
开发者ID:ubuntuserver,项目名称:nova,代码行数:13,代码来源:aggregate.py
示例19: test_in_api
def test_in_api(self):
ca1 = _create_aggregate(self.context, values={'name': 'fake_agg_1',
'id': 1,
'uuid': 'nonce'})
ca2 = db.aggregate_create(self.context, {'name': 'fake_agg_2',
'id': 2,
'uuid': 'nonce'})
api_db_agg = aggregate_obj.Aggregate.get_by_id(self.context, ca1['id'])
cell_db_agg = aggregate_obj.Aggregate.get_by_id(
self.context, ca2['id'])
self.assertEqual(api_db_agg.in_api, True)
self.assertEqual(cell_db_agg.in_api, False)
开发者ID:FrancescoTotti,项目名称:nova-1,代码行数:14,代码来源:test_aggregate.py
示例20: create
def create(self, context):
self._assert_no_hosts('create')
updates = {}
for key in self.obj_what_changed():
updates[key] = self[key]
payload = dict(updates)
if 'metadata' in updates:
# NOTE(danms): For some reason the notification format is weird
payload['meta_data'] = payload.pop('metadata')
compute_utils.notify_about_aggregate_update(context,
"create.start",
payload)
metadata = updates.pop('metadata', None)
db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
self._from_db_object(context, self, db_aggregate)
payload['aggregate_id'] = self.id
compute_utils.notify_about_aggregate_update(context,
"create.end",
payload)
开发者ID:prometheanfire,项目名称:nova,代码行数:19,代码来源:aggregate.py
注:本文中的nova.db.aggregate_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论