本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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])
示例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)
示例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))
示例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])
示例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)
示例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])
示例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()
示例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])
示例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)
示例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)
示例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)
示例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()
示例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()
示例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)
示例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)