Support 'atest server list --skylab' with '--json'
BUG=chromium:846057
TEST=None
CQ-DEPEND=CL:1070671
Change-Id: I4ec17681c99295d826b67d7264130fb4b2e96c6e
Reviewed-on: https://chromium-review.googlesource.com/1070709
Commit-Ready: Ningning Xia <nxia@chromium.org>
Tested-by: Ningning Xia <nxia@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/cli/server.py b/cli/server.py
index c9c2127..f389413 100644
--- a/cli/server.py
+++ b/cli/server.py
@@ -164,8 +164,7 @@
action='store_true',
default=False)
self.parser.add_option('--json',
- help=('Format output as JSON. %s' %
- skylab_utils.MSG_INVALID_IN_SKYLAB),
+ help=('Format output as JSON.'),
action='store_true',
default=False)
self.parser.add_option('-N', '--hostnames-only',
@@ -185,8 +184,8 @@
self.namesonly = options.hostnames_only
# TODO(nxia): support all formats for skylab inventory.
- if (self.skylab and (self.json or self.table or self.summary)):
- self.invalid_syntax('The format (table|summary|json)'
+ if (self.skylab and (self.table or self.summary)):
+ self.invalid_syntax('The format (table|summary)'
' is not supported with --skylab.')
if sum([self.table, self.summary, self.json, self.namesonly]) > 1:
@@ -237,7 +236,10 @@
"""
if results:
if self.json:
- formatter = server_manager_utils.format_servers_json
+ if self.skylab:
+ formatter = skylab_server.format_servers_json
+ else:
+ formatter = server_manager_utils.format_servers_json
elif self.table:
formatter = server_manager_utils.format_servers_table
elif self.summary: