Revision 3f8e1896
b/qa/qa_job.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
""" |
25 | 25 |
|
26 |
from ganeti.utils import retry |
|
27 |
from ganeti import constants |
|
28 |
from ganeti import query |
|
29 |
|
|
30 | 26 |
import functools |
31 | 27 |
import re |
32 | 28 |
|
29 |
from ganeti.utils import retry |
|
30 |
from ganeti import constants |
|
31 |
from ganeti import query |
|
33 | 32 |
import qa_config |
34 | 33 |
import qa_error |
34 |
import qa_job_utils |
|
35 | 35 |
import qa_utils |
36 |
|
|
37 | 36 |
from qa_utils import AssertCommand, GetCommandOutput |
38 | 37 |
|
39 | 38 |
|
... | ... | |
48 | 47 |
qa_utils.GenericQueryFieldsTest("gnt-job", query.JOB_FIELDS.keys()) |
49 | 48 |
|
50 | 49 |
|
51 |
def _GetJobStatuses(): |
|
52 |
""" Invokes gnt-job list and extracts an id to status dictionary. |
|
53 |
|
|
54 |
@rtype: dict of string to string |
|
55 |
@return: A dictionary mapping job ids to matching statuses |
|
56 |
|
|
57 |
""" |
|
58 |
master = qa_config.GetMasterNode() |
|
59 |
list_output = GetCommandOutput( |
|
60 |
master.primary, "gnt-job list --no-headers --output=id,status" |
|
61 |
) |
|
62 |
return dict(map(lambda s: s.split(), list_output.splitlines())) |
|
63 |
|
|
64 |
|
|
65 | 50 |
def _GetJobStatus(job_id): |
66 | 51 |
""" Retrieves the status of a job. |
67 | 52 |
|
... | ... | |
72 | 57 |
@return: The job status, or None if not present. |
73 | 58 |
|
74 | 59 |
""" |
75 |
return _GetJobStatuses().get(job_id, None)
|
|
60 |
return qa_job_utils.GetJobStatuses([job_id]).get(job_id, None)
|
|
76 | 61 |
|
77 | 62 |
|
78 | 63 |
def _RetryingFetchJobStatus(retry_status, job_id): |
b/qa/qa_job_utils.py | ||
---|---|---|
82 | 82 |
return int(possible_job_ids[0]) |
83 | 83 |
|
84 | 84 |
|
85 |
def GetJobStatuses(job_ids=None): |
|
86 |
""" Invokes gnt-job list and extracts an id to status dictionary. |
|
87 |
|
|
88 |
@type job_ids: list |
|
89 |
@param job_ids: list of job ids to query the status for; if C{None}, the |
|
90 |
status of all current jobs is returned |
|
91 |
@rtype: dict of string to string |
|
92 |
@return: A dictionary mapping job ids to matching statuses |
|
93 |
|
|
94 |
""" |
|
95 |
cmd = ["gnt-job", "list", "--no-headers", "--output=id,status"] |
|
96 |
if job_ids is not None: |
|
97 |
cmd.extend(map(str, job_ids)) |
|
98 |
|
|
99 |
list_output = GetOutputFromMaster(cmd) |
|
100 |
return dict(map(lambda s: s.split(), list_output.splitlines())) |
|
101 |
|
|
102 |
|
|
85 | 103 |
def _RetrieveTerminationInfo(job_id): |
86 | 104 |
""" Retrieves the termination info from a job caused by gnt-debug delay. |
87 | 105 |
|
b/qa/qa_performance.py | ||
---|---|---|
96 | 96 |
def _FetchJobStatuses(self): |
97 | 97 |
"""Retrieves status information of the given jobs. |
98 | 98 |
|
99 |
@rtype: dict of string to list of L{_JobEntry) |
|
100 |
|
|
101 | 99 |
""" |
102 |
cmd = (["gnt-job", "list", "--no-headers", "-o", "id,status"]) |
|
103 |
cmd.extend(map(str, self._GetJobIds())) |
|
104 |
job_statuses = [line.split() for line in |
|
105 |
qa_job_utils.GetOutputFromMaster(cmd).splitlines()] |
|
100 |
job_statuses = qa_job_utils.GetJobStatuses(self._GetJobIds()) |
|
101 |
|
|
106 | 102 |
new_statuses = {} |
107 |
for job_id, status in job_statuses: |
|
103 |
for job_id, status in job_statuses.items():
|
|
108 | 104 |
new_statuses.setdefault(status, []).append(self._jobs[int(job_id)]) |
109 | 105 |
self._jobs_per_status = new_statuses |
110 | 106 |
|
Also available in: Unified diff