diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-12-12 00:54:38 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-12-12 00:54:38 +0000 |
| commit | 1b4a0f859e76de4c6e5cb7b51a12e9bf2fb3e295 (patch) | |
| tree | 9d4d44b70adcd992af1bfe9dbe5a5731dd655ae8 /nova/compute | |
| parent | a4e2ed8cb9ba71e96dfadb96f8171054a0d30914 (diff) | |
| parent | cfe6fe374fa04b9c6150256c9a760b6b340ce697 (diff) | |
Merge "Add preparation for asynchronous instance faults"
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 897a8bc5e..8d9076b33 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -323,10 +323,11 @@ class ComputeManager(manager.SchedulerDependentManager): except exception.InstanceNotFound: LOG.exception(_("Instance %s not found.") % instance_uuid) return # assuming the instance was already deleted - except Exception: + except Exception as e: with utils.save_and_reraise_exception(): self._instance_update(context, instance_uuid, vm_state=vm_states.ERROR) + self.add_instance_fault_from_exc(context, instance_uuid, e) def _check_instance_not_already_created(self, context, instance): """Ensure an instance with the same name is not already present.""" @@ -1917,3 +1918,29 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.info(_("Reclaiming deleted instance %(instance_id)s"), locals()) self._delete_instance(context, instance) + + def add_instance_fault_from_exc(self, context, instance_uuid, fault): + """Adds the specified fault to the database.""" + if hasattr(fault, "code"): + code = fault.code + else: + code = 500 + + values = { + 'instance_uuid': instance_uuid, + 'code': code, + 'message': fault.__class__.__name__, + 'details': fault.message, + } + self.db.instance_fault_create(context, values) + + def add_instance_fault(self, context, instance_uuid, code=500, + message='', details=''): + """Adds a fault to the database using the specified values.""" + values = { + 'instance_uuid': instance_uuid, + 'code': code, + 'message': message, + 'details': details, + } + self.db.instance_fault_create(context, values) |
