Package ganeti :: Module cli
[hide private]
[frames] | no frames]

Module cli

source code

Module dealing with command line parsing

Classes [hide private]
  _Argument
  ArgSuggest
Suggesting argument.
  ArgChoice
Choice argument.
  ArgUnknown
Unknown argument to program (e.g.
  ArgInstance
Instances argument.
  ArgNode
Node argument.
  ArgJobId
Job ID argument.
  ArgFile
File path argument.
  ArgCommand
Command argument.
  ArgHost
Host argument.
  ArgOs
OS argument.
  CliOption
Custom option class for optparse.
  cli_option
Custom option class for optparse.
  JobSubmittedException
Job was submitted, client should exit.
  JobPollCbBase
Base class for GenericPollJob callbacks.
  JobPollReportCbBase
Base class for GenericPollJob reporting callbacks.
  _LuxiJobPollCb
  FeedbackFnJobPollReportCb
  StdioJobPollReportCb
  _RunWhileClusterStoppedHelper
Helper class for RunWhileClusterStopped to simplify state management
  JobExecutor
Class which manages the submission and execution of multiple jobs.
Functions [hide private]
 
_ExtractTagsObject(opts, args)
Extract the tag type object.
source code
 
_ExtendTags(opts, args)
Extend the args if a source file has been given.
source code
 
ListTags(opts, args)
List the tags on a given object.
source code
 
AddTags(opts, args)
Add tags on a given object.
source code
 
RemoveTags(opts, args)
Remove tags from a given object.
source code
 
check_unit(option, opt, value)
OptParsers custom converter for units.
source code
dict
_SplitKeyVal(opt, data)
Convert a KeyVal string into a dict.
source code
 
check_ident_key_val(option, opt, value)
Custom parser for ident:key=val,key=val options.
source code
 
check_key_val(option, opt, value)
Custom parser class for key=val,key=val options.
source code
 
check_bool(option, opt, value)
Custom parser for yes/no options.
source code
 
_ParseArgs(argv, commands, aliases)
Parser for the command line arguments.
source code
 
_CheckArguments(cmd, args_def, args)
Verifies the arguments using the argument definition.
source code
 
SplitNodeOption(value)
Splits the value of a --node option.
source code
list
CalculateOSNames(os_name, os_variants)
Calculates all the names an OS can be called, according to its variants.
source code
 
ParseFields(selected, default)
Parses the values of "--field"-like options.
source code
 
UsesRPC(fn)
RPC-wrapper decorator.
source code
 
AskUser(text, choices=None)
Ask the user a question.
source code
 
SendJob(ops, cl=None)
Function to submit an opcode without waiting for the results.
source code
 
GenericPollJob(job_id, cbs, report_cbs)
Generic job-polling function.
source code
 
FormatLogMessage(log_type, log_msg)
Formats a job message according to its type.
source code
 
PollJob(job_id, cl=None, feedback_fn=None, reporter=None)
Function to poll for the result of a job.
source code
 
SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None)
Legacy function to submit an opcode.
source code
 
SubmitOrSend(op, opts, cl=None, feedback_fn=None)
Wrapper around SubmitOpCode or SendJob.
source code
 
SetGenericOpcodeOpts(opcode_list, options)
Processor for generic options.
source code
 
GetClient() source code
 
FormatError(err)
Return a formatted error message for a given error.
source code
 
GenericMain(commands, override=None, aliases=None)
Generic main function for all the gnt-* commands.
source code
 
ParseNicOption(optvalue)
Parses the value of the --net option(s).
source code
int
GenericInstanceCreate(mode, opts, args)
Add an instance to the cluster via either creation or import.
source code
 
RunWhileClusterStopped(feedback_fn, fn, *args)
Calls a function while all cluster daemons are stopped.
source code
 
GenerateTable(headers, fields, separator, data, numfields=None, unitfields=None, units=None)
Prints a table with headers and different fields.
source code
string
FormatTimestamp(ts)
Formats a given timestamp.
source code
 
ParseTimespec(value)
Parse a time specification.
source code
 
GetOnlineNodes(nodes, cl=None, nowarn=False, secondary_ips=False, filter_master=False)
Returns the names of online nodes.
source code
 
_ToStream(stream, txt, *args)
Write a message to a stream, bypassing the logging system
source code
 
ToStdout(txt, *args)
Write a message to stdout only, bypassing the logging system
source code
 
ToStderr(txt, *args)
Write a message to stderr only, bypassing the logging system
source code
Variables [hide private]
  NO_PREFIX = "no_"
  UN_PREFIX = "-"
  _PRIORITY_NAMES = [("low", constants.OP_PRIO_LOW), ("normal", ...
Priorities (sorted)
  _PRIONAME_TO_VALUE = dict(_PRIORITY_NAMES)
Priority dictionary for easier lookup
  ARGS_NONE = []
  ARGS_MANY_INSTANCES = [ArgInstance()]
  ARGS_MANY_NODES = [ArgNode()]
  ARGS_ONE_INSTANCE = [ArgInstance(min= 1, max= 1)]
  ARGS_ONE_NODE = [ArgNode(min= 1, max= 1)]
  ARGS_ONE_OS = [ArgOs(min= 1, max= 1)]
  OPT_COMPL_ALL = frozenset([OPT_COMPL_MANY_NODES, OPT_COMPL_ONE...
  _YORNO = "yes|no"
  DEBUG_OPT = cli_option("-d", "--debug", default= 0, action= "c...
  NOHDR_OPT = cli_option("--no-headers", default= False, action=...
  SEP_OPT = cli_option("--separator", default= None, action= "st...
  USEUNITS_OPT = cli_option("--units", default= None, dest= "uni...
  FIELDS_OPT = cli_option("-o", "--output", dest= "output", acti...
  FORCE_OPT = cli_option("-f", "--force", dest= "force", action=...
  CONFIRM_OPT = cli_option("--yes", dest= "confirm", action= "st...
  IGNORE_OFFLINE_OPT = cli_option("--ignore-offline", dest= "ign...
  TAG_SRC_OPT = cli_option("--from", dest= "tags_source", defaul...
  SUBMIT_OPT = cli_option("--submit", dest= "submit_only", defau...
  SYNC_OPT = cli_option("--sync", dest= "do_locking", default= F...
  DRY_RUN_OPT = cli_option("--dry-run", default= False, action= ...
  VERBOSE_OPT = cli_option("-v", "--verbose", default= False, ac...
  DEBUG_SIMERR_OPT = cli_option("--debug-simulate-errors", defau...
  NWSYNC_OPT = cli_option("--no-wait-for-sync", dest= "wait_for_...
  DISK_TEMPLATE_OPT = cli_option("-t", "--disk-template", dest= ...
  NONICS_OPT = cli_option("--no-nics", default= False, action= "...
  FILESTORE_DIR_OPT = cli_option("--file-storage-dir", dest= "fi...
  FILESTORE_DRIVER_OPT = cli_option("--file-driver", dest= "file...
  IALLOCATOR_OPT = cli_option("-I", "--iallocator", metavar= "<N...
  DEFAULT_IALLOCATOR_OPT = cli_option("-I", "--default-iallocato...
  OS_OPT = cli_option("-o", "--os-type", dest= "os", help= "What...
  OSPARAMS_OPT = cli_option("-O", "--os-parameters", dest= "ospa...
  FORCE_VARIANT_OPT = cli_option("--force-variant", dest= "force...
  NO_INSTALL_OPT = cli_option("--no-install", dest= "no_install"...
  BACKEND_OPT = cli_option("-B", "--backend-parameters", dest= "...
  HVOPTS_OPT = cli_option("-H", "--hypervisor-parameters", type=...
  HYPERVISOR_OPT = cli_option("-H", "--hypervisor-parameters", d...
  HVLIST_OPT = cli_option("-H", "--hypervisor-parameters", dest=...
  NOIPCHECK_OPT = cli_option("--no-ip-check", dest= "ip_check", ...
  NONAMECHECK_OPT = cli_option("--no-name-check", dest= "name_ch...
  NET_OPT = cli_option("--net", help= "NIC parameters", default=...
  DISK_OPT = cli_option("--disk", help= "Disk parameters", defau...
  DISKIDX_OPT = cli_option("--disks", dest= "disks", default= No...
  OS_SIZE_OPT = cli_option("-s", "--os-size", dest= "sd_size", h...
  IGNORE_CONSIST_OPT = cli_option("--ignore-consistency", dest= ...
  NONLIVE_OPT = cli_option("--non-live", dest= "live", default= ...
  MIGRATION_MODE_OPT = cli_option("--migration-mode", dest= "mig...
  NODE_PLACEMENT_OPT = cli_option("-n", "--node", dest= "node", ...
  NODE_LIST_OPT = cli_option("-n", "--node", dest= "nodes", defa...
  NODEGROUP_OPT = cli_option("-g", "--node-group", dest= "nodegr...
  SINGLE_NODE_OPT = cli_option("-n", "--node", dest= "node", hel...
  NOSTART_OPT = cli_option("--no-start", dest= "start", default=...
  SHOWCMD_OPT = cli_option("--show-cmd", dest= "show_command", a...
  CLEANUP_OPT = cli_option("--cleanup", dest= "cleanup", default...
  STATIC_OPT = cli_option("-s", "--static", dest= "static", acti...
  ALL_OPT = cli_option("--all", dest= "show_all", default= False...
  SELECT_OS_OPT = cli_option("--select-os", dest= "select_os", a...
  IGNORE_FAILURES_OPT = cli_option("--ignore-failures", dest= "i...
  IGNORE_REMOVE_FAILURES_OPT = cli_option("--ignore-remove-failu...
  REMOVE_INSTANCE_OPT = cli_option("--remove-instance", dest= "r...
  NEW_SECONDARY_OPT = cli_option("-n", "--new-secondary", dest= ...
  ON_PRIMARY_OPT = cli_option("-p", "--on-primary", dest= "on_pr...
  ON_SECONDARY_OPT = cli_option("-s", "--on-secondary", dest= "o...
  AUTO_PROMOTE_OPT = cli_option("--auto-promote", dest= "auto_pr...
  AUTO_REPLACE_OPT = cli_option("-a", "--auto", dest= "auto", de...
  IGNORE_SIZE_OPT = cli_option("--ignore-size", dest= "ignore_si...
  SRC_NODE_OPT = cli_option("--src-node", dest= "src_node", help...
  SRC_DIR_OPT = cli_option("--src-dir", dest= "src_dir", help= "...
  SECONDARY_IP_OPT = cli_option("-s", "--secondary-ip", dest= "s...
  READD_OPT = cli_option("--readd", dest= "readd", default= Fals...
  NOSSH_KEYCHECK_OPT = cli_option("--no-ssh-key-check", dest= "s...
  MC_OPT = cli_option("-C", "--master-candidate", dest= "master_...
  OFFLINE_OPT = cli_option("-O", "--offline", dest= "offline", m...
  DRAINED_OPT = cli_option("-D", "--drained", dest= "drained", m...
  CAPAB_MASTER_OPT = cli_option("--master-capable", dest= "maste...
  CAPAB_VM_OPT = cli_option("--vm-capable", dest= "vm_capable", ...
  ALLOCATABLE_OPT = cli_option("--allocatable", dest= "allocatab...
  NOLVM_STORAGE_OPT = cli_option("--no-lvm-storage", dest= "lvm_...
  ENABLED_HV_OPT = cli_option("--enabled-hypervisors", dest= "en...
  NIC_PARAMS_OPT = cli_option("-N", "--nic-parameters", dest= "n...
  CP_SIZE_OPT = cli_option("-C", "--candidate-pool-size", defaul...
  VG_NAME_OPT = cli_option("--vg-name", dest= "vg_name", help= "...
  YES_DOIT_OPT = cli_option("--yes-do-it", dest= "yes_do_it", he...
  NOVOTING_OPT = cli_option("--no-voting", dest= "no_voting", he...
  MAC_PREFIX_OPT = cli_option("-m", "--mac-prefix", dest= "mac_p...
  MASTER_NETDEV_OPT = cli_option("--master-netdev", dest= "maste...
  GLOBAL_FILEDIR_OPT = cli_option("--file-storage-dir", dest= "f...
  NOMODIFY_ETCHOSTS_OPT = cli_option("--no-etc-hosts", dest= "mo...
  NOMODIFY_SSH_SETUP_OPT = cli_option("--no-ssh-init", dest= "mo...
  ERROR_CODES_OPT = cli_option("--error-codes", dest= "error_cod...
  NONPLUS1_OPT = cli_option("--no-nplus1-mem", dest= "skip_nplus...
  REBOOT_TYPE_OPT = cli_option("-t", "--type", dest= "reboot_typ...
  IGNORE_SECONDARIES_OPT = cli_option("--ignore-secondaries", de...
  NOSHUTDOWN_OPT = cli_option("--noshutdown", dest= "shutdown", ...
  TIMEOUT_OPT = cli_option("--timeout", dest= "timeout", type= "...
  SHUTDOWN_TIMEOUT_OPT = cli_option("--shutdown-timeout", dest= ...
  INTERVAL_OPT = cli_option("--interval", dest= "interval", type...
  EARLY_RELEASE_OPT = cli_option("--early-release", dest= "early...
  NEW_CLUSTER_CERT_OPT = cli_option("--new-cluster-certificate",...
  RAPI_CERT_OPT = cli_option("--rapi-certificate", dest= "rapi_c...
  NEW_RAPI_CERT_OPT = cli_option("--new-rapi-certificate", dest=...
  NEW_CONFD_HMAC_KEY_OPT = cli_option("--new-confd-hmac-key", de...
  CLUSTER_DOMAIN_SECRET_OPT = cli_option("--cluster-domain-secre...
  NEW_CLUSTER_DOMAIN_SECRET_OPT = cli_option("--new-cluster-doma...
  USE_REPL_NET_OPT = cli_option("--use-replication-network", des...
  MAINTAIN_NODE_HEALTH_OPT = cli_option("--maintain-node-health"...
  IDENTIFY_DEFAULTS_OPT = cli_option("--identify-defaults", dest...
  UIDPOOL_OPT = cli_option("--uid-pool", default= None, action= ...
  ADD_UIDS_OPT = cli_option("--add-uids", default= None, action=...
  REMOVE_UIDS_OPT = cli_option("--remove-uids", default= None, a...
  RESERVED_LVS_OPT = cli_option("--reserved-lvs", default= None,...
  ROMAN_OPT = cli_option("--roman", dest= "roman_integers", defa...
  DRBD_HELPER_OPT = cli_option("--drbd-usermode-helper", dest= "...
  NODRBD_STORAGE_OPT = cli_option("--no-drbd-storage", dest= "dr...
  PRIMARY_IP_VERSION_OPT = cli_option("--primary-ip-version", de...
  PRIORITY_OPT = cli_option("--priority", default= None, dest= "...
  HID_OS_OPT = cli_option("--hidden", dest= "hidden", type= "boo...
  BLK_OS_OPT = cli_option("--blacklisted", dest= "blacklisted", ...
  PREALLOC_WIPE_DISKS_OPT = cli_option("--prealloc-wipe-disks", ...
  COMMON_OPTS = [DEBUG_OPT]
Options provided by all commands
  COMMON_CREATE_OPTS = [BACKEND_OPT, DISK_OPT, DISK_TEMPLATE_OPT...

Imports: sys, textwrap, os, time, logging, StringIO, utils, errors, constants, opcodes, luxi, ssconf, rpc, ssh, compat, netutils, OptionParser, TitledHelpFormatter, Option, OptionValueError


Function Details [hide private]

_ExtractTagsObject(opts, args)

source code 

Extract the tag type object.

Note that this function will modify its args parameter.

_ExtendTags(opts, args)

source code 

Extend the args if a source file has been given.

This function will extend the tags with the contents of the file passed in the 'tags_source' attribute of the opts parameter. A file named '-' will be replaced by stdin.

ListTags(opts, args)

source code 

List the tags on a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

AddTags(opts, args)

source code 

Add tags on a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

RemoveTags(opts, args)

source code 

Remove tags from a given object.

This is a generic implementation that knows how to deal with all three cases of tag objects (cluster, node, instance). The opts argument is expected to contain a tag_type field denoting what object type we work on.

_SplitKeyVal(opt, data)

source code 

Convert a KeyVal string into a dict.

This function will convert a key=val[,...] string into a dict. Empty values will be converted specially: keys which have the prefix 'no_' will have the value=False and the prefix stripped, the others will have value=True.

Parameters:
  • opt (string) - a string holding the option name for which we process the data, used in building error messages
  • data (string) - a string of the format key=val,key=val,...
Returns: dict
{key=val, key=val}
Raises:

check_ident_key_val(option, opt, value)

source code 

Custom parser for ident:key=val,key=val options.

This will store the parsed values as a tuple (ident, {key: val}). As such, multiple uses of this option via action=append is possible.

check_key_val(option, opt, value)

source code 

Custom parser class for key=val,key=val options.

This will store the parsed values as a dict {key: val}.

check_bool(option, opt, value)

source code 

Custom parser for yes/no options.

This will store the parsed value as either True or False.

_ParseArgs(argv, commands, aliases)

source code 

Parser for the command line arguments.

This function parses the arguments and returns the function which must be executed together with its (modified) arguments.

Parameters:
  • argv - the command line
  • commands - dictionary with special contents, see the design doc for cmdline handling
  • aliases - dictionary with command aliases {'alias': 'target, ...}

_CheckArguments(cmd, args_def, args)

source code 

Verifies the arguments using the argument definition.

Algorithm:

  1. Abort with error if values specified by user but none expected.
  1. For each argument in definition
    1. Keep running count of minimum number of values (min_count)
    1. Keep running count of maximum number of values (max_count)
    1. If it has an unlimited number of values
      1. Abort with error if it's not the last argument in the definition
  1. If last argument has limited number of values
    1. Abort with error if number of values doesn't match or is too large
  1. Abort with error if user didn't pass enough values (min_count)

CalculateOSNames(os_name, os_variants)

source code 

Calculates all the names an OS can be called, according to its variants.

Parameters:
  • os_name (string) - base name of the os
  • os_variants (list or None) - list of supported variants
Returns: list
list of valid names

ParseFields(selected, default)

source code 

Parses the values of "--field"-like options.

Parameters:
  • selected (string or None) - User-selected options
  • default (list) - Default fields

UsesRPC(fn)

source code 

RPC-wrapper decorator.

When applied to a function, it runs it with the RPC system initialized, and it shutsdown the system afterwards. This means the function must be called without RPC being initialized.

AskUser(text, choices=None)

source code 

Ask the user a question.

Parameters:
  • text - the question to ask
  • choices - list with elements tuples (input_char, return_value, description); if not given, it will default to: [('y', True, 'Perform the operation'), ('n', False, 'Do no do the operation')]; note that the '?' char is reserved for help
Returns:
one of the return values from the choices list; if input is not possible (i.e. not running with a tty, we return the last entry from the list

SendJob(ops, cl=None)

source code 

Function to submit an opcode without waiting for the results.

Parameters:
  • ops (list) - list of opcodes
  • cl (luxi.Client) - the luxi client to use for communicating with the master; if None, a new client will be created

GenericPollJob(job_id, cbs, report_cbs)

source code 

Generic job-polling function.

Parameters:

PollJob(job_id, cl=None, feedback_fn=None, reporter=None)

source code 

Function to poll for the result of a job.

Parameters:
  • job_id (job identified) - the job to poll for results
  • cl (luxi.Client) - the luxi client to use for communicating with the master; if None, a new client will be created

SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None)

source code 

Legacy function to submit an opcode.

This is just a simple wrapper over the construction of the processor instance. It should be extended to better handle feedback and interaction functions.

SubmitOrSend(op, opts, cl=None, feedback_fn=None)

source code 

Wrapper around SubmitOpCode or SendJob.

This function will decide, based on the 'opts' parameter, whether to submit and wait for the result of the opcode (and return it), or whether to just send the job and print its identifier. It is used in order to simplify the implementation of the '--submit' option.

It will also process the opcodes if we're sending the via SendJob (otherwise SubmitOpCode does it).

SetGenericOpcodeOpts(opcode_list, options)

source code 

Processor for generic options.

This function updates the given opcodes based on generic command line options (like debug, dry-run, etc.).

Parameters:
  • opcode_list - list of opcodes
  • options - command line options or None
Returns:
None (in-place modification)

FormatError(err)

source code 

Return a formatted error message for a given error.

This function takes an exception instance and returns a tuple consisting of two values: first, the recommended exit code, and second, a string describing the error message (not newline-terminated).

GenericMain(commands, override=None, aliases=None)

source code 

Generic main function for all the gnt-* commands.

Arguments:

  • commands: a dictionary with a special structure, see the design doc for command line handling.
  • override: if not None, we expect a dictionary with keys that will override command line options; this can be used to pass options from the scripts to generic functions
  • aliases: dictionary with command aliases {'alias': 'target, ...}

GenericInstanceCreate(mode, opts, args)

source code 

Add an instance to the cluster via either creation or import.

Parameters:
  • mode - constants.INSTANCE_CREATE or constants.INSTANCE_IMPORT
  • opts - the command line options selected by the user
  • args (list) - should contain only one element, the new instance name
Returns: int
the desired exit code

RunWhileClusterStopped(feedback_fn, fn, *args)

source code 

Calls a function while all cluster daemons are stopped.

Parameters:
  • feedback_fn (callable) - Feedback function
  • fn (callable) - Function to be called when daemons are stopped

GenerateTable(headers, fields, separator, data, numfields=None, unitfields=None, units=None)

source code 

Prints a table with headers and different fields.

Parameters:
  • headers (dict) - dictionary mapping field names to headers for the table
  • fields (list) - the field names corresponding to each row in the data field
  • separator - the separator to be used; if this is None, the default 'smart' algorithm is used which computes optimal field width, otherwise just the separator is used between each field
  • data (list) - a list of lists, each sublist being one row to be output
  • numfields (list) - a list with the fields that hold numeric values and thus should be right-aligned
  • unitfields (list) - a list with the fields that hold numeric values that should be formatted with the units field
  • units (string or None) - the units we should use for formatting, or None for automatic choice (human-readable for non-separator usage, otherwise megabytes); this is a one-letter string

FormatTimestamp(ts)

source code 

Formats a given timestamp.

Parameters:
  • ts (timestamp) - a timeval-type timestamp, a tuple of seconds and microseconds
Returns: string
a string with the formatted timestamp

ParseTimespec(value)

source code 

Parse a time specification.

The following suffixed will be recognized:

  • s: seconds
  • m: minutes
  • h: hours
  • d: day
  • w: weeks

Without any suffix, the value will be taken to be in seconds.

GetOnlineNodes(nodes, cl=None, nowarn=False, secondary_ips=False, filter_master=False)

source code 

Returns the names of online nodes.

This function will also log a warning on stderr with the names of the online nodes.

Parameters:
  • nodes - if not empty, use only this subset of nodes (minus the offline ones)
  • cl - if not None, luxi client to use
  • nowarn (boolean) - by default, this function will output a note with the offline nodes that are skipped; if this parameter is True the note is not displayed
  • secondary_ips (boolean) - if True, return the secondary IPs instead of the names, useful for doing network traffic over the replication interface (if any)
  • filter_master (boolean) - if True, do not return the master node in the list (useful in coordination with secondary_ips where we cannot check our node name against the list)

_ToStream(stream, txt, *args)

source code 

Write a message to a stream, bypassing the logging system

Parameters:
  • stream (file object) - the file to which we should write
  • txt (str) - the message

ToStdout(txt, *args)

source code 

Write a message to stdout only, bypassing the logging system

This is just a wrapper over _ToStream.

Parameters:
  • txt (str) - the message

ToStderr(txt, *args)

source code 

Write a message to stderr only, bypassing the logging system

This is just a wrapper over _ToStream.

Parameters:
  • txt (str) - the message

Variables Details [hide private]

_PRIORITY_NAMES

Priorities (sorted)

Value:
[("low", constants.OP_PRIO_LOW), ("normal", constants.OP_PRIO_NORMAL),\
 ("high", constants.OP_PRIO_HIGH),]

OPT_COMPL_ALL

Value:
frozenset([OPT_COMPL_MANY_NODES, OPT_COMPL_ONE_NODE, OPT_COMPL_ONE_INS\
TANCE, OPT_COMPL_ONE_OS, OPT_COMPL_ONE_IALLOCATOR, OPT_COMPL_INST_ADD_\
NODES, OPT_COMPL_ONE_NODEGROUP,])

DEBUG_OPT

Value:
cli_option("-d", "--debug", default= 0, action= "count", help= "Increa\
se debugging level")

NOHDR_OPT

Value:
cli_option("--no-headers", default= False, action= "store_true", dest=\
 "no_headers", help= "Don't display column headers")

SEP_OPT

Value:
cli_option("--separator", default= None, action= "store", dest= "separ\
ator", help= ("Separator between output fields" " (defaults to one spa\
ce)"))

USEUNITS_OPT

Value:
cli_option("--units", default= None, dest= "units", choices= ('h', 'm'\
, 'g', 't'), help= "Specify units for output (one of hmgt)")

FIELDS_OPT

Value:
cli_option("-o", "--output", dest= "output", action= "store", type= "s\
tring", metavar= "FIELDS", help= "Comma separated list of output field\
s")

FORCE_OPT

Value:
cli_option("-f", "--force", dest= "force", action= "store_true", defau\
lt= False, help= "Force the operation")

CONFIRM_OPT

Value:
cli_option("--yes", dest= "confirm", action= "store_true", default= Fa\
lse, help= "Do not require confirmation")

IGNORE_OFFLINE_OPT

Value:
cli_option("--ignore-offline", dest= "ignore_offline", action= "store_\
true", default= False, help= ("Ignore offline nodes and do as much" " \
as possible"))

TAG_SRC_OPT

Value:
cli_option("--from", dest= "tags_source", default= None, help= "File w\
ith tag names")

SUBMIT_OPT

Value:
cli_option("--submit", dest= "submit_only", default= False, action= "s\
tore_true", help= ("Submit the job and return the job ID, but" " don't\
 wait for the job to finish"))

SYNC_OPT

Value:
cli_option("--sync", dest= "do_locking", default= False, action= "stor\
e_true", help= ("Grab locks while doing the queries" " in order to ens\
ure more consistent results"))

DRY_RUN_OPT

Value:
cli_option("--dry-run", default= False, action= "store_true", help= ("\
Do not execute the operation, just run the" " check steps and verify i\
t it could be" " executed"))

VERBOSE_OPT

Value:
cli_option("-v", "--verbose", default= False, action= "store_true", he\
lp= "Increase the verbosity of the operation")

DEBUG_SIMERR_OPT

Value:
cli_option("--debug-simulate-errors", default= False, action= "store_t\
rue", dest= "simulate_errors", help= "Debugging option that makes the \
operation" " treat most runtime checks as failed")

NWSYNC_OPT

Value:
cli_option("--no-wait-for-sync", dest= "wait_for_sync", default= True,\
 action= "store_false", help= "Don't wait for sync (DANGEROUS!)")

DISK_TEMPLATE_OPT

Value:
cli_option("-t", "--disk-template", dest= "disk_template", help= "Cust\
om disk setup (diskless, file," " plain or drbd)", default= None, meta\
var= "TEMPL", choices= list(constants.DISK_TEMPLATES))

NONICS_OPT

Value:
cli_option("--no-nics", default= False, action= "store_true", help= "D\
o not create any network cards for" " the instance")

FILESTORE_DIR_OPT

Value:
cli_option("--file-storage-dir", dest= "file_storage_dir", help= "Rela\
tive path under default cluster-wide" " file storage dir to store file\
-based disks", default= None, metavar= "<DIR>")

FILESTORE_DRIVER_OPT

Value:
cli_option("--file-driver", dest= "file_driver", help= "Driver to use \
for image files", default= "loop", metavar= "<DRIVER>", choices= list(\
constants.FILE_DRIVER))

IALLOCATOR_OPT

Value:
cli_option("-I", "--iallocator", metavar= "<NAME>", help= "Select node\
s for the instance automatically" " using the <NAME> iallocator plugin\
", default= None, type= "string", completion_suggest= OPT_COMPL_ONE_IA\
LLOCATOR)

DEFAULT_IALLOCATOR_OPT

Value:
cli_option("-I", "--default-iallocator", metavar= "<NAME>", help= "Set\
 the default instance allocator plugin", default= None, type= "string"\
, completion_suggest= OPT_COMPL_ONE_IALLOCATOR)

OS_OPT

Value:
cli_option("-o", "--os-type", dest= "os", help= "What OS to run", meta\
var= "<os>", completion_suggest= OPT_COMPL_ONE_OS)

OSPARAMS_OPT

Value:
cli_option("-O", "--os-parameters", dest= "osparams", type= "keyval", \
default= {}, help= "OS parameters")

FORCE_VARIANT_OPT

Value:
cli_option("--force-variant", dest= "force_variant", action= "store_tr\
ue", default= False, help= "Force an unknown variant")

NO_INSTALL_OPT

Value:
cli_option("--no-install", dest= "no_install", action= "store_true", d\
efault= False, help= "Do not install the OS (will" " enable no-start)"\
)

BACKEND_OPT

Value:
cli_option("-B", "--backend-parameters", dest= "beparams", type= "keyv\
al", default= {}, help= "Backend parameters")

HVOPTS_OPT

Value:
cli_option("-H", "--hypervisor-parameters", type= "keyval", default= {\
}, dest= "hvparams", help= "Hypervisor parameters")

HYPERVISOR_OPT

Value:
cli_option("-H", "--hypervisor-parameters", dest= "hypervisor", help= \
"Hypervisor and hypervisor options, in the" " format hypervisor:option\
=value,option=value,...", default= None, type= "identkeyval")

HVLIST_OPT

Value:
cli_option("-H", "--hypervisor-parameters", dest= "hvparams", help= "H\
ypervisor and hypervisor options, in the" " format hypervisor:option=v\
alue,option=value,...", default= [], action= "append", type= "identkey\
val")

NOIPCHECK_OPT

Value:
cli_option("--no-ip-check", dest= "ip_check", default= True, action= "\
store_false", help= "Don't check that the instance's IP" " is alive")

NONAMECHECK_OPT

Value:
cli_option("--no-name-check", dest= "name_check", default= True, actio\
n= "store_false", help= "Don't check that the instance's name" " is re\
solvable")

NET_OPT

Value:
cli_option("--net", help= "NIC parameters", default= [], dest= "nics",\
 action= "append", type= "identkeyval")

DISK_OPT

Value:
cli_option("--disk", help= "Disk parameters", default= [], dest= "disk\
s", action= "append", type= "identkeyval")

DISKIDX_OPT

Value:
cli_option("--disks", dest= "disks", default= None, help= "Comma-separ\
ated list of disks" " indices to act on (e.g. 0,2) (optional," " defau\
lts to all disks)")

OS_SIZE_OPT

Value:
cli_option("-s", "--os-size", dest= "sd_size", help= "Enforces a singl\
e-disk configuration using the" " given disk size, in MiB unless a suf\
fix is used", default= None, type= "unit", metavar= "<size>")

IGNORE_CONSIST_OPT

Value:
cli_option("--ignore-consistency", dest= "ignore_consistency", action=\
 "store_true", default= False, help= "Ignore the consistency of the di\
sks on" " the secondary")

NONLIVE_OPT

Value:
cli_option("--non-live", dest= "live", default= True, action= "store_f\
alse", help= "Do a non-live migration (this usually means" " freeze th\
e instance, save the state, transfer and" " only then resume running o\
n the secondary node)")

MIGRATION_MODE_OPT

Value:
cli_option("--migration-mode", dest= "migration_mode", default= None, \
choices= list(constants.HT_MIGRATION_MODES), help= "Override default m\
igration mode (choose" " either live or non-live")

NODE_PLACEMENT_OPT

Value:
cli_option("-n", "--node", dest= "node", help= "Target node and option\
al secondary node", metavar= "<pnode>[:<snode>]", completion_suggest= \
OPT_COMPL_INST_ADD_NODES)

NODE_LIST_OPT

Value:
cli_option("-n", "--node", dest= "nodes", default= [], action= "append\
", metavar= "<node>", help= "Use only this node (can be used multiple"\
 " times, if not given defaults to all nodes)", completion_suggest= OP\
T_COMPL_ONE_NODE)

NODEGROUP_OPT

Value:
cli_option("-g", "--node-group", dest= "nodegroup", help= "Node group \
(name or uuid)", metavar= "<nodegroup>", default= None, type= "string"\
, completion_suggest= OPT_COMPL_ONE_NODEGROUP)

SINGLE_NODE_OPT

Value:
cli_option("-n", "--node", dest= "node", help= "Target node", metavar=\
 "<node>", completion_suggest= OPT_COMPL_ONE_NODE)

NOSTART_OPT

Value:
cli_option("--no-start", dest= "start", default= True, action= "store_\
false", help= "Don't start the instance after creation")

SHOWCMD_OPT

Value:
cli_option("--show-cmd", dest= "show_command", action= "store_true", d\
efault= False, help= "Show command instead of executing it")

CLEANUP_OPT

Value:
cli_option("--cleanup", dest= "cleanup", default= False, action= "stor\
e_true", help= "Instead of performing the migration, try to" " recover\
 from a failed cleanup. This is safe" " to run even if the instance is\
 healthy, but it" " will create extra replication traffic and " " disr\
upt briefly the replication (like during the" " migration")

STATIC_OPT

Value:
cli_option("-s", "--static", dest= "static", action= "store_true", def\
ault= False, help= "Only show configuration data, not runtime data")

ALL_OPT

Value:
cli_option("--all", dest= "show_all", default= False, action= "store_t\
rue", help= "Show info on all instances on the cluster." " This can ta\
ke a long time to run, use wisely")

SELECT_OS_OPT

Value:
cli_option("--select-os", dest= "select_os", action= "store_true", def\
ault= False, help= "Interactive OS reinstall, lists available" " OS te\
mplates for selection")

IGNORE_FAILURES_OPT

Value:
cli_option("--ignore-failures", dest= "ignore_failures", action= "stor\
e_true", default= False, help= "Remove the instance from the cluster" \
" configuration even if there are failures" " during the removal proce\
ss")

IGNORE_REMOVE_FAILURES_OPT

Value:
cli_option("--ignore-remove-failures", dest= "ignore_remove_failures",\
 action= "store_true", default= False, help= "Remove the instance from\
 the" " cluster configuration even if there" " are failures during the\
 removal" " process")

REMOVE_INSTANCE_OPT

Value:
cli_option("--remove-instance", dest= "remove_instance", action= "stor\
e_true", default= False, help= "Remove the instance from the cluster")

NEW_SECONDARY_OPT

Value:
cli_option("-n", "--new-secondary", dest= "dst_node", help= "Specifies\
 the new secondary node", metavar= "NODE", default= None, completion_s\
uggest= OPT_COMPL_ONE_NODE)

ON_PRIMARY_OPT

Value:
cli_option("-p", "--on-primary", dest= "on_primary", default= False, a\
ction= "store_true", help= "Replace the disk(s) on the primary" " node\
 (only for the drbd template)")

ON_SECONDARY_OPT

Value:
cli_option("-s", "--on-secondary", dest= "on_secondary", default= Fals\
e, action= "store_true", help= "Replace the disk(s) on the secondary" \
" node (only for the drbd template)")

AUTO_PROMOTE_OPT

Value:
cli_option("--auto-promote", dest= "auto_promote", default= False, act\
ion= "store_true", help= "Lock all nodes and auto-promote as needed" "\
 to MC status")

AUTO_REPLACE_OPT

Value:
cli_option("-a", "--auto", dest= "auto", default= False, action= "stor\
e_true", help= "Automatically replace faulty disks" " (only for the dr\
bd template)")

IGNORE_SIZE_OPT

Value:
cli_option("--ignore-size", dest= "ignore_size", default= False, actio\
n= "store_true", help= "Ignore current recorded size" " (useful for fo\
rcing activation when" " the recorded size is wrong)")

SRC_NODE_OPT

Value:
cli_option("--src-node", dest= "src_node", help= "Source node", metava\
r= "<node>", completion_suggest= OPT_COMPL_ONE_NODE)

SRC_DIR_OPT

Value:
cli_option("--src-dir", dest= "src_dir", help= "Source directory", met\
avar= "<dir>")

SECONDARY_IP_OPT

Value:
cli_option("-s", "--secondary-ip", dest= "secondary_ip", help= "Specif\
y the secondary ip for the node", metavar= "ADDRESS", default= None)

READD_OPT

Value:
cli_option("--readd", dest= "readd", default= False, action= "store_tr\
ue", help= "Readd old node after replacing it")

NOSSH_KEYCHECK_OPT

Value:
cli_option("--no-ssh-key-check", dest= "ssh_key_check", default= True,\
 action= "store_false", help= "Disable SSH key fingerprint checking")

MC_OPT

Value:
cli_option("-C", "--master-candidate", dest= "master_candidate", type=\
 "bool", default= None, metavar= _YORNO, help= "Set the master_candida\
te flag on the node")

OFFLINE_OPT

Value:
cli_option("-O", "--offline", dest= "offline", metavar= _YORNO, type= \
"bool", default= None, help= "Set the offline flag on the node")

DRAINED_OPT

Value:
cli_option("-D", "--drained", dest= "drained", metavar= _YORNO, type= \
"bool", default= None, help= "Set the drained flag on the node")

CAPAB_MASTER_OPT

Value:
cli_option("--master-capable", dest= "master_capable", type= "bool", d\
efault= None, metavar= _YORNO, help= "Set the master_capable flag on t\
he node")

CAPAB_VM_OPT

Value:
cli_option("--vm-capable", dest= "vm_capable", type= "bool", default= \
None, metavar= _YORNO, help= "Set the vm_capable flag on the node")

ALLOCATABLE_OPT

Value:
cli_option("--allocatable", dest= "allocatable", type= "bool", default\
= None, metavar= _YORNO, help= "Set the allocatable flag on a volume")

NOLVM_STORAGE_OPT

Value:
cli_option("--no-lvm-storage", dest= "lvm_storage", help= "Disable sup\
port for lvm based instances" " (cluster-wide)", action= "store_false"\
, default= True)

ENABLED_HV_OPT

Value:
cli_option("--enabled-hypervisors", dest= "enabled_hypervisors", help=\
 "Comma-separated list of hypervisors", type= "string", default= None)

NIC_PARAMS_OPT

Value:
cli_option("-N", "--nic-parameters", dest= "nicparams", type= "keyval"\
, default= {}, help= "NIC parameters")

CP_SIZE_OPT

Value:
cli_option("-C", "--candidate-pool-size", default= None, dest= "candid\
ate_pool_size", type= "int", help= "Set the candidate pool size")

VG_NAME_OPT

Value:
cli_option("--vg-name", dest= "vg_name", help= "Enables LVM and specif\
ies the volume group" " name (cluster-wide) for disk allocation [xenvg\
]", metavar= "VG", default= None)

YES_DOIT_OPT

Value:
cli_option("--yes-do-it", dest= "yes_do_it", help= "Destroy cluster", \
action= "store_true")

NOVOTING_OPT

Value:
cli_option("--no-voting", dest= "no_voting", help= "Skip node agreemen\
t check (dangerous)", action= "store_true", default= False)

MAC_PREFIX_OPT

Value:
cli_option("-m", "--mac-prefix", dest= "mac_prefix", help= "Specify th\
e mac prefix for the instance IP" " addresses, in the format XX:XX:XX"\
, metavar= "PREFIX", default= None)

MASTER_NETDEV_OPT

Value:
cli_option("--master-netdev", dest= "master_netdev", help= "Specify th\
e node interface (cluster-wide)" " on which the master IP address will\
 be added " " [%s]" % constants.DEFAULT_BRIDGE, metavar= "NETDEV", def\
ault= constants.DEFAULT_BRIDGE)

GLOBAL_FILEDIR_OPT

Value:
cli_option("--file-storage-dir", dest= "file_storage_dir", help= "Spec\
ify the default directory (cluster-" "wide) for storing the file-based\
 disks [%s]" % constants.DEFAULT_FILE_STORAGE_DIR, metavar= "DIR", def\
ault= constants.DEFAULT_FILE_STORAGE_DIR)

NOMODIFY_ETCHOSTS_OPT

Value:
cli_option("--no-etc-hosts", dest= "modify_etc_hosts", help= "Don't mo\
dify /etc/hosts", action= "store_false", default= True)

NOMODIFY_SSH_SETUP_OPT

Value:
cli_option("--no-ssh-init", dest= "modify_ssh_setup", help= "Don't ini\
tialize SSH keys", action= "store_false", default= True)

ERROR_CODES_OPT

Value:
cli_option("--error-codes", dest= "error_codes", help= "Enable parseab\
le error messages", action= "store_true", default= False)

NONPLUS1_OPT

Value:
cli_option("--no-nplus1-mem", dest= "skip_nplusone_mem", help= "Skip N\
+1 memory redundancy tests", action= "store_true", default= False)

REBOOT_TYPE_OPT

Value:
cli_option("-t", "--type", dest= "reboot_type", help= "Type of reboot:\
 soft/hard/full", default= constants.INSTANCE_REBOOT_HARD, metavar= "<\
REBOOT>", choices= list(constants.REBOOT_TYPES))

IGNORE_SECONDARIES_OPT

Value:
cli_option("--ignore-secondaries", dest= "ignore_secondaries", default\
= False, action= "store_true", help= "Ignore errors from secondaries")

NOSHUTDOWN_OPT

Value:
cli_option("--noshutdown", dest= "shutdown", action= "store_false", de\
fault= True, help= "Don't shutdown the instance (unsafe)")

TIMEOUT_OPT

Value:
cli_option("--timeout", dest= "timeout", type= "int", default= constan\
ts.DEFAULT_SHUTDOWN_TIMEOUT, help= "Maximum time to wait")

SHUTDOWN_TIMEOUT_OPT

Value:
cli_option("--shutdown-timeout", dest= "shutdown_timeout", type= "int"\
, default= constants.DEFAULT_SHUTDOWN_TIMEOUT, help= "Maximum time to \
wait for instance shutdown")

INTERVAL_OPT

Value:
cli_option("--interval", dest= "interval", type= "int", default= None,\
 help= ("Number of seconds between repetions of the" " command"))

EARLY_RELEASE_OPT

Value:
cli_option("--early-release", dest= "early_release", default= False, a\
ction= "store_true", help= "Release the locks on the secondary" " node\
(s) early")

NEW_CLUSTER_CERT_OPT

Value:
cli_option("--new-cluster-certificate", dest= "new_cluster_cert", defa\
ult= False, action= "store_true", help= "Generate a new cluster certif\
icate")

RAPI_CERT_OPT

Value:
cli_option("--rapi-certificate", dest= "rapi_cert", default= None, hel\
p= "File containing new RAPI certificate")

NEW_RAPI_CERT_OPT

Value:
cli_option("--new-rapi-certificate", dest= "new_rapi_cert", default= N\
one, action= "store_true", help= ("Generate a new self-signed RAPI" " \
certificate"))

NEW_CONFD_HMAC_KEY_OPT

Value:
cli_option("--new-confd-hmac-key", dest= "new_confd_hmac_key", default\
= False, action= "store_true", help= ("Create a new HMAC key for %s" %\
 constants.CONFD))

CLUSTER_DOMAIN_SECRET_OPT

Value:
cli_option("--cluster-domain-secret", dest= "cluster_domain_secret", d\
efault= None, help= ("Load new new cluster domain" " secret from file"\
))

NEW_CLUSTER_DOMAIN_SECRET_OPT

Value:
cli_option("--new-cluster-domain-secret", dest= "new_cluster_domain_se\
cret", default= False, action= "store_true", help= ("Create a new clus\
ter domain" " secret"))

USE_REPL_NET_OPT

Value:
cli_option("--use-replication-network", dest= "use_replication_network\
", help= "Whether to use the replication network" " for talking to the\
 nodes", action= "store_true", default= False)

MAINTAIN_NODE_HEALTH_OPT

Value:
cli_option("--maintain-node-health", dest= "maintain_node_health", met\
avar= _YORNO, default= None, type= "bool", help= "Configure the cluste\
r to automatically maintain node" " health, by shutting down unknown i\
nstances, shutting down" " unknown DRBD devices, etc.")

IDENTIFY_DEFAULTS_OPT

Value:
cli_option("--identify-defaults", dest= "identify_defaults", default= \
False, action= "store_true", help= "Identify which saved instance para\
meters are equal to" " the current cluster defaults and set them as su\
ch, instead" " of marking them as overridden")

UIDPOOL_OPT

Value:
cli_option("--uid-pool", default= None, action= "store", dest= "uid_po\
ol", help= ("A list of user-ids or user-id" " ranges separated by comm\
as"))

ADD_UIDS_OPT

Value:
cli_option("--add-uids", default= None, action= "store", dest= "add_ui\
ds", help= ("A list of user-ids or user-id" " ranges separated by comm\
as, to be" " added to the user-id pool"))

REMOVE_UIDS_OPT

Value:
cli_option("--remove-uids", default= None, action= "store", dest= "rem\
ove_uids", help= ("A list of user-ids or user-id" " ranges separated b\
y commas, to be" " removed from the user-id pool"))

RESERVED_LVS_OPT

Value:
cli_option("--reserved-lvs", default= None, action= "store", dest= "re\
served_lvs", help= ("A comma-separated list of reserved" " logical vol\
umes names, that will be" " ignored by cluster verify"))

ROMAN_OPT

Value:
cli_option("--roman", dest= "roman_integers", default= False, action= \
"store_true", help= "Use roman numbers for positive integers")

DRBD_HELPER_OPT

Value:
cli_option("--drbd-usermode-helper", dest= "drbd_helper", action= "sto\
re", default= None, help= "Specifies usermode helper for DRBD")

NODRBD_STORAGE_OPT

Value:
cli_option("--no-drbd-storage", dest= "drbd_storage", action= "store_f\
alse", default= True, help= "Disable support for DRBD")

PRIMARY_IP_VERSION_OPT

Value:
cli_option("--primary-ip-version", default= constants.IP4_VERSION, act\
ion= "store", dest= "primary_ip_version", metavar= "%d|%d" %(constants\
.IP4_VERSION, constants.IP6_VERSION), help= "Cluster-wide IP version f\
or primary IP")

PRIORITY_OPT

Value:
cli_option("--priority", default= None, dest= "priority", metavar= "|"\
.join(name for name, _ in _PRIORITY_NAMES), choices= _PRIONAME_TO_VALU\
E.keys(), help= "Priority for opcode processing")

HID_OS_OPT

Value:
cli_option("--hidden", dest= "hidden", type= "bool", default= None, me\
tavar= _YORNO, help= "Sets the hidden flag on the OS")

BLK_OS_OPT

Value:
cli_option("--blacklisted", dest= "blacklisted", type= "bool", default\
= None, metavar= _YORNO, help= "Sets the blacklisted flag on the OS")

PREALLOC_WIPE_DISKS_OPT

Value:
cli_option("--prealloc-wipe-disks", default= None, type= "bool", metav\
ar= _YORNO, dest= "prealloc_wipe_disks", help= ("Wipe disks prior to i\
nstance" " creation"))

COMMON_CREATE_OPTS

Value:
[BACKEND_OPT, DISK_OPT, DISK_TEMPLATE_OPT, FILESTORE_DIR_OPT, FILESTOR\
E_DRIVER_OPT, HYPERVISOR_OPT, IALLOCATOR_OPT, NET_OPT, NODE_PLACEMENT_\
OPT, NOIPCHECK_OPT, NONAMECHECK_OPT, NONICS_OPT, NWSYNC_OPT, OSPARAMS_\
OPT, OS_SIZE_OPT, SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT,]