Revision af30b2fd scripts/gnt-job
b/scripts/gnt-job | ||
---|---|---|
35 | 35 |
|
36 | 36 |
_LIST_DEF_FIELDS = ["id", "status"] |
37 | 37 |
|
38 |
_USER_JOB_STATUS = { |
|
39 |
constants.JOB_STATUS_QUEUED: "queued", |
|
40 |
constants.JOB_STATUS_RUNNING: "running", |
|
41 |
constants.JOB_STATUS_CANCELED: "canceled", |
|
42 |
constants.JOB_STATUS_SUCCESS: "success", |
|
43 |
constants.JOB_STATUS_ERROR: "error", |
|
44 |
} |
|
45 |
|
|
38 | 46 |
def ListJobs(opts, args): |
39 | 47 |
"""List the jobs |
40 | 48 |
|
... | ... | |
46 | 54 |
else: |
47 | 55 |
selected_fields = opts.output.split(",") |
48 | 56 |
|
49 |
query = { |
|
50 |
"object": "jobs", |
|
51 |
"fields": selected_fields, |
|
52 |
"names": [], |
|
53 |
} |
|
54 |
|
|
55 |
output = SubmitQuery(query) |
|
57 |
output = GetClient().QueryJobs(None, selected_fields) |
|
56 | 58 |
if not opts.no_headers: |
59 |
# TODO: Implement more fields |
|
57 | 60 |
headers = { |
58 | 61 |
"id": "ID", |
59 | 62 |
"status": "Status", |
60 |
"op_list": "OpCodes",
|
|
61 |
"op_status": "OpStatus",
|
|
62 |
"op_result": "OpResult",
|
|
63 |
"ops": "OpCodes",
|
|
64 |
"opresult": "OpCode_result",
|
|
65 |
"opstatus": "OpCode_status",
|
|
63 | 66 |
} |
64 | 67 |
else: |
65 | 68 |
headers = None |
... | ... | |
73 | 76 |
for idx, field in enumerate(selected_fields): |
74 | 77 |
val = row[idx] |
75 | 78 |
if field == "status": |
76 |
if val == opcodes.Job.STATUS_PENDING: |
|
77 |
val = "pending" |
|
78 |
elif val == opcodes.Job.STATUS_RUNNING: |
|
79 |
val = "running" |
|
80 |
elif val == opcodes.Job.STATUS_SUCCESS: |
|
81 |
val = "finished" |
|
82 |
elif val == opcodes.Job.STATUS_FAIL: |
|
83 |
val = "failed" |
|
84 |
elif val == opcodes.Job.STATUS_ABORT: |
|
85 |
val = "aborted" |
|
79 |
if val in _USER_JOB_STATUS: |
|
80 |
val = _USER_JOB_STATUS[val] |
|
86 | 81 |
else: |
87 | 82 |
raise errors.ProgrammerError("Unknown job status code '%s'" % val) |
88 | 83 |
|
Also available in: Unified diff