[autotest] Refactor atest server list

This is prep work for adding a JSON output format to atest so various
scripts can use atest to access server_db.

BUG=None
TEST=Run atest server list

Change-Id: If037def77393f60bc87e2b855bb088c72e1c34ab
Reviewed-on: https://chromium-review.googlesource.com/404496
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/cli/server.py b/cli/server.py
index e0c5717..f517046 100644
--- a/cli/server.py
+++ b/cli/server.py
@@ -173,13 +173,18 @@
         @param results: return of the execute call, a list of server object that
                         contains server information.
         """
-        if not results:
+        if results:
+            if self.table:
+                formatter = server_manager_utils.format_servers_table
+            elif self.summary:
+                formatter = server_manager_utils.format_servers_summary
+            else:
+                formatter = server_manager_utils.format_servers
+            print formatter(results)
+        else:
             self.failure('No server is found.',
                          what_failed='Failed to find servers',
                          item=self.hostname, fatal=True)
-        else:
-            print server_manager_utils.get_server_details(results, self.table,
-                                                          self.summary)
 
 
 class server_create(server):