Revision 60452edf
b/lib/cli.py | ||
---|---|---|
28 | 28 |
import time |
29 | 29 |
import logging |
30 | 30 |
import errno |
31 |
import itertools |
|
31 | 32 |
from cStringIO import StringIO |
32 | 33 |
|
33 | 34 |
from ganeti import utils |
... | ... | |
2947 | 2948 |
self.jobs = [] |
2948 | 2949 |
self.opts = opts |
2949 | 2950 |
self.feedback_fn = feedback_fn |
2951 |
self._counter = itertools.count() |
|
2950 | 2952 |
|
2951 | 2953 |
def QueueJob(self, name, *ops): |
2952 | 2954 |
"""Record a job for later submit. |
... | ... | |
2955 | 2957 |
@param name: a description of the job, will be used in WaitJobSet |
2956 | 2958 |
""" |
2957 | 2959 |
SetGenericOpcodeOpts(ops, self.opts) |
2958 |
self.queue.append((name, ops)) |
|
2960 |
self.queue.append((self._counter.next(), name, ops))
|
|
2959 | 2961 |
|
2960 | 2962 |
def SubmitPending(self, each=False): |
2961 | 2963 |
"""Submit all pending jobs. |
... | ... | |
2963 | 2965 |
""" |
2964 | 2966 |
if each: |
2965 | 2967 |
results = [] |
2966 |
for row in self.queue:
|
|
2968 |
for (_, _, ops) in self.queue:
|
|
2967 | 2969 |
# SubmitJob will remove the success status, but raise an exception if |
2968 | 2970 |
# the submission fails, so we'll notice that anyway. |
2969 |
results.append([True, self.cl.SubmitJob(row[1])])
|
|
2971 |
results.append([True, self.cl.SubmitJob(ops)])
|
|
2970 | 2972 |
else: |
2971 |
results = self.cl.SubmitManyJobs([row[1] for row in self.queue]) |
|
2972 |
for (idx, ((status, data), (name, _))) in enumerate(zip(results, |
|
2973 |
self.queue)): |
|
2973 |
results = self.cl.SubmitManyJobs([ops for (_, _, ops) in self.queue]) |
|
2974 |
for ((status, data), (idx, name, _)) in zip(results, self.queue): |
|
2974 | 2975 |
self.jobs.append((idx, status, data, name)) |
2975 | 2976 |
|
2976 | 2977 |
def _ChooseJob(self): |
Also available in: Unified diff