Commit d6cd74dd authored by Klaus Aehlig's avatar Klaus Aehlig

Add an option to print job id of submitted jobs on stdout

When submitting a job, the job id, prefixed by 'JobID: ', is output to
stderr. While this is easy to understand for humans, for scripting, it
is more convenient to have (additionally) the id on stdout (and only
the id). Add an option to provide this.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent f5d13a77
...@@ -165,6 +165,7 @@ __all__ = [ ...@@ -165,6 +165,7 @@ __all__ = [
"PREALLOC_WIPE_DISKS_OPT", "PREALLOC_WIPE_DISKS_OPT",
"PRIMARY_IP_VERSION_OPT", "PRIMARY_IP_VERSION_OPT",
"PRIMARY_ONLY_OPT", "PRIMARY_ONLY_OPT",
"PRINT_JOBID_OPT",
"PRIORITY_OPT", "PRIORITY_OPT",
"RAPI_CERT_OPT", "RAPI_CERT_OPT",
"READD_OPT", "READD_OPT",
...@@ -198,6 +199,7 @@ __all__ = [ ...@@ -198,6 +199,7 @@ __all__ = [
"SRC_DIR_OPT", "SRC_DIR_OPT",
"SRC_NODE_OPT", "SRC_NODE_OPT",
"SUBMIT_OPT", "SUBMIT_OPT",
"SUBMIT_OPTS",
"STARTUP_PAUSED_OPT", "STARTUP_PAUSED_OPT",
"STATIC_OPT", "STATIC_OPT",
"SYNC_OPT", "SYNC_OPT",
...@@ -832,6 +834,11 @@ SUBMIT_OPT = cli_option("--submit", dest="submit_only", ...@@ -832,6 +834,11 @@ SUBMIT_OPT = cli_option("--submit", dest="submit_only",
help=("Submit the job and return the job ID, but" help=("Submit the job and return the job ID, but"
" don't wait for the job to finish")) " don't wait for the job to finish"))
PRINT_JOBID_OPT = cli_option("--print-jobid", dest="print_jobid",
default=False, action="store_true",
help=("Additionally print the job as first line"
" on stdout (for scripting)."))
SYNC_OPT = cli_option("--sync", dest="do_locking", SYNC_OPT = cli_option("--sync", dest="do_locking",
default=False, action="store_true", default=False, action="store_true",
help=("Grab locks while doing the queries" help=("Grab locks while doing the queries"
...@@ -1634,6 +1641,13 @@ INCLUDEDEFAULTS_OPT = cli_option("--include-defaults", dest="include_defaults", ...@@ -1634,6 +1641,13 @@ INCLUDEDEFAULTS_OPT = cli_option("--include-defaults", dest="include_defaults",
#: Options provided by all commands #: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT, REASON_OPT] COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
# options related to asynchronous job handling
SUBMIT_OPTS = [
SUBMIT_OPT,
PRINT_JOBID_OPT,
]
# common options for creating instances. add and import then add their own # common options for creating instances. add and import then add their own
# specific ones. # specific ones.
COMMON_CREATE_OPTS = [ COMMON_CREATE_OPTS = [
...@@ -1654,6 +1668,7 @@ COMMON_CREATE_OPTS = [ ...@@ -1654,6 +1668,7 @@ COMMON_CREATE_OPTS = [
OSPARAMS_OPT, OSPARAMS_OPT,
OS_SIZE_OPT, OS_SIZE_OPT,
SUBMIT_OPT, SUBMIT_OPT,
PRINT_JOBID_OPT,
TAG_ADD_OPT, TAG_ADD_OPT,
DRY_RUN_OPT, DRY_RUN_OPT,
PRIORITY_OPT, PRIORITY_OPT,
...@@ -2248,6 +2263,8 @@ def SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None): ...@@ -2248,6 +2263,8 @@ def SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None):
SetGenericOpcodeOpts([op], opts) SetGenericOpcodeOpts([op], opts)
job_id = SendJob([op], cl=cl) job_id = SendJob([op], cl=cl)
if opts.print_jobid:
ToStdout("%d" % job_id)
op_results = PollJob(job_id, cl=cl, feedback_fn=feedback_fn, op_results = PollJob(job_id, cl=cl, feedback_fn=feedback_fn,
reporter=reporter) reporter=reporter)
...@@ -2271,6 +2288,8 @@ def SubmitOrSend(op, opts, cl=None, feedback_fn=None): ...@@ -2271,6 +2288,8 @@ def SubmitOrSend(op, opts, cl=None, feedback_fn=None):
job = [op] job = [op]
SetGenericOpcodeOpts(job, opts) SetGenericOpcodeOpts(job, opts)
job_id = SendJob(job, cl=cl) job_id = SendJob(job, cl=cl)
if opts.print_jobid:
ToStdout("%d" % job_id)
raise JobSubmittedException(job_id) raise JobSubmittedException(job_id)
else: else:
return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn, opts=opts) return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn, opts=opts)
......
...@@ -150,7 +150,7 @@ commands = { ...@@ -150,7 +150,7 @@ commands = {
ExportInstance, ARGS_ONE_INSTANCE, ExportInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SINGLE_NODE_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT, [FORCE_OPT, SINGLE_NODE_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT,
REMOVE_INSTANCE_OPT, IGNORE_REMOVE_FAILURES_OPT, DRY_RUN_OPT, REMOVE_INSTANCE_OPT, IGNORE_REMOVE_FAILURES_OPT, DRY_RUN_OPT,
PRIORITY_OPT, SUBMIT_OPT], PRIORITY_OPT] + SUBMIT_OPTS,
"-n <target_node> [opts...] <name>", "-n <target_node> [opts...] <name>",
"Exports an instance to an image"), "Exports an instance to an image"),
"import": ( "import": (
...@@ -159,7 +159,7 @@ commands = { ...@@ -159,7 +159,7 @@ commands = {
"Imports an instance from an exported image"), "Imports an instance from an exported image"),
"remove": ( "remove": (
RemoveExport, [ArgUnknown(min=1, max=1)], RemoveExport, [ArgUnknown(min=1, max=1)],
[DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT], [DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<name>", "Remove exports of named instance from the filesystem."), "<name>", "Remove exports of named instance from the filesystem."),
} }
......
...@@ -1550,7 +1550,7 @@ commands = { ...@@ -1550,7 +1550,7 @@ commands = {
"<new_name>", "<new_name>",
"Renames the cluster"), "Renames the cluster"),
"redist-conf": ( "redist-conf": (
RedistributeConfig, ARGS_NONE, [SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], RedistributeConfig, ARGS_NONE, SUBMIT_OPTS + [DRY_RUN_OPT, PRIORITY_OPT],
"", "Forces a push of the configuration file and ssconf files" "", "Forces a push of the configuration file and ssconf files"
" to the nodes in the cluster"), " to the nodes in the cluster"),
"verify": ( "verify": (
...@@ -1590,10 +1590,10 @@ commands = { ...@@ -1590,10 +1590,10 @@ commands = {
"list-tags": ( "list-tags": (
ListTags, ARGS_NONE, [], "", "List the tags of the cluster"), ListTags, ARGS_NONE, [], "", "List the tags of the cluster"),
"add-tags": ( "add-tags": (
AddTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], AddTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"tag...", "Add tags to the cluster"), "tag...", "Add tags to the cluster"),
"remove-tags": ( "remove-tags": (
RemoveTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], RemoveTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"tag...", "Remove tags from the cluster"), "tag...", "Remove tags from the cluster"),
"search-tags": ( "search-tags": (
SearchTags, [ArgUnknown(min=1, max=1)], [PRIORITY_OPT], "", SearchTags, [ArgUnknown(min=1, max=1)], [PRIORITY_OPT], "",
...@@ -1617,8 +1617,8 @@ commands = { ...@@ -1617,8 +1617,8 @@ commands = {
DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT,
RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT, RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT, NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT,
DISK_STATE_OPT, SUBMIT_OPT, ENABLED_DISK_TEMPLATES_OPT, DISK_STATE_OPT] + SUBMIT_OPTS +
IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS, [ENABLED_DISK_TEMPLATES_OPT, IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS,
"[opts...]", "[opts...]",
"Alters the parameters of the cluster"), "Alters the parameters of the cluster"),
"renew-crypto": ( "renew-crypto": (
......
...@@ -631,8 +631,7 @@ commands = { ...@@ -631,8 +631,7 @@ commands = {
action="append", help="Select nodes to sleep on"), action="append", help="Select nodes to sleep on"),
cli_option("-r", "--repeat", type="int", default="0", dest="repeat", cli_option("-r", "--repeat", type="int", default="0", dest="repeat",
help="Number of times to repeat the sleep"), help="Number of times to repeat the sleep"),
DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
],
"[opts...] <duration>", "Executes a TestDelay OpCode"), "[opts...] <duration>", "Executes a TestDelay OpCode"),
"submit-job": ( "submit-job": (
GenericOpCodes, [ArgFile(min=1)], GenericOpCodes, [ArgFile(min=1)],
......
...@@ -323,12 +323,12 @@ commands = { ...@@ -323,12 +323,12 @@ commands = {
"add": ( "add": (
AddGroup, ARGS_ONE_GROUP, AddGroup, ARGS_ONE_GROUP,
[DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, DISK_PARAMS_OPT, [DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, DISK_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT, PRIORITY_OPT, HV_STATE_OPT, DISK_STATE_OPT, PRIORITY_OPT]
SUBMIT_OPT] + INSTANCE_POLICY_OPTS, + SUBMIT_OPTS + INSTANCE_POLICY_OPTS,
"<group_name>", "Add a new node group to the cluster"), "<group_name>", "Add a new node group to the cluster"),
"assign-nodes": ( "assign-nodes": (
AssignNodes, ARGS_ONE_GROUP + ARGS_MANY_NODES, AssignNodes, ARGS_ONE_GROUP + ARGS_MANY_NODES,
[DRY_RUN_OPT, FORCE_OPT, PRIORITY_OPT, SUBMIT_OPT], [DRY_RUN_OPT, FORCE_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<group_name> <node>...", "Assign nodes to a group"), "<group_name> <node>...", "Assign nodes to a group"),
"list": ( "list": (
ListGroups, ARGS_MANY_GROUPS, ListGroups, ARGS_MANY_GROUPS,
...@@ -342,20 +342,21 @@ commands = { ...@@ -342,20 +342,21 @@ commands = {
"Lists all available fields for node groups"), "Lists all available fields for node groups"),
"modify": ( "modify": (
SetGroupParams, ARGS_ONE_GROUP, SetGroupParams, ARGS_ONE_GROUP,
[DRY_RUN_OPT, SUBMIT_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, HV_STATE_OPT, [DRY_RUN_OPT] + SUBMIT_OPTS + [ALLOC_POLICY_OPT, NODE_PARAMS_OPT,
DISK_STATE_OPT, DISK_PARAMS_OPT, PRIORITY_OPT] + INSTANCE_POLICY_OPTS, HV_STATE_OPT, DISK_STATE_OPT, DISK_PARAMS_OPT, PRIORITY_OPT]
+ INSTANCE_POLICY_OPTS,
"<group_name>", "Alters the parameters of a node group"), "<group_name>", "Alters the parameters of a node group"),
"remove": ( "remove": (
RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT], RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"[--dry-run] <group-name>", "[--dry-run] <group-name>",
"Remove an (empty) node group from the cluster"), "Remove an (empty) node group from the cluster"),
"rename": ( "rename": (
RenameGroup, [ArgGroup(min=2, max=2)], RenameGroup, [ArgGroup(min=2, max=2)],
[DRY_RUN_OPT, SUBMIT_OPT, PRIORITY_OPT], [DRY_RUN_OPT] + SUBMIT_OPTS + [PRIORITY_OPT],
"[--dry-run] <group-name> <new-name>", "Rename a node group"), "[--dry-run] <group-name> <new-name>", "Rename a node group"),
"evacuate": ( "evacuate": (
EvacuateGroup, [ArgGroup(min=1, max=1)], EvacuateGroup, [ArgGroup(min=1, max=1)],
[TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, SUBMIT_OPT, PRIORITY_OPT], [TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT] + SUBMIT_OPTS,
"[-I <iallocator>] [--to <group>]", "[-I <iallocator>] [--to <group>]",
"Evacuate all instances within a group"), "Evacuate all instances within a group"),
"list-tags": ( "list-tags": (
...@@ -363,11 +364,11 @@ commands = { ...@@ -363,11 +364,11 @@ commands = {
"<group_name>", "List the tags of the given group"), "<group_name>", "List the tags of the given group"),
"add-tags": ( "add-tags": (
AddTags, [ArgGroup(min=1, max=1), ArgUnknown()], AddTags, [ArgGroup(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<group_name> tag...", "Add tags to the given group"), "<group_name> tag...", "Add tags to the given group"),
"remove-tags": ( "remove-tags": (
RemoveTags, [ArgGroup(min=1, max=1), ArgUnknown()], RemoveTags, [ArgGroup(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<group_name> tag...", "Remove tags from the given group"), "<group_name> tag...", "Remove tags from the given group"),
"info": ( "info": (
GroupInfo, ARGS_MANY_GROUPS, [], "[<group_name>...]", GroupInfo, ARGS_MANY_GROUPS, [], "[<group_name>...]",
......
...@@ -1458,7 +1458,7 @@ commands = { ...@@ -1458,7 +1458,7 @@ commands = {
"Creates and adds a new instance to the cluster"), "Creates and adds a new instance to the cluster"),
"batch-create": ( "batch-create": (
BatchCreate, [ArgFile(min=1, max=1)], BatchCreate, [ArgFile(min=1, max=1)],
[DRY_RUN_OPT, PRIORITY_OPT, IALLOCATOR_OPT, SUBMIT_OPT], [DRY_RUN_OPT, PRIORITY_OPT, IALLOCATOR_OPT] + SUBMIT_OPTS,
"<instances.json>", "<instances.json>",
"Create a bunch of instances based on specs in the file."), "Create a bunch of instances based on specs in the file."),
"console": ( "console": (
...@@ -1467,7 +1467,8 @@ commands = { ...@@ -1467,7 +1467,8 @@ commands = {
"[--show-cmd] <instance>", "Opens a console on the specified instance"), "[--show-cmd] <instance>", "Opens a console on the specified instance"),
"failover": ( "failover": (
FailoverInstance, ARGS_ONE_INSTANCE, FailoverInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, IGNORE_CONSIST_OPT, SUBMIT_OPT, SHUTDOWN_TIMEOUT_OPT, [FORCE_OPT, IGNORE_CONSIST_OPT] + SUBMIT_OPTS +
[SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT, DRY_RUN_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT,
IGNORE_IPOLICY_OPT], IGNORE_IPOLICY_OPT],
"[-f] <instance>", "Stops the instance, changes its primary node and" "[-f] <instance>", "Stops the instance, changes its primary node and"
...@@ -1478,13 +1479,15 @@ commands = { ...@@ -1478,13 +1479,15 @@ commands = {
MigrateInstance, ARGS_ONE_INSTANCE, MigrateInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT, DRY_RUN_OPT, [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT, DRY_RUN_OPT,
PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT, ALLOW_FAILOVER_OPT, PRIORITY_OPT, DST_NODE_OPT, IALLOCATOR_OPT, ALLOW_FAILOVER_OPT,
IGNORE_IPOLICY_OPT, NORUNTIME_CHGS_OPT, SUBMIT_OPT], IGNORE_IPOLICY_OPT, NORUNTIME_CHGS_OPT] + SUBMIT_OPTS,
"[-f] <instance>", "Migrate instance to its secondary node" "[-f] <instance>", "Migrate instance to its secondary node"
" (only for mirrored instances)"), " (only for mirrored instances)"),
"move": ( "move": (
MoveInstance, ARGS_ONE_INSTANCE, MoveInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SUBMIT_OPT, SINGLE_NODE_OPT, SHUTDOWN_TIMEOUT_OPT, [FORCE_OPT] + SUBMIT_OPTS +
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_CONSIST_OPT, IGNORE_IPOLICY_OPT], [SINGLE_NODE_OPT,
SHUTDOWN_TIMEOUT_OPT, DRY_RUN_OPT, PRIORITY_OPT, IGNORE_CONSIST_OPT,
IGNORE_IPOLICY_OPT],
"[-f] <instance>", "Move instance to an arbitrary node" "[-f] <instance>", "Move instance to an arbitrary node"
" (only for instances of type file and lv)"), " (only for instances of type file and lv)"),
"info": ( "info": (
...@@ -1511,30 +1514,31 @@ commands = { ...@@ -1511,30 +1514,31 @@ commands = {
ReinstallInstance, [ArgInstance()], ReinstallInstance, [ArgInstance()],
[FORCE_OPT, OS_OPT, FORCE_VARIANT_OPT, m_force_multi, m_node_opt, [FORCE_OPT, OS_OPT, FORCE_VARIANT_OPT, m_force_multi, m_node_opt,
m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_inst_opt, m_node_tags_opt, m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_inst_opt, m_node_tags_opt,
m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, SELECT_OS_OPT, m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, SELECT_OS_OPT]
SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT, OSPARAMS_OPT], + SUBMIT_OPTS + [DRY_RUN_OPT, PRIORITY_OPT, OSPARAMS_OPT],
"[-f] <instance>", "Reinstall a stopped instance"), "[-f] <instance>", "Reinstall a stopped instance"),
"remove": ( "remove": (
RemoveInstance, ARGS_ONE_INSTANCE, RemoveInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT, SUBMIT_OPT, [FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT] + SUBMIT_OPTS
DRY_RUN_OPT, PRIORITY_OPT], + [DRY_RUN_OPT, PRIORITY_OPT],
"[-f] <instance>", "Shuts down the instance and removes it"), "[-f] <instance>", "Shuts down the instance and removes it"),
"rename": ( "rename": (
RenameInstance, RenameInstance,
[ArgInstance(min=1, max=1), ArgHost(min=1, max=1)], [ArgInstance(min=1, max=1), ArgHost(min=1, max=1)],
[NOIPCHECK_OPT, NONAMECHECK_OPT, SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], [NOIPCHECK_OPT, NONAMECHECK_OPT] + SUBMIT_OPTS
+ [DRY_RUN_OPT, PRIORITY_OPT],
"<instance> <new_name>", "Rename the instance"), "<instance> <new_name>", "Rename the instance"),
"replace-disks": ( "replace-disks": (
ReplaceDisks, ARGS_ONE_INSTANCE, ReplaceDisks, ARGS_ONE_INSTANCE,
[AUTO_REPLACE_OPT, DISKIDX_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, [AUTO_REPLACE_OPT, DISKIDX_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT,
NEW_SECONDARY_OPT, ON_PRIMARY_OPT, ON_SECONDARY_OPT, SUBMIT_OPT, NEW_SECONDARY_OPT, ON_PRIMARY_OPT, ON_SECONDARY_OPT] + SUBMIT_OPTS
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT], + [DRY_RUN_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT],
"[-s|-p|-a|-n NODE|-I NAME] <instance>", "[-s|-p|-a|-n NODE|-I NAME] <instance>",
"Replaces disks for the instance"), "Replaces disks for the instance"),
"modify": ( "modify": (
SetInstanceParams, ARGS_ONE_INSTANCE, SetInstanceParams, ARGS_ONE_INSTANCE,
[BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT, SUBMIT_OPT, [BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT] + SUBMIT_OPTS +
DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT, [DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT,
OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT,
ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT, ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT,
NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT], NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT],
...@@ -1543,57 +1547,60 @@ commands = { ...@@ -1543,57 +1547,60 @@ commands = {
GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()], GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
[FORCE_OPT, m_node_opt, m_pri_node_opt, m_sec_node_opt, m_clust_opt, [FORCE_OPT, m_node_opt, m_pri_node_opt, m_sec_node_opt, m_clust_opt,
m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt, m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt,
m_inst_tags_opt, m_inst_opt, m_force_multi, TIMEOUT_OPT, SUBMIT_OPT, m_inst_tags_opt, m_inst_opt, m_force_multi, TIMEOUT_OPT] + SUBMIT_OPTS
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, NO_REMEMBER_OPT], + [DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, NO_REMEMBER_OPT],
"<instance>", "Stops an instance"), "<instance>", "Stops an instance"),
"startup": ( "startup": (
GenericManyOps("startup", _StartupInstance), [ArgInstance()], GenericManyOps("startup", _StartupInstance), [ArgInstance()],
[FORCE_OPT, m_force_multi, m_node_opt, m_pri_node_opt, m_sec_node_opt, [FORCE_OPT, m_force_multi, m_node_opt, m_pri_node_opt, m_sec_node_opt,
m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt, m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt,
m_inst_tags_opt, m_clust_opt, m_inst_opt, SUBMIT_OPT, HVOPTS_OPT, m_inst_tags_opt, m_clust_opt, m_inst_opt] + SUBMIT_OPTS +
[HVOPTS_OPT,
BACKEND_OPT, DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, BACKEND_OPT, DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT,
NO_REMEMBER_OPT, STARTUP_PAUSED_OPT], NO_REMEMBER_OPT, STARTUP_PAUSED_OPT],
"<instance>", "Starts an instance"), "<instance>", "Starts an instance"),
"reboot": ( "reboot": (
GenericManyOps("reboot", _RebootInstance), [ArgInstance()], GenericManyOps("reboot", _RebootInstance), [ArgInstance()],
[m_force_multi, REBOOT_TYPE_OPT, IGNORE_SECONDARIES_OPT, m_node_opt, [m_force_multi, REBOOT_TYPE_OPT, IGNORE_SECONDARIES_OPT, m_node_opt,
m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_inst_opt, SUBMIT_OPT, m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_inst_opt] + SUBMIT_OPTS +
m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt, [m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt,
m_inst_tags_opt, SHUTDOWN_TIMEOUT_OPT, DRY_RUN_OPT, PRIORITY_OPT], m_inst_tags_opt, SHUTDOWN_TIMEOUT_OPT, DRY_RUN_OPT, PRIORITY_OPT],
"<instance>", "Reboots an instance"), "<instance>", "Reboots an instance"),
"activate-disks": ( "activate-disks": (
ActivateDisks, ARGS_ONE_INSTANCE, ActivateDisks, ARGS_ONE_INSTANCE,
[SUBMIT_OPT, IGNORE_SIZE_OPT, PRIORITY_OPT, WFSYNC_OPT], SUBMIT_OPTS + [IGNORE_SIZE_OPT, PRIORITY_OPT, WFSYNC_OPT],
"<instance>", "Activate an instance's disks"), "<instance>", "Activate an instance's disks"),
"deactivate-disks": ( "deactivate-disks": (
DeactivateDisks, ARGS_ONE_INSTANCE, DeactivateDisks, ARGS_ONE_INSTANCE,
[FORCE_OPT, SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], [FORCE_OPT] + SUBMIT_OPTS + [DRY_RUN_OPT, PRIORITY_OPT],
"[-f] <instance>", "Deactivate an instance's disks"), "[-f] <instance>", "Deactivate an instance's disks"),
"recreate-disks": ( "recreate-disks": (
RecreateDisks, ARGS_ONE_INSTANCE, RecreateDisks, ARGS_ONE_INSTANCE,
[SUBMIT_OPT, DISK_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPTS +
[DISK_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT,
IALLOCATOR_OPT], IALLOCATOR_OPT],
"<instance>", "Recreate an instance's disks"), "<instance>", "Recreate an instance's disks"),
"grow-disk": ( "grow-disk": (
GrowDisk, GrowDisk,
[ArgInstance(min=1, max=1), ArgUnknown(min=1, max=1), [ArgInstance(min=1, max=1), ArgUnknown(min=1, max=1),
ArgUnknown(min=1, max=1)], ArgUnknown(min=1, max=1)],
[SUBMIT_OPT, NWSYNC_OPT, DRY_RUN_OPT, PRIORITY_OPT, ABSOLUTE_OPT], SUBMIT_OPTS + [NWSYNC_OPT, DRY_RUN_OPT, PRIORITY_OPT, ABSOLUTE_OPT],
"<instance> <disk> <size>", "Grow an instance's disk"), "<instance> <disk> <size>", "Grow an instance's disk"),
"change-group": ( "change-group": (
ChangeGroup, ARGS_ONE_INSTANCE, ChangeGroup, ARGS_ONE_INSTANCE,
[TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, PRIORITY_OPT, SUBMIT_OPT], [TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT, PRIORITY_OPT]
+ SUBMIT_OPTS,
"[-I <iallocator>] [--to <group>]", "Change group of instance"), "[-I <iallocator>] [--to <group>]", "Change group of instance"),
"list-tags": ( "list-tags": (
ListTags, ARGS_ONE_INSTANCE, [], ListTags, ARGS_ONE_INSTANCE, [],
"<instance_name>", "List the tags of the given instance"), "<instance_name>", "List the tags of the given instance"),
"add-tags": ( "add-tags": (
AddTags, [ArgInstance(min=1, max=1), ArgUnknown()], AddTags, [ArgInstance(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<instance_name> tag...", "Add tags to the given instance"), "<instance_name> tag...", "Add tags to the given instance"),
"remove-tags": ( "remove-tags": (
RemoveTags, [ArgInstance(min=1, max=1), ArgUnknown()], RemoveTags, [ArgInstance(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<instance_name> tag...", "Remove tags from given instance"), "<instance_name> tag...", "Remove tags from given instance"),
} }
......
...@@ -313,7 +313,7 @@ commands = { ...@@ -313,7 +313,7 @@ commands = {
AddNetwork, ARGS_ONE_NETWORK, AddNetwork, ARGS_ONE_NETWORK,
[DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT, [DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT,
MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT, MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
NOCONFLICTSCHECK_OPT, TAG_ADD_OPT, PRIORITY_OPT, SUBMIT_OPT], NOCONFLICTSCHECK_OPT, TAG_ADD_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<network_name>", "Add a new IP network to the cluster"), "<network_name>", "Add a new IP network to the cluster"),
"list": ( "list": (
ListNetworks, ARGS_MANY_NETWORKS, ListNetworks, ARGS_MANY_NETWORKS,
...@@ -330,9 +330,10 @@ commands = { ...@@ -330,9 +330,10 @@ commands = {
"[<network_name>...]", "Show information about the network(s)"), "[<network_name>...]", "Show information about the network(s)"),
"modify": ( "modify": (
SetNetworkParams, ARGS_ONE_NETWORK, SetNetworkParams, ARGS_ONE_NETWORK,
[DRY_RUN_OPT, SUBMIT_OPT, ADD_RESERVED_IPS_OPT, REMOVE_RESERVED_IPS_OPT, [DRY_RUN_OPT] + SUBMIT_OPTS +
GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT, [ADD_RESERVED_IPS_OPT,
PRIORITY_OPT], REMOVE_RESERVED_IPS_OPT, GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT,
GATEWAY6_OPT, PRIORITY_OPT],
"<network_name>", "Alters the parameters of a network"), "<network_name>", "Alters the parameters of a network"),
"connect": ( "connect": (
ConnectNetwork, ConnectNetwork,
...@@ -352,7 +353,7 @@ commands = { ...@@ -352,7 +353,7 @@ commands = {
"Unmap a given network from a specified node group"), "Unmap a given network from a specified node group"),
"remove": ( "remove": (
RemoveNetwork, ARGS_ONE_NETWORK, RemoveNetwork, ARGS_ONE_NETWORK,
[FORCE_OPT, DRY_RUN_OPT, SUBMIT_OPT, PRIORITY_OPT], [FORCE_OPT, DRY_RUN_OPT] + SUBMIT_OPTS + [PRIORITY_OPT],
"[--dry-run] <network_id>", "[--dry-run] <network_id>",
"Remove an (empty) network from the cluster"), "Remove an (empty) network from the cluster"),
"list-tags": ( "list-tags": (
...@@ -360,11 +361,11 @@ commands = { ...@@ -360,11 +361,11 @@ commands = {
"<network_name>", "List the tags of the given network"), "<network_name>", "List the tags of the given network"),
"add-tags": ( "add-tags": (
AddTags, [ArgNetwork(min=1, max=1), ArgUnknown()], AddTags, [ArgNetwork(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<network_name> tag...", "Add tags to the given network"), "<network_name> tag...", "Add tags to the given network"),
"remove-tags": ( "remove-tags": (
RemoveTags, [ArgNetwork(min=1, max=1), ArgUnknown()], RemoveTags, [ArgNetwork(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], [TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<network_name> tag...", "Remove tags from given network"), "<network_name> tag...", "Remove tags from given network"),
} }
......
...@@ -1090,7 +1090,7 @@ commands = { ...@@ -1090,7 +1090,7 @@ commands = {
"evacuate": ( "evacuate": (
EvacuateNode, ARGS_ONE_NODE, EvacuateNode, ARGS_ONE_NODE,
[FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT, [FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT,
PRIORITY_OPT, PRIMARY_ONLY_OPT, SECONDARY_ONLY_OPT, SUBMIT_OPT], PRIORITY_OPT, PRIMARY_ONLY_OPT, SECONDARY_ONLY_OPT] + SUBMIT_OPTS,
"[-f] {-I <iallocator> | -n <dst>} [-p | -s] [options...] <node>", "[-f] {-I <iallocator> | -n <dst>} [-p | -s] [options...] <node>",
"Relocate the primary and/or secondary instances from a node"), "Relocate the primary and/or secondary instances from a node"),
"failover": ( "failover": (
...@@ -1103,7 +1103,7 @@ commands = { ...@@ -1103,7 +1103,7 @@ commands = {
MigrateNode, ARGS_ONE_NODE, MigrateNode, ARGS_ONE_NODE,
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT, [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT,
IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT, IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT,
NORUNTIME_CHGS_OPT, SUBMIT_OPT], NORUNTIME_CHGS_OPT] + SUBMIT_OPTS,
"[-f] <node>", "[-f] <node>",
"Migrate all the primary instance on a node away from it" "Migrate all the primary instance on a node away from it"
" (only for instances of type drbd)"), " (only for instances of type drbd)"),
...@@ -1126,21 +1126,24 @@ commands = { ...@@ -1126,21 +1126,24 @@ commands = {
"Lists all available fields for nodes"), "Lists all available fields for nodes"),
"modify": ( "modify": (
SetNodeParams, ARGS_ONE_NODE, SetNodeParams, ARGS_ONE_NODE,
[FORCE_OPT, SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT, [FORCE_OPT] + SUBMIT_OPTS +
[MC_OPT, DRAINED_OPT, OFFLINE_OPT,
CAPAB_MASTER_OPT, CAPAB_VM_OPT, SECONDARY_IP_OPT, CAPAB_MASTER_OPT, CAPAB_VM_OPT, SECONDARY_IP_OPT,
AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT, AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT,
NODE_POWERED_OPT, HV_STATE_OPT, DISK_STATE_OPT], NODE_POWERED_OPT, HV_STATE_OPT, DISK_STATE_OPT],
"<node_name>", "Alters the parameters of a node"), "<node_name>", "Alters the parameters of a node"),
"powercycle": ( "powercycle": (
PowercycleNode, ARGS_ONE_NODE, PowercycleNode, ARGS_ONE_NODE,
[FORCE_OPT, CONFIRM_OPT, DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT], [FORCE_OPT, CONFIRM_OPT, DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<node_name>", "Tries to forcefully powercycle a node"), "<node_name>", "Tries to forcefully powercycle a node"),
"power": ( "power": (
PowerNode, PowerNode,
[ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS), [ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS),
ArgNode()], ArgNode()],
[SUBMIT_OPT, AUTO_PROMOTE_OPT, PRIORITY_OPT, IGNORE_STATUS_OPT, SUBMIT_OPTS +