From e9e07c9c398c45be5a211f08fcb7d40134a321ec Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 24 Oct 2012 03:46:15 +0200 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9Cgnt-job=20change-priority?= =?UTF-8?q?=E2=80=9D=20sub-command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be used to change the priority of a pending or running job (the latter only if there are unprocessed opcodes). Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Bernardo Dal Seno <bdalseno@google.com> --- lib/client/gnt_job.py | 26 ++++++++++++++++++++++++++ man/gnt-job.rst | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/client/gnt_job.py b/lib/client/gnt_job.py index b1fa7f69c..81f0bd1df 100644 --- a/lib/client/gnt_job.py +++ b/lib/client/gnt_job.py @@ -245,6 +245,26 @@ def CancelJobs(opts, args, cl=None, _stdout_fn=ToStdout, _ask_fn=AskUser): lambda cl, job_id: cl.CancelJob(job_id)) +def ChangePriority(opts, args): + """Change priority of jobs. + + @param opts: Command line options + @type args: list + @param args: Job IDs + @rtype: int + @return: Exit code + + """ + if opts.priority is None: + ToStderr("--priority option must be given.") + return constants.EXIT_FAILURE + + return _MultiJobAction(opts, args, None, None, None, + "Change priority of job(s) listed above?", + lambda cl, job_id: + cl.ChangeJobPriority(job_id, opts.priority)) + + def ShowJobs(opts, args): """Show detailed information about jobs. @@ -494,6 +514,12 @@ commands = { "watch": ( WatchJob, [ArgJobId(min=1, max=1)], [], "<job-id>", "Follows a job and prints its output as it arrives"), + "change-priority": ( + ChangePriority, [ArgJobId()], + [PRIORITY_OPT, FORCE_OPT, _PENDING_OPT, _QUEUED_OPT, _WAITING_OPT], + "--priority <priority> {[--force] {--pending | --queued | --waiting} |" + " <job-id> [<job-id> ...]}", + "Change the priority of jobs"), } diff --git a/man/gnt-job.rst b/man/gnt-job.rst index 773d8a375..c7a0e8a0e 100644 --- a/man/gnt-job.rst +++ b/man/gnt-job.rst @@ -50,6 +50,18 @@ not yet started to run can be canceled; that is, jobs in either the ``--queued`` and ``waiting`` can be used to cancel all jobs in the respective state, ``--pending`` includes both. +CHANGE-PRIORITY +~~~~~~~~~~~~~~~ + +| **change-priority** --priority {low | normal | high} +| {[\--force] {\--pending | \--queued | \--waiting} | *job-id* ...} + +Changes the priority of one or multiple pending jobs. Jobs currently +running have only the priority of remaining opcodes changed. +``--priority`` must be specified. ``--queued`` and ``waiting`` can be +used to re-prioritize all jobs in the respective state, ``--pending`` +includes both. To skip a confirmation, pass ``--force``. + INFO ~~~~ -- GitLab