[LNT] r309011 - admin: Add machine-info command

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 12:42:42 PDT 2017


Author: matze
Date: Tue Jul 25 12:42:42 2017
New Revision: 309011

URL: http://llvm.org/viewvc/llvm-project?rev=309011&view=rev
Log:
admin: Add machine-info command

Modified:
    lnt/trunk/docs/tools.rst
    lnt/trunk/lnt/lnttool/admin.py

Modified: lnt/trunk/docs/tools.rst
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docs/tools.rst?rev=309011&r1=309010&r2=309011&view=diff
==============================================================================
--- lnt/trunk/docs/tools.rst (original)
+++ lnt/trunk/docs/tools.rst Tue Jul 25 12:42:42 2017
@@ -62,8 +62,11 @@ an authentication mechanism specified in
   ``lnt admin list-machines``
   List machines and their id numbers
 
+  ``lnt admin machine-info <machine>``
+  Display information about the specified machine.
+
   ``lnt admin get-machine <machine>``
-  Download machine information and run list for a specific machine.
+  Download machine information and save data in a json file.
 
   ``lnt admin rm-machine <machine>``
   Removes the specified machine and related runs and samples.

Modified: lnt/trunk/lnt/lnttool/admin.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/admin.py?rev=309011&r1=309010&r2=309011&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/admin.py (original)
+++ lnt/trunk/lnt/lnttool/admin.py Tue Jul 25 12:42:42 2017
@@ -100,13 +100,23 @@ def _check_response(response):
     sys.exit(1)
 
 
+def _sorted_dict_items(dict, *args):
+    result = list()
+    for key in args:
+        if key in dict:
+            result.append((key, dict.pop(key)))
+    # Order rest alphabetically
+    result += sorted(dict.items())
+    return result
+
+
 def _print_machine_info(machine, indent=''):
-    for key, value in machine.items():
+    for key, value in _sorted_dict_items(machine, 'name', 'id'):
         sys.stdout.write('%s%s: %s\n' % (indent, key, value))
 
 
 def _print_run_info(run, indent=''):
-    for key, value in run.items():
+    for key, value in _sorted_dict_items(run, 'id'):
         sys.stdout.write('%s%s: %s\n' % (indent, key, value))
 
 
@@ -155,6 +165,19 @@ def action_get_machine(config, machine):
     sys.stdout.write("%s created.\n" % filename)
 
 
+ at click.command("machine-info")
+ at _pass_config
+ at click.argument("machine")
+def action_machine_info(config, machine):
+    """Show machine information."""
+    url = ('{lnt_url}/api/db_{database}/v4/{testsuite}/machines/{machine}'
+           .format(machine=machine, **config.dict))
+    response = config.session.get(url)
+    _check_response(response)
+    data = json.loads(response.text)
+    _print_machine_info(data['machine'])
+
+
 @click.command("rm-machine")
 @_pass_config
 @click.argument("machine")
@@ -331,6 +354,7 @@ class AdminCLI(click.MultiCommand):
         action_get_run,
         action_list_machines,
         action_list_runs,
+        action_machine_info,
         action_merge_machine_into,
         action_post_run,
         action_rename_machine,




More information about the llvm-commits mailing list