Skip to content

Commit 6e3c9a3

Browse files
author
Steve Martinelli
committed
Fix a few issues with 'usage list'
* Added number of servers column, was missing * Added a new line character after the initial usage message Change-Id: I6c4e5bda6ba9ceafa92ecf13987c56d0bbe99961
1 parent c7a5ead commit 6e3c9a3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎openstackclient/compute/v2/usage.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ def _format_project(project):
6060
compute_client = self.app.client_manager.compute
6161
columns = (
6262
"tenant_id",
63+
"server_usages",
6364
"total_memory_mb_usage",
6465
"total_vcpus_usage",
6566
"total_local_gb_usage"
6667
)
6768
column_headers = (
6869
"Project",
70+
"Servers",
6971
"RAM MB-Hours",
7072
"CPU Hours",
7173
"Disk GB-Hours"
@@ -84,7 +86,7 @@ def _format_project(project):
8486
else:
8587
end = now + datetime.timedelta(days=1)
8688

87-
usage_list = compute_client.usage.list(start, end)
89+
usage_list = compute_client.usage.list(start, end, detailed=True)
8890

8991
# Cache the project list
9092
project_cache = {}
@@ -95,8 +97,8 @@ def _format_project(project):
9597
# Just forget it if there's any trouble
9698
pass
9799

98-
if len(usage_list) > 0:
99-
sys.stdout.write("Usage from %s to %s:" % (
100+
if parsed_args.formatter == 'table' and len(usage_list) > 0:
101+
sys.stdout.write("Usage from %s to %s: \n" % (
100102
start.strftime(dateformat),
101103
end.strftime(dateformat),
102104
))
@@ -106,6 +108,7 @@ def _format_project(project):
106108
s, columns,
107109
formatters={
108110
'tenant_id': _format_project,
111+
'server_usages': lambda x: len(x),
109112
'total_memory_mb_usage': lambda x: float("%.2f" % x),
110113
'total_vcpus_usage': lambda x: float("%.2f" % x),
111114
'total_local_gb_usage': lambda x: float("%.2f" % x),

0 commit comments

Comments
 (0)