Package ganeti :: Package client :: Module gnt_job
[hide private]
[frames] | no frames]

Module gnt_job

source code

Job related commands

Functions [hide private]
 
_FormatStatus(value)
Formats a job status.
source code
int
ListJobs(opts, args)
List the jobs
source code
int
ListJobFields(opts, args)
List job fields.
source code
int
ArchiveJobs(opts, args)
Archive jobs.
source code
int
AutoArchiveJobs(opts, args)
Archive jobs based on age.
source code
int
CancelJobs(opts, args)
Cancel not-yet-started jobs.
source code
int
ShowJobs(opts, args)
Show detailed information about jobs.
source code
int
WatchJob(opts, args)
Follow a job and print its output as it arrives.
source code
 
Main() source code
Variables [hide private]
  _LIST_DEF_FIELDS = ["id", "status", "summary"]
default list of fields for ListJobs
  _USER_JOB_STATUS = {constants.JOB_STATUS_QUEUED: "queued", con...
map converting the job status contants to user-visible names
  _PENDING_OPT = cli_option("--pending", default= None, action= ...
  _RUNNING_OPT = cli_option("--running", default= None, action= ...
  _ERROR_OPT = cli_option("--error", default= None, action= "sto...
  _FINISHED_OPT = cli_option("--finished", default= None, action...
  commands = {"list":(ListJobs, [ArgJobId()], [NOHDR_OPT, SEP_OP...
  aliases = {"show": "info",}
dictionary with aliases for commands

Imports: constants, errors, utils, cli, qlang


Function Details [hide private]

ListJobs(opts, args)

source code 

List the jobs

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should be an empty list
Returns: int
the desired exit code

ListJobFields(opts, args)

source code 

List job fields.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - fields to list, or empty for all
Returns: int
the desired exit code

ArchiveJobs(opts, args)

source code 

Archive jobs.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain the job IDs to be archived
Returns: int
the desired exit code

AutoArchiveJobs(opts, args)

source code 

Archive jobs based on age.

This will archive jobs based on their age, or all jobs if a 'all' is passed.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the age as a time spec that can be parsed by ganeti.cli.ParseTimespec or the keyword all, which will cause all jobs to be archived
Returns: int
the desired exit code

CancelJobs(opts, args)

source code 

Cancel not-yet-started jobs.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain the job IDs to be cancelled
Returns: int
the desired exit code

ShowJobs(opts, args)

source code 

Show detailed information about jobs.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - should contain the job IDs to be queried
Returns: int
the desired exit code

WatchJob(opts, args)

source code 

Follow a job and print its output as it arrives.

Parameters:
  • opts - the command line options selected by the user
  • args (list) - Contains the job ID
Returns: int
the desired exit code

Variables Details [hide private]

_USER_JOB_STATUS

map converting the job status contants to user-visible names

Value:
{constants.JOB_STATUS_QUEUED: "queued", constants.JOB_STATUS_WAITING: \
"waiting", constants.JOB_STATUS_CANCELING: "canceling", constants.JOB_\
STATUS_RUNNING: "running", constants.JOB_STATUS_CANCELED: "canceled", \
constants.JOB_STATUS_SUCCESS: "success", constants.JOB_STATUS_ERROR: "\
error",}

_PENDING_OPT

Value:
cli_option("--pending", default= None, action= "store_const", dest= "s\
tatus_filter", const= frozenset([constants.JOB_STATUS_QUEUED, constant\
s.JOB_STATUS_WAITING,]), help= "Show only jobs pending execution")

_RUNNING_OPT

Value:
cli_option("--running", default= None, action= "store_const", dest= "s\
tatus_filter", const= frozenset([constants.JOB_STATUS_RUNNING,]), help\
= "Show jobs currently running only")

_ERROR_OPT

Value:
cli_option("--error", default= None, action= "store_const", dest= "sta\
tus_filter", const= frozenset([constants.JOB_STATUS_ERROR,]), help= "S\
how failed jobs only")

_FINISHED_OPT

Value:
cli_option("--finished", default= None, action= "store_const", dest= "\
status_filter", const= constants.JOBS_FINALIZED, help= "Show finished \
jobs only")

commands

Value:
{"list":(ListJobs, [ArgJobId()], [NOHDR_OPT, SEP_OPT, FIELDS_OPT, VERB\
OSE_OPT, FORCE_FILTER_OPT, _PENDING_OPT, _RUNNING_OPT, _ERROR_OPT, _FI\
NISHED_OPT], "[job_id ...]", "Lists the jobs and their status. The ava\
ilable fields can be shown" " using the \"list-fields\" command (see t\
he man page for details)." " The default field list is (in order): %s.\
" % utils.CommaJoin(_LIST_DEF_FIELDS)), "list-fields":(ListJobFields, \
[ArgUnknown()], [NOHDR_OPT, SEP_OPT], "[fields...]", "Lists all availa\
ble fields for jobs"), "archive":(ArchiveJobs, [ArgJobId(min= 1)], [],\
...