Merge "Fix the bug of "openstack usage show""

This commit is contained in:
Jenkins 2015-11-11 21:46:38 +00:00 committed by Gerrit Code Review
commit 53fc20fa6f

View File

@ -183,10 +183,18 @@ class ShowUsage(show.ShowOne):
)) ))
info = {} info = {}
info['Servers'] = len(usage.server_usages) info['Servers'] = (
info['RAM MB-Hours'] = float("%.2f" % usage.total_memory_mb_usage) len(usage.server_usages)
info['CPU Hours'] = float("%.2f" % usage.total_vcpus_usage) if hasattr(usage, "server_usages") else None)
info['Disk GB-Hours'] = float("%.2f" % usage.total_local_gb_usage) 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))) return zip(*sorted(six.iteritems(info)))