projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
An attempt at fixing some encoding issues
[ganeti-local]
/
scripts
/
gnt-job
diff --git
a/scripts/gnt-job
b/scripts/gnt-job
index
e1ee560
..
9b22a29
100755
(executable)
--- a/
scripts/gnt-job
+++ b/
scripts/gnt-job
@@
-28,6
+28,7
@@
import sys
from ganeti.cli import *
from ganeti import constants
from ganeti import errors
from ganeti.cli import *
from ganeti import constants
from ganeti import errors
+from ganeti import utils
#: default list of fields for L{ListJobs}
#: default list of fields for L{ListJobs}
@@
-38,6
+39,7
@@
_LIST_DEF_FIELDS = ["id", "status", "summary"]
_USER_JOB_STATUS = {
constants.JOB_STATUS_QUEUED: "queued",
constants.JOB_STATUS_WAITLOCK: "waiting",
_USER_JOB_STATUS = {
constants.JOB_STATUS_QUEUED: "queued",
constants.JOB_STATUS_WAITLOCK: "waiting",
+ constants.JOB_STATUS_CANCELING: "canceling",
constants.JOB_STATUS_RUNNING: "running",
constants.JOB_STATUS_CANCELED: "canceled",
constants.JOB_STATUS_SUCCESS: "success",
constants.JOB_STATUS_RUNNING: "running",
constants.JOB_STATUS_CANCELED: "canceled",
constants.JOB_STATUS_SUCCESS: "success",
@@
-140,8
+142,8
@@
def AutoArchiveJobs(opts, args):
@param opts: the command line options selected by the user
@type args: list
@param args: should contain only one element, the age as a time spec
@param opts: the command line options selected by the user
@type args: list
@param args: should contain only one element, the age as a time spec
- that can be parsed by L{cli.ParseTimespec} or the keyword I{all},
- which will cause all jobs to be archived
+ that can be parsed by L{ganeti.cli.ParseTimespec} or the
+ keyword I{all}, which will cause all jobs to be archived
@rtype: int
@return: the desired exit code
@rtype: int
@return: the desired exit code
@@
-155,7
+157,9
@@
def AutoArchiveJobs(opts, args):
else:
age = ParseTimespec(age)
else:
age = ParseTimespec(age)
- client.AutoArchiveJobs(age)
+ (archived_count, jobs_left) = client.AutoArchiveJobs(age)
+ ToStdout("Archived %s jobs, %s unchecked left", archived_count, jobs_left)
+
return 0
return 0
@@
-172,8
+176,10
@@
def CancelJobs(opts, args):
client = GetClient()
for job_id in args:
client = GetClient()
for job_id in args:
- client.CancelJob(job_id)
+ (success, msg) = client.CancelJob(job_id)
+ ToStdout(msg)
+ # TODO: Different exit value if not all jobs were canceled?
return 0
return 0
@@
-302,7
+308,7
@@
def ShowJobs(opts, args):
format(3, "Execution log:")
for serial, log_ts, log_type, log_msg in log:
time_txt = FormatTimestamp(log_ts)
format(3, "Execution log:")
for serial, log_ts, log_type, log_msg in log:
time_txt = FormatTimestamp(log_ts)
- encoded = str(log_msg).encode('string_escape')
+ encoded = utils.SafeEncode(log_msg)
format(4, "%s:%s:%s %s" % (serial, time_txt, log_type, encoded))
return 0
format(4, "%s:%s:%s %s" % (serial, time_txt, log_type, encoded))
return 0