Merge "Fix a few issues with 'usage list'"
This commit is contained in:
commit
95313d0a2d
@ -60,12 +60,14 @@ class ListUsage(lister.Lister):
|
|||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
columns = (
|
columns = (
|
||||||
"tenant_id",
|
"tenant_id",
|
||||||
|
"server_usages",
|
||||||
"total_memory_mb_usage",
|
"total_memory_mb_usage",
|
||||||
"total_vcpus_usage",
|
"total_vcpus_usage",
|
||||||
"total_local_gb_usage"
|
"total_local_gb_usage"
|
||||||
)
|
)
|
||||||
column_headers = (
|
column_headers = (
|
||||||
"Project",
|
"Project",
|
||||||
|
"Servers",
|
||||||
"RAM MB-Hours",
|
"RAM MB-Hours",
|
||||||
"CPU Hours",
|
"CPU Hours",
|
||||||
"Disk GB-Hours"
|
"Disk GB-Hours"
|
||||||
@ -84,7 +86,7 @@ class ListUsage(lister.Lister):
|
|||||||
else:
|
else:
|
||||||
end = now + datetime.timedelta(days=1)
|
end = now + datetime.timedelta(days=1)
|
||||||
|
|
||||||
usage_list = compute_client.usage.list(start, end)
|
usage_list = compute_client.usage.list(start, end, detailed=True)
|
||||||
|
|
||||||
# Cache the project list
|
# Cache the project list
|
||||||
project_cache = {}
|
project_cache = {}
|
||||||
@ -95,8 +97,8 @@ class ListUsage(lister.Lister):
|
|||||||
# Just forget it if there's any trouble
|
# Just forget it if there's any trouble
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if len(usage_list) > 0:
|
if parsed_args.formatter == 'table' and len(usage_list) > 0:
|
||||||
sys.stdout.write("Usage from %s to %s:" % (
|
sys.stdout.write("Usage from %s to %s: \n" % (
|
||||||
start.strftime(dateformat),
|
start.strftime(dateformat),
|
||||||
end.strftime(dateformat),
|
end.strftime(dateformat),
|
||||||
))
|
))
|
||||||
@ -106,6 +108,7 @@ class ListUsage(lister.Lister):
|
|||||||
s, columns,
|
s, columns,
|
||||||
formatters={
|
formatters={
|
||||||
'tenant_id': _format_project,
|
'tenant_id': _format_project,
|
||||||
|
'server_usages': lambda x: len(x),
|
||||||
'total_memory_mb_usage': lambda x: float("%.2f" % x),
|
'total_memory_mb_usage': lambda x: float("%.2f" % x),
|
||||||
'total_vcpus_usage': lambda x: float("%.2f" % x),
|
'total_vcpus_usage': lambda x: float("%.2f" % x),
|
||||||
'total_local_gb_usage': lambda x: float("%.2f" % x),
|
'total_local_gb_usage': lambda x: float("%.2f" % x),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user