From b59252feb90e3f6c3754c5e464dc28c895ac0c2b Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sun, 19 Jul 2009 01:51:04 +0200
Subject: [PATCH] Switch gnt-debug submit-job to JobExecutor

Currently gnt-debug submits jobs individually, but in 2.1 JobExecutor
uses the optimized SubmitManyJobs luxi call and as such should be used
whenever multiple jobs need to be submitted.

This patch converts gnt-debug submit-job to use it and also removes an
extra empty line in the JobExecutor class.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cli.py        |  1 -
 scripts/gnt-debug | 15 +++++----------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index cfa64f2d4..fefd2b71b 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -1004,7 +1004,6 @@ class JobExecutor(object):
     """
     self.queue.append((name, ops))
 
-
   def SubmitPending(self):
     """Submit all pending jobs.
 
diff --git a/scripts/gnt-debug b/scripts/gnt-debug
index d3bf05450..3a12b2b7a 100755
--- a/scripts/gnt-debug
+++ b/scripts/gnt-debug
@@ -71,19 +71,14 @@ def GenericOpCodes(opts, args):
 
   """
   cl = cli.GetClient()
-  job_data = []
-  job_ids = []
+  jex = cli.JobExecutor(cl=cl)
+
   for fname in args:
     op_data = simplejson.loads(open(fname).read())
     op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data]
-    job_data.append((fname, op_list))
-  for fname, op_list in job_data:
-    jid = cli.SendJob(op_list, cl=cl)
-    ToStdout("File '%s', job id: %s", fname, jid)
-    job_ids.append(jid)
-  for jid in job_ids:
-    ToStdout("Waiting for job id %s", jid)
-    cli.PollJob(jid, cl=cl)
+    jex.QueueJob("file %s" % fname, *op_list)
+
+  jex.GetResults()
   return 0
 
 
-- 
GitLab