diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-11-11 21:46:38 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-11-11 21:46:38 +0000 |
| commit | 53fc20fa6f65191eff7f5802c15a13e060225c69 (patch) | |
| tree | 2f1809fbfb2d854c3af2cd955220d83c37b45d3c /openstackclient | |
| parent | 46f1676dceddbcc0448093a761cba2ccd28267f2 (diff) | |
| parent | 9e507523215bb38502832ceccea0a9b94b6f4cbd (diff) | |
| download | python-openstackclient-53fc20fa6f65191eff7f5802c15a13e060225c69.tar.gz | |
Merge "Fix the bug of "openstack usage show""
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/compute/v2/usage.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/openstackclient/compute/v2/usage.py b/openstackclient/compute/v2/usage.py index 31b90c22..6d5d678f 100644 --- a/openstackclient/compute/v2/usage.py +++ b/openstackclient/compute/v2/usage.py @@ -183,10 +183,18 @@ class ShowUsage(show.ShowOne): )) info = {} - info['Servers'] = len(usage.server_usages) - info['RAM MB-Hours'] = float("%.2f" % usage.total_memory_mb_usage) - info['CPU Hours'] = float("%.2f" % usage.total_vcpus_usage) - info['Disk GB-Hours'] = float("%.2f" % usage.total_local_gb_usage) + info['Servers'] = ( + len(usage.server_usages) + if hasattr(usage, "server_usages") else None) + info['RAM MB-Hours'] = ( + float("%.2f" % usage.total_memory_mb_usage) + if hasattr(usage, "total_memory_mb_usage") else None) + info['CPU Hours'] = ( + float("%.2f" % usage.total_vcpus_usage) + if hasattr(usage, "total_vcpus_usage") else None) + info['Disk GB-Hours'] = ( + float("%.2f" % usage.total_local_gb_usage) + if hasattr(usage, "total_local_gb_usage") else None) return zip(*sorted(six.iteritems(info))) |
