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
 
_FormatSummary(value)
Formats a job's summary.
source code
 
_ParseJobIds(args)
Parses a list of string job IDs into integers.
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
_MultiJobAction(opts, args, cl, stdout_fn, ask_fn, question, action_fn)
Applies a function to multipe jobs.
source code
int
CancelJobs(opts, args, cl=None, _stdout_fn=ToStdout, _ask_fn=AskUser)
Cancel not-yet-started jobs.
source code
int
ChangePriority(opts, args)
Change priority of 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
int
WaitJob(opts, args)
Wait for a job to finish, not producing any output.
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
  _JOB_LIST_FORMAT = {"status":(_FormatStatus, False), "summary"...
  _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...
  _ARCHIVED_OPT = cli_option("--archived", default= False, actio...
  _QUEUED_OPT = cli_option("--queued", default= None, action= "s...
  _WAITING_OPT = cli_option("--waiting", default= None, action= ...
  commands = {"list":(ListJobs, [ArgJobId()], [NOHDR_OPT, SEP_OP...
  aliases = {"show": "info",}
dictionary with aliases for commands

Imports: ARGS_ONE_INSTANCE, POWER_DELAY_OPT, NEW_RAPI_CERT_OPT, OOB_TIMEOUT_OPT, TO_GROUP_OPT, MAC_PREFIX_OPT, IPOLICY_STD_SPECS_OPT, CONFIRM_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT, ParseFields, PRIMARY_IP_VERSION_OPT, ARGS_NONE, ARGS_ONE_GROUP, ARGS_MANY_NODES, UsesRPC, ALLOC_POLICY_OPT, NEW_NODE_CERT_OPT, NOVOTING_OPT, INSTANCE_POLICY_OPTS, ArgUnknown, ERROR_CODES_OPT, SPECS_CPU_COUNT_OPT, SPECS_DISK_SIZE_OPT, SECONDARY_IP_OPT, ARGS_ONE_NETWORK, GATEWAY_OPT, REMOVE_INSTANCE_OPT, RQL_OPT, IPOLICY_DISK_TEMPLATES, FormatTimestamp, GenerateTable, ABSOLUTE_OPT, DEFAULT_IALLOCATOR_PARAMS_OPT, IGNORE_SIZE_OPT, COMMON_CREATE_OPTS, READD_OPT, NO_REMEMBER_OPT, SUBMIT_OPTS, ConfirmOperation, SubmitOrSend, RAPI_CERT_OPT, ROMAN_OPT, HV_STATE_OPT, HOTPLUG_IF_POSSIBLE_OPT, ARGS_MANY_NETWORKS, FILESTORE_DIR_OPT, RUNTIME_MEM_OPT, SEP_OPT, RESERVED_LVS_OPT, USE_EXTERNAL_MIP_SCRIPT, GLOBAL_SHARED_FILEDIR_OPT, FormatPolicyInfo, NOMODIFY_SSH_SETUP_OPT, GenericInstanceCreate, SubmitOpCodeToDrainedQueue, ArgChoice, ENABLED_USER_SHUTDOWN_OPT, TRANSPORT_COMPRESSION_OPT, NODE_FORCE_JOIN_OPT, DRY_RUN_OPT, CAPAB_VM_OPT, NODE_POWERED_OPT, NODE_PLACEMENT_OPT, JobExecutor, FixHvParams, ToStderr, SELECT_OS_OPT, SINGLE_NODE_OPT, ArgExtStorage, ArgOs, SPICE_CACERT_OPT, PrintIPolicyCommand, IGNORE_ERRORS_OPT, AUTO_REPLACE_OPT, HVLIST_OPT, cli_option, AskUser, ENABLED_DISK_TEMPLATES_OPT, DISK_STATE_OPT, USEUNITS_OPT, EARLY_RELEASE_OPT, VERBOSE_OPT, ArgHost, UIDPOOL_OPT, ALL_OPT, HOTPLUG_OPT, CalculateOSNames, OS_OPT, OFFLINE_OPT, ARGS_ONE_NODE, ArgCommand, FAILURE_ONLY_OPT, ALLOW_FAILOVER_OPT, NOSTART_OPT, SPECS_NIC_COUNT_OPT, OS_SIZE_OPT, DEBUG_OPT, ON_PRIMARY_OPT, JobSubmittedException, SUBMIT_OPT, MASTER_NETMASK_OPT, SPICE_CERT_OPT, NEW_CLUSTER_CERT_OPT, INTERVAL_OPT, ToStdout, FORCE_FILTER_OPT, OSPARAMS_OPT, AddTags, NONICS_OPT, NODE_PARAMS_OPT, ArgNetwork, RunWhileClusterStopped, BLK_OS_OPT, GLOBAL_FILEDIR_OPT, SRC_NODE_OPT, CAPAB_MASTER_OPT, MODIFY_ETCHOSTS_OPT, GenericListFields, SPECS_MEM_SIZE_OPT, GetNodesSshPorts, TAG_SRC_OPT, NOSSH_KEYCHECK_OPT, NET_OPT, IGNORE_FAILURES_OPT, ADD_UIDS_OPT, MASTER_NETDEV_OPT, USE_REPL_NET_OPT, NODEGROUP_OPT, SRC_DIR_OPT, SYNC_OPT, IDENTIFY_DEFAULTS_OPT, REMOVE_UIDS_OPT, HYPERVISOR_OPT, IGNORE_IPOLICY_OPT, MC_OPT, ONLINE_INST_OPT, IGNORE_SECONDARIES_OPT, SplitNodeOption, REBOOT_TYPE_OPT, NONPLUS1_OPT, IGNORE_CONSIST_OPT, NOHDR_OPT, NEW_SPICE_CERT_OPT, TAG_ADD_OPT, SPECS_DISK_COUNT_OPT, NONLIVE_OPT, ARGS_ONE_OS, DISK_OPT, PRIMARY_ONLY_OPT, RemoveTags, AUTO_PROMOTE_OPT, ListTags, DEFAULT_IALLOCATOR_OPT, NEW_PRIMARY_OPT, FORCE_VARIANT_OPT, GetOnlineNodes, NETWORK_OPT, TIMEOUT_OPT, NODE_LIST_OPT, GenericList, ON_SECONDARY_OPT, FormatLogMessage, ArgInstance, CLEANUP_OPT, CreateIPolicyFromOpts, MIGRATION_MODE_OPT, NIC_PARAMS_OPT, NOIPCHECK_OPT, ArgJobId, SEQUENTIAL_OPT, DRBD_HELPER_OPT, DEBUG_SIMERR_OPT, STATIC_OPT, DISK_TEMPLATE_OPT, FORCE_FAILOVER_OPT, ARGS_MANY_GROUPS, REASON_OPT, NO_INSTALL_OPT, YES_DOIT_OPT, FORCE_OPT, PRINT_JOBID_OPT, SHOWCMD_OPT, SPLIT_ISPECS_OPTS, ArgGroup, OFFLINE_INST_OPT, NWSYNC_OPT, NOCONFLICTSCHECK_OPT, PRIORITY_OPT, SECONDARY_ONLY_OPT, NEW_CLUSTER_DOMAIN_SECRET_OPT, FormatParamsDictInfo, SubmitOpCode, DRAINED_OPT, ParseTimespec, REMOVE_RESERVED_IPS_OPT, GenericMain, ArgFile, WFSYNC_OPT, PrintGenericInfo, NORUNTIME_CHGS_OPT, ArgNode, IGNORE_REMOVE_FAILURES_OPT, CP_SIZE_OPT, ADD_RESERVED_IPS_OPT, CLUSTER_DOMAIN_SECRET_OPT, HID_OS_OPT, SHOW_MACHINE_OPT, GATEWAY6_OPT, ALLOCATABLE_OPT, ARGS_MANY_INSTANCES, PREALLOC_WIPE_DISKS_OPT, NONAMECHECK_OPT, FormatQueryResult, FormatError, COMPRESS_OPT, MAINTAIN_NODE_HEALTH_OPT, ArgSuggest, HVOPTS_OPT, IPOLICY_VCPU_RATIO, GetClient, NETWORK6_OPT, NOMODIFY_ETCHOSTS_OPT, ENABLED_HV_OPT, NEW_SECONDARY_OPT, IGNORE_OFFLINE_OPT, VG_NAME_OPT, DISK_PARAMS_OPT, FIELDS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT, DST_NODE_OPT, IALLOCATOR_OPT, NEW_CONFD_HMAC_KEY_OPT, FILESTORE_DRIVER_OPT, INCLUDEDEFAULTS_OPT, STARTUP_PAUSED_OPT, DISKIDX_OPT, BACKEND_OPT, constants, errors, utils, cli, qlang


Function Details [hide private]

_FormatSummary(value)

source code 

Formats a job's summary. Takes possible non-ascii encoding into account.

_ParseJobIds(args)

source code 

Parses a list of string job IDs into integers.

Parameters:
  • args - list of strings
Returns:
list of integers
Raises:

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

_MultiJobAction(opts, args, cl, stdout_fn, ask_fn, question, action_fn)

source code 

Applies a function to multipe jobs.

Parameters:
  • opts - Command line options
  • args (list) - Job IDs
Returns: int
Exit code

CancelJobs(opts, args, cl=None, _stdout_fn=ToStdout, _ask_fn=AskUser)

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

ChangePriority(opts, args)

source code 

Change priority of jobs.

Parameters:
  • opts - Command line options
  • args (list) - Job IDs
Returns: int
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

WaitJob(opts, args)

source code 

Wait for a job to finish, not producing any output.

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",}

_JOB_LIST_FORMAT

Value:
{"status":(_FormatStatus, False), "summary":(_FormatSummary, False),}

_PENDING_OPT

Value:
cli_option("--pending", default= None, action= "store_const", dest= "s\
tatus_filter", const= constants.JOBS_PENDING, help= "Select jobs pendi\
ng execution or being cancelled")

_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")

_ARCHIVED_OPT

Value:
cli_option("--archived", default= False, action= "store_true", dest= "\
archived", help= "Include archived jobs in list (slow and expensive)")

_QUEUED_OPT

Value:
cli_option("--queued", default= None, action= "store_const", dest= "st\
atus_filter", const= frozenset([constants.JOB_STATUS_QUEUED,]), help= \
"Select queued jobs only")

_WAITING_OPT

Value:
cli_option("--waiting", default= None, action= "store_const", dest= "s\
tatus_filter", const= frozenset([constants.JOB_STATUS_WAITING,]), help\
= "Select waiting 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, _ARCHIVED_OPT], "[job_id ...]", "Lists the jobs and their \
status. The available fields can be shown" " using the \"list-fields\"\
 command (see the 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...]", "L\
ists all available fields for jobs"), "archive":(ArchiveJobs, [ArgJobI\
...