diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-04-19 17:40:52 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-04-19 17:40:52 +0000 |
| commit | 2d8ebfeda8db3b3232506c6b142c4004bb206092 (patch) | |
| tree | e663f522c56948d53aabce942544604aa6fb35e2 /nova/utils.py | |
| parent | abe04a0548dba801c67b8e2998dbd7d739f7b543 (diff) | |
| parent | 4d7c40423d8bb8e22dab8a59d0ba381871eb8a8e (diff) | |
Merge "Add deleted_at to instance usage notification."
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/nova/utils.py b/nova/utils.py index cb54235c1..d12694be2 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -458,6 +458,9 @@ def last_completed_audit_period(unit=None): def usage_from_instance(instance_ref, network_info=None, **kw): + def null_safe_str(s): + return str(s) if s else '' + image_ref_url = "%s/images/%s" % (generate_glance_url(), instance_ref['image_ref']) @@ -471,12 +474,11 @@ def usage_from_instance(instance_ref, network_info=None, **kw): disk_gb=instance_ref['root_gb'] + instance_ref['ephemeral_gb'], display_name=instance_ref['display_name'], created_at=str(instance_ref['created_at']), - launched_at=str(instance_ref['launched_at']) - if instance_ref['launched_at'] else '', + deleted_at=null_safe_str(instance_ref['deleted_at']), + launched_at=null_safe_str(instance_ref['launched_at']), image_ref_url=image_ref_url, state=instance_ref['vm_state'], - state_description=instance_ref['task_state'] - if instance_ref['task_state'] else '') + state_description=null_safe_str(instance_ref['task_state'])) if network_info is not None: usage_info['fixed_ips'] = network_info.fixed_ips() |
