summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-04-26 22:31:23 +0000
committerGerrit Code Review <review@openstack.org>2013-04-26 22:31:23 +0000
commitb19e4cb460cb7b6dff59c75e3a4f00eb16e4b17a (patch)
tree7442fd5454cfa15b9be81afea4fee2cd4c465827 /nova/compute
parent7cb2163c2d3673abeaf0fa67032bfabb7bc75d0b (diff)
parent0c0a211f9fb22485a2c75f70ad86cf4697db11ae (diff)
Merge "Send a instance create error notification"
Diffstat (limited to 'nova/compute')
-rwxr-xr-xnova/compute/manager.py14
-rw-r--r--nova/compute/utils.py9
2 files changed, 17 insertions, 6 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e8f21e9ce..3f6d828e1 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -840,10 +840,14 @@ class ComputeManager(manager.SchedulerDependentManager):
extra_usage_info = {}
def notify(status, msg=None):
- """Send a create.{start,end} notification."""
+ """Send a create.{start,error,end} notification."""
type_ = "create.%(status)s" % dict(status=status)
+ info = extra_usage_info.copy()
+ if not msg:
+ msg = ""
+ info['message'] = msg
self._notify_about_instance_usage(context, instance, type_,
- extra_usage_info=extra_usage_info)
+ extra_usage_info=info)
try:
image_meta = self._prebuild_instance(context, instance)
@@ -855,20 +859,22 @@ class ComputeManager(manager.SchedulerDependentManager):
instance = self._build_instance(context, request_spec,
filter_properties, requested_networks, injected_files,
admin_password, is_first_time, node, instance, image_meta)
- notify("end") # notify that build is done
+ notify("end", msg=_("Success")) # notify that build is done
except exception.RescheduledException as e:
# Instance build encountered an error, and has been rescheduled.
- pass
+ notify("error", msg=unicode(e)) # notify that build failed
except exception.BuildAbortException as e:
# Instance build aborted due to a non-failure
LOG.info(e)
+ notify("end", msg=unicode(e)) # notify that build is done
except Exception as e:
# Instance build encountered a non-recoverable error:
with excutils.save_and_reraise_exception():
self._set_instance_error_state(context, instance['uuid'])
+ notify("error", msg=unicode(e)) # notify that build failed
def _prebuild_instance(self, context, instance):
self._check_instance_exists(context, instance)
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 797bb9f1a..24ace0702 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -245,9 +245,14 @@ def notify_about_instance_usage(context, instance, event_suffix,
usage_info = notifications.info_from_instance(context, instance,
network_info, system_metadata, **extra_usage_info)
+ if event_suffix.endswith("error"):
+ level = notifier_api.ERROR
+ else:
+ level = notifier_api.INFO
+
notifier_api.notify(context, 'compute.%s' % host,
- 'compute.instance.%s' % event_suffix,
- notifier_api.INFO, usage_info)
+ 'compute.instance.%s' % event_suffix, level,
+ usage_info)
def get_nw_info_for_instance(instance):