Merge branch 'devel-2.2'
[ganeti-local] / scripts / gnt-job
index 7c09e7a..2e71bae 100755 (executable)
@@ -134,10 +134,13 @@ def ArchiveJobs(opts, args):
   """
   client = GetClient()
 
+  rcode = 0
   for job_id in args:
-    client.ArchiveJob(job_id)
+    if not client.ArchiveJob(job_id):
+      ToStderr("Failed to archive job with ID '%s'", job_id)
+      rcode = 1
 
-  return 0
+  return rcode
 
 
 def AutoArchiveJobs(opts, args):
@@ -321,7 +324,7 @@ def ShowJobs(opts, args):
       format_msg(3, "Execution log:")
       for serial, log_ts, log_type, log_msg in log:
         time_txt = FormatTimestamp(log_ts)
-        encoded = utils.SafeEncode(log_msg)
+        encoded = FormatLogMessage(log_type, log_msg)
         format_msg(4, "%s:%s:%s %s" % (serial, time_txt, log_type, encoded))
   return 0
 
@@ -367,7 +370,7 @@ commands = {
     "<job-id> [<job-id> ...]", "Archive specified jobs"),
   'autoarchive': (
     AutoArchiveJobs,
-    [ArgSuggest(min=1, max=1, choices=["1d", "1w", "4w"])],
+    [ArgSuggest(min=1, max=1, choices=["1d", "1w", "4w", "all"])],
     [],
     "<age>", "Auto archive jobs older than the given age"),
   'cancel': (