summaryrefslogtreecommitdiffstats
path: root/nova/notifications.py
diff options
context:
space:
mode:
authorDoug Hellmann <doug.hellmann@dreamhost.com>2012-06-18 10:52:18 -0400
committerDoug Hellmann <doug.hellmann@dreamhost.com>2012-06-18 16:49:02 -0400
commite71a8c390916079a682b197a291c8fbea5cd844f (patch)
tree4e6d947989dd025930a3c2beb1e2dc6c0e92939f /nova/notifications.py
parentba52373f3827117f07b1b871eed3970c83131973 (diff)
downloadnova-e71a8c390916079a682b197a291c8fbea5cd844f.tar.gz
nova-e71a8c390916079a682b197a291c8fbea5cd844f.tar.xz
nova-e71a8c390916079a682b197a291c8fbea5cd844f.zip
Add instance details to notifications
bug 1006120 Ceilometer needs to collect more data for determining the billing rate for an instance. The most efficient way to get that data is to have it included in the notifications sent by nova, rather than looking it up after the notification is received. This change adds details about the location, size, and "type" of the instance to the existing notification data. It also organizes the set of values into groups and adds comments to clarify those groupings. Change-Id: I01b7b550b0c4a5da1cc0dc764c9a6cb0161bf7e5
Diffstat (limited to 'nova/notifications.py')
-rw-r--r--nova/notifications.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/nova/notifications.py b/nova/notifications.py
index 05c1f7237..654ba5d25 100644
--- a/nova/notifications.py
+++ b/nova/notifications.py
@@ -223,23 +223,52 @@ def usage_from_instance(context, instance_ref, network_info,
instance_type_name = instance_ref.get('instance_type', {}).get('name', '')
usage_info = dict(
+ # Owner properties
tenant_id=instance_ref['project_id'],
user_id=instance_ref['user_id'],
+
+ # Identity properties
instance_id=instance_ref['uuid'],
+ display_name=instance_ref['display_name'],
+ reservation_id=instance_ref['reservation_id'],
+
+ # Type properties
instance_type=instance_type_name,
instance_type_id=instance_ref['instance_type_id'],
+ architecture=instance_ref['architecture'],
+
+ # Capacity properties
memory_mb=instance_ref['memory_mb'],
disk_gb=instance_ref['root_gb'] + instance_ref['ephemeral_gb'],
- display_name=instance_ref['display_name'],
+ vcpus=instance_ref['vcpus'],
+ # Note(dhellmann): This makes the disk_gb value redundant, but
+ # we are keeping it for backwards-compatibility with existing
+ # users of notifications.
+ root_gb=instance_ref['root_gb'],
+ ephemeral_gb=instance_ref['ephemeral_gb'],
+
+ # Location properties
+ host=instance_ref['host'],
+ availability_zone=instance_ref['availability_zone'],
+
+ # Date properties
created_at=str(instance_ref['created_at']),
# Nova's deleted vs terminated instance terminology is confusing,
# this should be when the instance was deleted (i.e. terminated_at),
# not when the db record was deleted. (mdragon)
deleted_at=null_safe_str(instance_ref.get('terminated_at')),
launched_at=null_safe_str(instance_ref.get('launched_at')),
+
+ # Image properties
image_ref_url=image_ref_url,
+ os_type=instance_ref['os_type'],
+ kernel_id=instance_ref['kernel_id'],
+ ramdisk_id=instance_ref['ramdisk_id'],
+
+ # Status properties
state=instance_ref['vm_state'],
- state_description=null_safe_str(instance_ref.get('task_state')))
+ state_description=null_safe_str(instance_ref.get('task_state')),
+ )
if network_info is not None:
usage_info['fixed_ips'] = network_info.fixed_ips()