Fix the bug of "openstack usage show"
When there is no resouce usage associated with the project, an odd output will be displayed. This patch tried to fix this issue. Change-Id: I6f254c6ba37fbb760ada08e640c4938668d560dc Closes-Bug: #1512220
This commit is contained in:
parent
cb28cd9ac0
commit
9e50752321
@ -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)))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user