本文整理汇总了Python中nova.db.instance_fault_create函数的典型用法代码示例。如果您正苦于以下问题:Python instance_fault_create函数的具体用法?Python instance_fault_create怎么用?Python instance_fault_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了instance_fault_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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()
# Create faults
uuid = str(utils.gen_uuid())
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuid,
'code': 404,
}
db.instance_fault_create(ctxt, fault_values)
uuid2 = str(utils.gen_uuid())
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuid2,
'code': 500,
}
db.instance_fault_create(ctxt, fault_values)
# Retrieve the fault to ensure it was successfully added
instance_fault = db.instance_fault_get_by_instance(ctxt, uuid2)
self.assertEqual(500, instance_fault['code'])
开发者ID:TMG-nl,项目名称:nova,代码行数:26,代码来源:test_db_api.py
示例3: test_instance_fault_get_by_instance_first_fault
def test_instance_fault_get_by_instance_first_fault(self):
"""Instance_fault_get_by_instance should return the latest fault """
ctxt = context.get_admin_context()
# Create faults
uuid = str(utils.gen_uuid())
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuid,
'code': 404,
}
db.instance_fault_create(ctxt, fault_values)
fault_values = {
'message': 'message',
'details': 'detail',
'instance_uuid': uuid,
'code': 500,
}
db.instance_fault_create(ctxt, fault_values)
# Retrieve the fault to ensure it was successfully added
instance_fault = db.instance_fault_get_by_instance(ctxt, uuid)
self.assertEqual(500, instance_fault['code'])
开发者ID:TMG-nl,项目名称:nova,代码行数:25,代码来源:test_db_api.py
示例4: add_instance_fault_from_exc
def add_instance_fault_from_exc(context, instance, fault, exc_info=None):
"""Adds the specified fault to the database."""
code = 500
message = fault.__class__.__name__
if hasattr(fault, "kwargs"):
code = fault.kwargs.get('code', 500)
# get the message from the exception that was thrown
# if that does not exist, use the name of the exception class itself
message = fault.kwargs.get('value', message)
details = unicode(fault)
if exc_info and code == 500:
tb = exc_info[2]
details += '\n' + ''.join(traceback.format_tb(tb))
values = {
'instance_uuid': instance['uuid'],
'code': code,
'message': unicode(message),
'details': unicode(details),
'host': CONF.host
}
db.instance_fault_create(context, values)
开发者ID:gtriolo,项目名称:nova,代码行数:25,代码来源:utils.py
示例5: test_instance_fault_create
def test_instance_fault_create(self):
self.mox.StubOutWithMock(db, 'instance_fault_create')
db.instance_fault_create(self.context, 'fake-values').AndReturn(
'fake-result')
self.mox.ReplayAll()
result = self.conductor.instance_fault_create(self.context,
'fake-values')
self.assertEqual(result, 'fake-result')
开发者ID:gminator,项目名称:nova,代码行数:8,代码来源:test_conductor.py
示例6: test_handle_schedule_error_adds_instance_fault
def test_handle_schedule_error_adds_instance_fault(self):
instance = {"uuid": "fake-uuid"}
self.mox.StubOutWithMock(db, "instance_update_and_get_original")
self.mox.StubOutWithMock(db, "instance_fault_create")
self.mox.StubOutWithMock(notifier, "notify")
db.instance_update_and_get_original(self.context, instance["uuid"], mox.IgnoreArg()).AndReturn((None, instance))
db.instance_fault_create(self.context, mox.IgnoreArg())
notifier.notify(self.context, mox.IgnoreArg(), "scheduler.run_instance", notifier.ERROR, mox.IgnoreArg())
self.mox.ReplayAll()
driver.handle_schedule_error(self.context, exception.NoValidHost("test"), instance["uuid"], {})
开发者ID:jjo,项目名称:openstack-nova,代码行数:11,代码来源:test_scheduler.py
示例7: 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
示例8: test_set_vm_state_and_notify_adds_instance_fault
def test_set_vm_state_and_notify_adds_instance_fault(self):
request = {"instance_properties": {"uuid": "fake-uuid"}}
updates = {"vm_state": "foo"}
fake_inst = {"uuid": "fake-uuid"}
self.mox.StubOutWithMock(db, "instance_update_and_get_original")
self.mox.StubOutWithMock(db, "instance_fault_create")
self.mox.StubOutWithMock(notifier, "notify")
db.instance_update_and_get_original(self.context, "fake-uuid", updates).AndReturn((None, fake_inst))
db.instance_fault_create(self.context, mox.IgnoreArg())
notifier.notify(self.context, mox.IgnoreArg(), "scheduler.foo", notifier.ERROR, mox.IgnoreArg())
self.mox.ReplayAll()
self.manager._set_vm_state_and_notify("foo", {"vm_state": "foo"}, self.context, None, request)
开发者ID:jjo,项目名称:openstack-nova,代码行数:14,代码来源:test_scheduler.py
示例9: test_handle_schedule_error_adds_instance_fault
def test_handle_schedule_error_adds_instance_fault(self):
instance = {"uuid": "fake-uuid"}
self.mox.StubOutWithMock(db, "instance_update_and_get_original")
self.mox.StubOutWithMock(db, "instance_fault_create")
db.instance_update_and_get_original(self.context, instance["uuid"], mox.IgnoreArg()).AndReturn((None, instance))
db.instance_fault_create(self.context, mox.IgnoreArg())
self.mox.StubOutWithMock(rpc, "get_notifier")
notifier = self.mox.CreateMockAnything()
rpc.get_notifier("conductor", CONF.host).AndReturn(notifier)
rpc.get_notifier("scheduler").AndReturn(notifier)
notifier.error(self.context, "scheduler.run_instance", mox.IgnoreArg())
self.mox.ReplayAll()
driver.handle_schedule_error(self.context, exception.NoValidHost("test"), instance["uuid"], {})
开发者ID:ramielrowe,项目名称:nova,代码行数:14,代码来源:test_scheduler.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:matiu2,项目名称:nova,代码行数:48,代码来源:test_db_api.py
示例11: 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:matiu2,项目名称:nova,代码行数:17,代码来源:test_db_api.py
示例12: test_set_vm_state_and_notify_adds_instance_fault
def test_set_vm_state_and_notify_adds_instance_fault(self):
request = {"instance_properties": {"uuid": "fake-uuid"}}
updates = {"vm_state": "foo"}
fake_inst = {"uuid": "fake-uuid"}
self.mox.StubOutWithMock(db, "instance_update_and_get_original")
self.mox.StubOutWithMock(db, "instance_fault_create")
self.mox.StubOutWithMock(rpc, "get_notifier")
notifier = self.mox.CreateMockAnything()
rpc.get_notifier("conductor", CONF.host).AndReturn(notifier)
rpc.get_notifier("scheduler").AndReturn(notifier)
db.instance_update_and_get_original(self.context, "fake-uuid", updates).AndReturn((None, fake_inst))
db.instance_fault_create(self.context, mox.IgnoreArg())
notifier.error(self.context, "scheduler.foo", mox.IgnoreArg())
self.mox.ReplayAll()
self.manager._set_vm_state_and_notify("foo", {"vm_state": "foo"}, self.context, None, request)
开发者ID:ramielrowe,项目名称:nova,代码行数:17,代码来源:test_scheduler.py
示例13: test_handle_schedule_error_adds_instance_fault
def test_handle_schedule_error_adds_instance_fault(self):
instance = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
self.mox.StubOutWithMock(db, 'instance_fault_create')
self.mox.StubOutWithMock(notifier, 'notify')
db.instance_update_and_get_original(self.context, instance['uuid'],
mox.IgnoreArg()).AndReturn(
(None, instance))
db.instance_fault_create(self.context, mox.IgnoreArg())
notifier.notify(self.context, mox.IgnoreArg(),
'scheduler.run_instance',
notifier.ERROR, mox.IgnoreArg())
self.mox.ReplayAll()
driver.handle_schedule_error(self.context,
exception.NoValidHost('test'),
instance['uuid'], {})
开发者ID:achbarou,项目名称:nova,代码行数:17,代码来源:test_scheduler.py
示例14: test_set_vm_state_and_notify_adds_instance_fault
def test_set_vm_state_and_notify_adds_instance_fault(self):
request = {'instance_properties': {'uuid': 'fake-uuid'}}
updates = {'vm_state': 'foo'}
fake_inst = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
self.mox.StubOutWithMock(db, 'instance_fault_create')
self.mox.StubOutWithMock(notifier, 'notify')
db.instance_update_and_get_original(self.context, 'fake-uuid',
updates).AndReturn((None,
fake_inst))
db.instance_fault_create(self.context, mox.IgnoreArg())
notifier.notify(self.context, mox.IgnoreArg(), 'scheduler.foo',
notifier.ERROR, mox.IgnoreArg())
self.mox.ReplayAll()
self.manager._set_vm_state_and_notify('foo', {'vm_state': 'foo'},
self.context, None, request)
开发者ID:achbarou,项目名称:nova,代码行数:18,代码来源:test_scheduler.py
示例15: test_handle_schedule_error_adds_instance_fault
def test_handle_schedule_error_adds_instance_fault(self):
instance = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
self.mox.StubOutWithMock(db, 'instance_fault_create')
db.instance_update_and_get_original(self.context, instance['uuid'],
mox.IgnoreArg()).AndReturn(
(None, instance))
db.instance_fault_create(self.context, mox.IgnoreArg()).AndReturn(
test_instance_fault.fake_faults['fake-uuid'][0])
self.mox.StubOutWithMock(rpc, 'get_notifier')
notifier = self.mox.CreateMockAnything()
rpc.get_notifier('scheduler').AndReturn(notifier)
notifier.error(self.context, 'scheduler.run_instance', mox.IgnoreArg())
self.mox.ReplayAll()
driver.handle_schedule_error(self.context,
exception.NoValidHost('test'),
instance['uuid'], {})
开发者ID:PFZheng,项目名称:nova,代码行数:18,代码来源:test_scheduler.py
示例16: add_instance_fault_from_exc
def add_instance_fault_from_exc(context, instance_uuid, fault, exc_info=None):
"""Adds the specified fault to the database."""
code = 500
message = fault.__class__.__name__
if hasattr(fault, "kwargs"):
code = fault.kwargs.get("code", 500)
# get the message from the exception that was thrown
# if that does not exist, use the name of the exception class itself
message = fault.kwargs.get("value", message)
details = unicode(fault)
if exc_info and code == 500:
tb = exc_info[2]
details += "\n" + "".join(traceback.format_tb(tb))
values = {"instance_uuid": instance_uuid, "code": code, "message": unicode(message), "details": unicode(details)}
db.instance_fault_create(context, values)
开发者ID:ameade,项目名称:nova,代码行数:19,代码来源:utils.py
示例17: add_instance_fault_from_exc
def add_instance_fault_from_exc(context, instance_uuid, fault, exc_info=None):
"""Adds the specified fault to the database."""
code = 500
if hasattr(fault, "kwargs"):
code = fault.kwargs.get('code', 500)
details = unicode(fault)
if exc_info and code == 500:
tb = exc_info[2]
details += '\n' + ''.join(traceback.format_tb(tb))
values = {
'instance_uuid': instance_uuid,
'code': code,
'message': fault.__class__.__name__,
'details': unicode(details),
}
db.instance_fault_create(context, values)
开发者ID:Mirantis,项目名称:nova,代码行数:19,代码来源:utils.py
示例18: test_set_vm_state_and_notify_adds_instance_fault
def test_set_vm_state_and_notify_adds_instance_fault(self):
request = {'instance_properties': {'uuid': 'fake-uuid'}}
updates = {'vm_state': 'foo'}
fake_inst = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
self.mox.StubOutWithMock(db, 'instance_fault_create')
self.mox.StubOutWithMock(rpc, 'get_notifier')
notifier = self.mox.CreateMockAnything()
rpc.get_notifier('scheduler').AndReturn(notifier)
db.instance_update_and_get_original(self.context, 'fake-uuid',
updates).AndReturn((None,
fake_inst))
db.instance_fault_create(self.context, mox.IgnoreArg()).AndReturn(
test_instance_fault.fake_faults['fake-uuid'][0])
notifier.error(self.context, 'scheduler.foo', mox.IgnoreArg())
self.mox.ReplayAll()
self.manager._set_vm_state_and_notify('foo', {'vm_state': 'foo'},
self.context, None, request)
开发者ID:PFZheng,项目名称:nova,代码行数:20,代码来源:test_scheduler.py
示例19: create
def create(self, context):
if self.obj_attr_is_set('id'):
raise exception.ObjectActionError(action='create',
reason='already created')
values = {
'instance_uuid': self.instance_uuid,
'code': self.code,
'message': self.message,
'details': self.details,
'host': self.host,
}
db_fault = db.instance_fault_create(context, values)
self._from_db_object(context, self, db_fault)
self.obj_reset_changes()
开发者ID:CiscoSystems,项目名称:nova,代码行数:14,代码来源:instance_fault.py
示例20: create
def create(self, context):
if self.obj_attr_is_set("id"):
raise exception.ObjectActionError(action="create", reason="already created")
values = {
"instance_uuid": self.instance_uuid,
"code": self.code,
"message": self.message,
"details": self.details,
"host": self.host,
}
db_fault = db.instance_fault_create(context, values)
self._from_db_object(context, self, db_fault)
self.obj_reset_changes()
# Cells should only try sending a message over to nova-cells
# if cells is enabled and we're not the API cell. Otherwise,
# if the API cell is calling this, we could end up with
# infinite recursion.
if cells_opts.get_cell_type() == "compute":
try:
cells_rpcapi.CellsAPI().instance_fault_create_at_top(context, db_fault)
except Exception:
LOG.exception(_LE("Failed to notify cells of instance fault"))
开发者ID:rcosma-gd,项目名称:openstack-nova,代码行数:22,代码来源:instance_fault.py
注:本文中的nova.db.instance_fault_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论