summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-05-01 17:31:26 -0400
committerRussell Bryant <rbryant@redhat.com>2012-05-02 16:05:58 -0400
commit29dc47bd5045853d83a2343ec88c36ea89db188d (patch)
tree4a7d4696ceed6ddf34976445bf90a14480e1170e /nova/compute
parent1d97b77ea4c31f1fb17bc20cc4c16a3f6edf2cf1 (diff)
Use save_and_reraise_exception() from common.
This patch common.excutils from openstack-common, which includes save_and_reraise_exception(). The patch also converts the code base to use it from there instead of nova.utils and then removes it from nova.utils. The initial motivation for this was removing another nova dependency from nova.rpc so that it can eventually be moved to openstack-common. Change-Id: I7354ca51a02aec9c709cf33f77d4abc46acc2742
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 71f7e817b..3bb5797ce 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -62,6 +62,7 @@ from nova import network
from nova.network import model as network_model
from nova.notifier import api as notifier
from nova.openstack.common import cfg
+from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova import rpc
from nova import utils
@@ -187,7 +188,7 @@ def wrap_instance_fault(function):
except exception.InstanceNotFound:
raise
except Exception, e:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
self.add_instance_fault_from_exc(context, instance_uuid, e,
sys.exc_info())
@@ -433,7 +434,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info, block_device_info,
injected_files, admin_password)
except Exception:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
self._deallocate_network(context, instance)
if (is_first_time and not instance['access_ip_v4']
@@ -445,7 +446,7 @@ class ComputeManager(manager.SchedulerDependentManager):
except exception.InstanceNotFound:
LOG.warn(_("Instance not found."), instance_uuid=instance_uuid)
except Exception as e:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
self._set_instance_error_state(context, instance_uuid)
def _update_access_ip(self, context, instance, nw_info):
@@ -1335,7 +1336,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context, instance_ref, migration_ref['dest_host'],
instance_type_ref, self._legacy_nw_info(network_info))
except Exception, error:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
LOG.error(_('%s. Setting instance vm_state to ERROR') % error,
instance=instance_ref)
self._set_instance_error_state(context, instance_uuid)
@@ -1425,7 +1426,7 @@ class ComputeManager(manager.SchedulerDependentManager):
self._finish_resize(context, instance_ref, migration_ref,
disk_info, image)
except Exception, error:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
LOG.error(_('%s. Setting instance vm_state to ERROR') % error,
instance=instance_ref)
self._set_instance_error_state(context, instance_ref.uuid)
@@ -1719,7 +1720,7 @@ class ComputeManager(manager.SchedulerDependentManager):
volume,
connector)
except Exception: # pylint: disable=W0702
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
msg = _("Failed to connect to volume %(volume_id)s "
"while attaching at %(mountpoint)s")
LOG.exception(msg % locals(), context=context,
@@ -1730,7 +1731,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref['name'],
mountpoint)
except Exception: # pylint: disable=W0702
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
msg = _("Failed to attach volume %(volume_id)s "
"at %(mountpoint)s")
LOG.exception(msg % locals(), context=context,
@@ -1975,7 +1976,7 @@ class ComputeManager(manager.SchedulerDependentManager):
'disk': disk}})
except Exception:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
instance_uuid = instance_ref['uuid']
LOG.exception(_('Pre live migration failed at %(dest)s'),
locals(), instance=instance_ref)
@@ -2506,7 +2507,7 @@ class ComputeManager(manager.SchedulerDependentManager):
try:
yield
except Exception, error:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
msg = _('%s. Setting instance vm_state to ERROR')
LOG.error(msg % error, instance_uuid=instance_uuid)
self._set_instance_error_state(context, instance_uuid)
@@ -2518,7 +2519,7 @@ class ComputeManager(manager.SchedulerDependentManager):
try:
self.driver.add_to_aggregate(context, aggregate, host, **kwargs)
except exception.AggregateError:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
self._undo_aggregate_operation(context,
self.db.aggregate_host_delete,
aggregate.id, host)
@@ -2532,7 +2533,7 @@ class ComputeManager(manager.SchedulerDependentManager):
aggregate, host, **kwargs)
except (exception.AggregateError,
exception.InvalidAggregateAction) as e:
- with utils.save_and_reraise_exception():
+ with excutils.save_and_reraise_exception():
self._undo_aggregate_operation(
context, self.db.aggregate_host_add,
aggregate.id, host,