From 57a62af0eebfd3f831f4be5b6e812c9d5019d0b7 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Fri, 20 Apr 2012 16:29:08 +0000 Subject: [PATCH] Use utils.save_and_reraise_exception It's less code and also logs when exceptions gets dropping instead of silently dropping them Change-Id: I407049861b1a402549f58939b654d1760cdb2d26 --- nova/compute/manager.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 90a458df9c9b..98d9d3472ab0 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2517,11 +2517,10 @@ class ComputeManager(manager.SchedulerDependentManager): try: self.driver.add_to_aggregate(context, aggregate, host, **kwargs) except exception.AggregateError: - error = sys.exc_info() - self._undo_aggregate_operation(context, - self.db.aggregate_host_delete, - aggregate.id, host) - raise error[0], error[1], error[2] + with utils.save_and_reraise_exception(): + self._undo_aggregate_operation(context, + self.db.aggregate_host_delete, + aggregate.id, host) @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) def remove_aggregate_host(self, context, aggregate_id, host, **kwargs): @@ -2532,12 +2531,11 @@ class ComputeManager(manager.SchedulerDependentManager): aggregate, host, **kwargs) except (exception.AggregateError, exception.InvalidAggregateAction) as e: - error = sys.exc_info() - self._undo_aggregate_operation( + with utils.save_and_reraise_exception(): + self._undo_aggregate_operation( context, self.db.aggregate_host_add, aggregate.id, host, isinstance(e, exception.AggregateError)) - raise error[0], error[1], error[2] def _undo_aggregate_operation(self, context, op, aggregate_id, host, set_error=True):