本文整理汇总了Python中nova.db.instance_fault_get_by_instance_uuids函数的典型用法代码示例。如果您正苦于以下问题:Python instance_fault_get_by_instance_uuids函数的具体用法?Python instance_fault_get_by_instance_uuids怎么用?Python instance_fault_get_by_instance_uuids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了instance_fault_get_by_instance_uuids函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_latest_for_instance
def test_get_latest_for_instance(self):
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
db.instance_fault_get_by_instance_uuids(self.context, ["fake-uuid"]).AndReturn(fake_faults)
self.mox.ReplayAll()
fault = instance_fault.InstanceFault.get_latest_for_instance(self.context, "fake-uuid")
for key in fake_faults["fake-uuid"][0]:
self.assertEqual(fake_faults["fake-uuid"][0][key], fault[key])
开发者ID:lyarwood,项目名称:nova,代码行数:7,代码来源:test_instance_fault.py
示例2: test_get_latest_for_instance_with_none
def test_get_latest_for_instance_with_none(self):
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_fault_get_by_instance_uuids(self.context, ['fake-uuid']
).AndReturn({})
self.mox.ReplayAll()
fault = instance_fault.InstanceFault.get_latest_for_instance(
self.context, 'fake-uuid')
self.assertIsNone(fault)
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:8,代码来源:test_instance_fault.py
示例3: test_get_by_instance_with_none
def test_get_by_instance_with_none(self):
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_fault_get_by_instance_uuids(self.context, ['fake-uuid']
).AndReturn({})
self.mox.ReplayAll()
faults = instance_fault.InstanceFaultList.get_by_instance_uuids(
self.context, ['fake-uuid'])
self.assertEqual(0, len(faults))
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:8,代码来源:test_instance_fault.py
示例4: test_get_by_instance
def test_get_by_instance(self):
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
db.instance_fault_get_by_instance_uuids(self.context, ["fake-uuid"]).AndReturn(fake_faults)
self.mox.ReplayAll()
faults = instance_fault.InstanceFaultList.get_by_instance_uuids(self.context, ["fake-uuid"])
for index, db_fault in enumerate(fake_faults["fake-uuid"]):
for key in db_fault:
self.assertEqual(fake_faults["fake-uuid"][index][key], faults[index][key])
开发者ID:lyarwood,项目名称:nova,代码行数:8,代码来源:test_instance_fault.py
示例5: test_get_latest_for_instance_with_none
def test_get_latest_for_instance_with_none(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_fault_get_by_instance_uuids(ctxt, ['fake-uuid']).AndReturn(
{})
self.mox.ReplayAll()
fault = instance_fault.InstanceFault.get_latest_for_instance(
ctxt, 'fake-uuid')
self.assertEqual(None, fault)
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:9,代码来源:test_instance_fault.py
示例6: test_get_latest_for_instance
def test_get_latest_for_instance(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_fault_get_by_instance_uuids(ctxt, ['fake-uuid']).AndReturn(
fake_faults)
self.mox.ReplayAll()
fault = instance_fault.InstanceFault.get_latest_for_instance(
ctxt, 'fake-uuid')
for key in fake_faults['fake-uuid'][0]:
self.assertEqual(fake_faults['fake-uuid'][0][key], fault[key])
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:10,代码来源:test_instance_fault.py
示例7: test_with_fault
def test_with_fault(self):
fake_inst = dict(self.fake_instance)
fake_uuid = fake_inst["uuid"]
fake_faults = [dict(x, instance_uuid=fake_uuid) for x in test_instance_fault.fake_faults["fake-uuid"]]
self.mox.StubOutWithMock(db, "instance_get_by_uuid")
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
db.instance_get_by_uuid(self.context, fake_uuid, columns_to_join=[]).AndReturn(self.fake_instance)
db.instance_fault_get_by_instance_uuids(self.context, [fake_uuid]).AndReturn({fake_uuid: fake_faults})
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, fake_uuid, expected_attrs=["fault"])
self.assertEqual(fake_faults[0], dict(inst.fault.items()))
self.assertRemotes()
开发者ID:ReVolly,项目名称:nova,代码行数:12,代码来源:test_instance.py
示例8: test_get_by_instance
def test_get_by_instance(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_fault_get_by_instance_uuids(ctxt, ['fake-uuid']).AndReturn(
fake_faults)
self.mox.ReplayAll()
faults = instance_fault.InstanceFaultList.get_by_instance_uuids(
ctxt, ['fake-uuid'])
for index, db_fault in enumerate(fake_faults['fake-uuid']):
for key in db_fault:
self.assertEqual(fake_faults['fake-uuid'][index][key],
faults[index][key])
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:12,代码来源:test_instance_fault.py
示例9: test_with_fault
def test_with_fault(self):
fake_insts = [
fake_instance.fake_db_instance(uuid="fake-uuid", host="host"),
fake_instance.fake_db_instance(uuid="fake-inst2", host="host"),
]
fake_faults = test_instance_fault.fake_faults
self.mox.StubOutWithMock(db, "instance_get_all_by_host")
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
db.instance_get_all_by_host(self.context, "host", columns_to_join=[], use_slave=False).AndReturn(fake_insts)
db.instance_fault_get_by_instance_uuids(self.context, [x["uuid"] for x in fake_insts]).AndReturn(fake_faults)
self.mox.ReplayAll()
instances = instance.InstanceList.get_by_host(self.context, "host", expected_attrs=["fault"], use_slave=False)
self.assertEqual(2, len(instances))
self.assertEqual(fake_faults["fake-uuid"][0], dict(instances[0].fault.iteritems()))
self.assertEqual(None, instances[1].fault)
开发者ID:ZelinIO,项目名称:nova,代码行数:15,代码来源:test_instance.py
示例10: test_instance_fault_get_by_instance
def test_instance_fault_get_by_instance(self):
""" ensure we can retrieve an instance fault by instance UUID """
ctxt = context.get_admin_context()
instance1 = db.instance_create(ctxt, {})
instance2 = db.instance_create(ctxt, {})
uuids = [instance1["uuid"], instance2["uuid"]]
# Create faults
fault_values = {"message": "message", "details": "detail", "instance_uuid": uuids[0], "code": 404}
fault1 = db.instance_fault_create(ctxt, fault_values)
fault_values = {"message": "message", "details": "detail", "instance_uuid": uuids[0], "code": 500}
fault2 = db.instance_fault_create(ctxt, fault_values)
fault_values = {"message": "message", "details": "detail", "instance_uuid": uuids[1], "code": 404}
fault3 = db.instance_fault_create(ctxt, fault_values)
fault_values = {"message": "message", "details": "detail", "instance_uuid": uuids[1], "code": 500}
fault4 = db.instance_fault_create(ctxt, fault_values)
instance_faults = db.instance_fault_get_by_instance_uuids(ctxt, uuids)
expected = {uuids[0]: [fault2, fault1], uuids[1]: [fault4, fault3]}
self.assertEqual(instance_faults, expected)
开发者ID:hiteshwadekar,项目名称:nova,代码行数:25,代码来源:test_db_api.py
示例11: get_latest_by_instance_uuids
def get_latest_by_instance_uuids(cls, context, instance_uuids):
db_faultdict = db.instance_fault_get_by_instance_uuids(context,
instance_uuids,
latest=True)
db_faultlist = itertools.chain(*db_faultdict.values())
return base.obj_make_list(context, cls(context), objects.InstanceFault,
db_faultlist)
开发者ID:Juniper,项目名称:nova,代码行数:7,代码来源:instance_fault.py
示例12: test_get_with_expected
def test_get_with_expected(self):
self.mox.StubOutWithMock(db, "instance_get_by_uuid")
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
exp_cols = instance.INSTANCE_OPTIONAL_ATTRS[:]
exp_cols.remove("fault")
db.instance_get_by_uuid(self.context, "uuid", columns_to_join=exp_cols).AndReturn(self.fake_instance)
fake_faults = test_instance_fault.fake_faults
db.instance_fault_get_by_instance_uuids(self.context, [self.fake_instance["uuid"]]).AndReturn(fake_faults)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(self.context, "uuid", expected_attrs=instance.INSTANCE_OPTIONAL_ATTRS)
for attr in instance.INSTANCE_OPTIONAL_ATTRS:
self.assertTrue(inst.obj_attr_is_set(attr))
self.assertRemotes()
开发者ID:ReVolly,项目名称:nova,代码行数:16,代码来源:test_instance.py
示例13: test_with_fault
def test_with_fault(self):
ctxt = context.get_admin_context()
fake_inst = dict(self.fake_instance)
fake_uuid = fake_inst['uuid']
fake_faults = [dict(x, instance_uuid=fake_uuid)
for x in test_instance_fault.fake_faults['fake-uuid']]
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_get_by_uuid(ctxt, fake_uuid, columns_to_join=[]
).AndReturn(self.fake_instance)
db.instance_fault_get_by_instance_uuids(ctxt, [fake_uuid]).AndReturn(
{fake_uuid: fake_faults})
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(ctxt, fake_uuid,
expected_attrs=['fault'])
self.assertEqual(fake_faults[0], dict(inst.fault.items()))
self.assertRemotes()
开发者ID:ammonite,项目名称:nova,代码行数:17,代码来源:test_instance.py
示例14: test_instance_faults_get_by_instance_uuids_no_faults
def test_instance_faults_get_by_instance_uuids_no_faults(self):
"""None should be returned when no faults exist"""
ctxt = context.get_admin_context()
instance1 = db.instance_create(ctxt, {})
instance2 = db.instance_create(ctxt, {})
uuids = [instance1['uuid'], instance2['uuid']]
instance_faults = db.instance_fault_get_by_instance_uuids(ctxt, uuids)
expected = {uuids[0]: [], uuids[1]: []}
self.assertEqual(expected, instance_faults)
开发者ID:matiu2,项目名称:nova,代码行数:9,代码来源:test_db_api.py
示例15: test_with_fault
def test_with_fault(self):
fake_insts = [
fake_instance.fake_db_instance(uuid='fake-uuid', host='host'),
fake_instance.fake_db_instance(uuid='fake-inst2', host='host'),
]
fake_faults = test_instance_fault.fake_faults
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
db.instance_get_all_by_host(self.context, 'host', columns_to_join=[]
).AndReturn(fake_insts)
db.instance_fault_get_by_instance_uuids(
self.context, [x['uuid'] for x in fake_insts]
).AndReturn(fake_faults)
self.mox.ReplayAll()
instances = instance.InstanceList.get_by_host(self.context, 'host',
expected_attrs=['fault'])
self.assertEqual(2, len(instances))
self.assertEqual(fake_faults['fake-uuid'][0],
dict(instances[0].fault.iteritems()))
self.assertEqual(None, instances[1].fault)
开发者ID:slagle,项目名称:nova,代码行数:20,代码来源:test_instance.py
示例16: test_instance_fault_create
def test_instance_fault_create(self):
"""Ensure we can create an instance fault"""
ctxt = context.get_admin_context()
uuid = str(utils.gen_uuid())
# Create a fault
fault_values = {"message": "message", "details": "detail", "instance_uuid": uuid, "code": 404}
db.instance_fault_create(ctxt, fault_values)
# Retrieve the fault to ensure it was successfully added
faults = db.instance_fault_get_by_instance_uuids(ctxt, [uuid])
self.assertEqual(404, faults[uuid][0]["code"])
开发者ID:hiteshwadekar,项目名称:nova,代码行数:12,代码来源:test_db_api.py
示例17: test_fill_faults
def test_fill_faults(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, "instance_fault_get_by_instance_uuids")
inst1 = instance.Instance()
inst1.uuid = "uuid1"
inst2 = instance.Instance()
inst2.uuid = "uuid2"
insts = [inst1, inst2]
for inst in insts:
inst.obj_reset_changes()
db_faults = {
"uuid1": [
{
"id": 123,
"instance_uuid": "uuid1",
"code": 456,
"message": "Fake message",
"details": "No details",
"host": "foo",
"deleted": False,
"deleted_at": None,
"updated_at": None,
"created_at": None,
}
]
}
db.instance_fault_get_by_instance_uuids(ctxt, [x.uuid for x in insts]).AndReturn(db_faults)
self.mox.ReplayAll()
inst_list = instance.InstanceList()
inst_list._context = ctxt
inst_list.objects = insts
faulty = inst_list.fill_faults()
self.assertEqual(faulty, ["uuid1"])
self.assertEqual(inst_list[0].fault.message, db_faults["uuid1"][0]["message"])
self.assertEqual(inst_list[1].fault, None)
for inst in inst_list:
self.assertEqual(inst.obj_what_changed(), set())
开发者ID:Alexei-Kornienko,项目名称:nova,代码行数:39,代码来源:test_instance.py
示例18: test_fill_faults
def test_fill_faults(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
inst1 = instance.Instance()
inst1.uuid = 'uuid1'
inst2 = instance.Instance()
inst2.uuid = 'uuid2'
insts = [inst1, inst2]
for inst in insts:
inst.obj_reset_changes()
db_faults = {
'uuid1': [{'id': 123,
'instance_uuid': 'uuid1',
'code': 456,
'message': 'Fake message',
'details': 'No details',
'host': 'foo',
'deleted': False,
'deleted_at': None,
'updated_at': None,
'created_at': None,
}
]}
db.instance_fault_get_by_instance_uuids(ctxt,
[x.uuid for x in insts],
).AndReturn(db_faults)
self.mox.ReplayAll()
inst_list = instance.InstanceList()
inst_list._context = ctxt
inst_list.objects = insts
faulty = inst_list.fill_faults()
self.assertEqual(faulty, ['uuid1'])
self.assertEqual(inst_list[0].fault.message,
db_faults['uuid1'][0]['message'])
self.assertEqual(inst_list[1].fault, None)
for inst in inst_list:
self.assertEqual(inst.obj_what_changed(), set())
开发者ID:ammonite,项目名称:nova,代码行数:39,代码来源:test_instance.py
示例19: test_get_with_expected
def test_get_with_expected(self):
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
self.mox.StubOutWithMock(db, 'instance_fault_get_by_instance_uuids')
exp_cols = instance.INSTANCE_OPTIONAL_ATTRS[:]
exp_cols.remove('fault')
db.instance_get_by_uuid(
self.context, 'uuid',
columns_to_join=exp_cols,
use_slave=False
).AndReturn(self.fake_instance)
fake_faults = test_instance_fault.fake_faults
db.instance_fault_get_by_instance_uuids(
self.context, [self.fake_instance['uuid']]
).AndReturn(fake_faults)
self.mox.ReplayAll()
inst = instance.Instance.get_by_uuid(
self.context, 'uuid',
expected_attrs=instance.INSTANCE_OPTIONAL_ATTRS)
for attr in instance.INSTANCE_OPTIONAL_ATTRS:
self.assertTrue(inst.obj_attr_is_set(attr))
self.assertRemotes()
开发者ID:chengxiayan,项目名称:nova,代码行数:24,代码来源:test_instance.py
示例20: test_instance_fault_get_by_instance
def test_instance_fault_get_by_instance(self):
""" ensure we can retrieve an instance fault by instance UUID """
ctxt = context.get_admin_context()
instance1 = db.instance_create(ctxt, {})
instance2 = db.instance_create(ctxt, {})
uuids = [instance1['uuid'], instance2['uuid']]
# Create faults
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuids[0],
'code': 404,
}
fault1 = db.instance_fault_create(ctxt, fault_values)
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuids[0],
'code': 500,
}
fault2 = db.instance_fault_create(ctxt, fault_values)
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuids[1],
'code': 404,
}
fault3 = db.instance_fault_create(ctxt, fault_values)
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuids[1],
'code': 500,
}
fault4 = db.instance_fault_create(ctxt, fault_values)
instance_faults = db.instance_fault_get_by_instance_uuids(ctxt, uuids)
expected = {
uuids[0]: [fault2, fault1],
uuids[1]: [fault4, fault3],
}
self.assertEqual(instance_faults, expected)
开发者ID:matiu2,项目名称:nova,代码行数:48,代码来源:test_db_api.py
注:本文中的nova.db.instance_fault_get_by_instance_uuids函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论