Some command line scripts fixes
authorIustin Pop <iustin@google.com>
Thu, 12 Feb 2009 17:04:45 +0000 (17:04 +0000)
committerIustin Pop <iustin@google.com>
Thu, 12 Feb 2009 17:04:45 +0000 (17:04 +0000)
This patch changes the gnt-node and gnt-job list commands to accept
argument and list only the selected items, which is useful when having
many nodes or jobs.

It also removes the “--units” option from gnt-job list as we don't
actually use it.

Reviewed-by: imsnah

scripts/gnt-job
scripts/gnt-node

index 9b22a29..ce81709 100755 (executable)
@@ -64,7 +64,7 @@ def ListJobs(opts, args):
   else:
     selected_fields = opts.output.split(",")
 
-  output = GetClient().QueryJobs(None, selected_fields)
+  output = GetClient().QueryJobs(args, selected_fields)
   if not opts.no_headers:
     # TODO: Implement more fields
     headers = {
@@ -84,10 +84,6 @@ def ListJobs(opts, args):
   else:
     headers = None
 
-  # we don't have yet unitfields here
-  unitfields = None
-  numfields = None
-
   # change raw values to nicer strings
   for row in output:
     for idx, field in enumerate(selected_fields):
@@ -107,8 +103,7 @@ def ListJobs(opts, args):
       row[idx] = str(val)
 
   data = GenerateTable(separator=opts.separator, headers=headers,
-                       fields=selected_fields, unitfields=unitfields,
-                       numfields=numfields, data=output, units=opts.units)
+                       fields=selected_fields, data=output)
   for line in data:
     ToStdout(line)
 
@@ -314,9 +309,10 @@ def ShowJobs(opts, args):
 
 
 commands = {
-  'list': (ListJobs, ARGS_NONE,
-            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
-            "", "List the jobs and their status. The available fields are"
+  'list': (ListJobs, ARGS_ANY,
+            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, FIELDS_OPT],
+            "[job_id ...]",
+           "List the jobs and their status. The available fields are"
            " (see the man page for details): id, status, op_list,"
            " op_status, op_result."
            " The default field"
index 40bf594..95cd7f4 100755 (executable)
@@ -142,7 +142,7 @@ def ListNodes(opts, args):
   else:
     selected_fields = opts.output.split(",")
 
-  output = GetClient().QueryNodes([], selected_fields, opts.do_locking)
+  output = GetClient().QueryNodes(args, selected_fields, opts.do_locking)
 
   if not opts.no_headers:
     headers = _LIST_HEADERS
@@ -528,10 +528,10 @@ commands = {
                " (only for instances of type drbd)"),
   'info': (ShowNodeConfig, ARGS_ANY, [DEBUG_OPT],
            "[<node_name>...]", "Show information about the node(s)"),
-  'list': (ListNodes, ARGS_NONE,
-           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT,
-            SUBMIT_OPT, SYNC_OPT],
-           "", "Lists the nodes in the cluster. The available fields"
+  'list': (ListNodes, ARGS_ANY,
+           [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SYNC_OPT],
+           "[nodes...]",
+           "Lists the nodes in the cluster. The available fields"
            " are (see the man page for details): %s"
            " The default field list is (in order): %s." %
            (", ".join(_LIST_HEADERS), ", ".join(_LIST_DEF_FIELDS))),