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__ = [
"PREALLOC_WIPE_DISKS_OPT",
"PRIMARY_IP_VERSION_OPT",
"PRIMARY_ONLY_OPT",
"PRINT_JOBID_OPT",
"PRIORITY_OPT",
"RAPI_CERT_OPT",
"READD_OPT",
......@@ -198,6 +199,7 @@ __all__ = [
"SRC_DIR_OPT",
"SRC_NODE_OPT",
"SUBMIT_OPT",
"SUBMIT_OPTS",
"STARTUP_PAUSED_OPT",
"STATIC_OPT",
"SYNC_OPT",
......@@ -832,6 +834,11 @@ SUBMIT_OPT = cli_option("--submit", dest="submit_only",
help=("Submit the job and return the job ID, but"
" 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",
default=False, action="store_true",
help=("Grab locks while doing the queries"
......@@ -1634,6 +1641,13 @@ INCLUDEDEFAULTS_OPT = cli_option("--include-defaults", dest="include_defaults",
#: Options provided by all commands
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
# specific ones.
COMMON_CREATE_OPTS = [
......@@ -1654,6 +1668,7 @@ COMMON_CREATE_OPTS = [
OSPARAMS_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
PRINT_JOBID_OPT,
TAG_ADD_OPT,
DRY_RUN_OPT,
PRIORITY_OPT,
......@@ -2248,6 +2263,8 @@ def SubmitOpCode(op, cl=None, feedback_fn=None, opts=None, reporter=None):
SetGenericOpcodeOpts([op], opts)
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,
reporter=reporter)
......@@ -2271,6 +2288,8 @@ def SubmitOrSend(op, opts, cl=None, feedback_fn=None):
job = [op]
SetGenericOpcodeOpts(job, opts)
job_id = SendJob(job, cl=cl)
if opts.print_jobid:
ToStdout("%d" % job_id)
raise JobSubmittedException(job_id)
else:
return SubmitOpCode(op, cl=cl, feedback_fn=feedback_fn, opts=opts)
......
......@@ -150,7 +150,7 @@ commands = {
ExportInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SINGLE_NODE_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT,
REMOVE_INSTANCE_OPT, IGNORE_REMOVE_FAILURES_OPT, DRY_RUN_OPT,
PRIORITY_OPT, SUBMIT_OPT],
PRIORITY_OPT] + SUBMIT_OPTS,
"-n <target_node> [opts...] <name>",
"Exports an instance to an image"),
"import": (
......@@ -159,7 +159,7 @@ commands = {
"Imports an instance from an exported image"),
"remove": (
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."),
}
......
......@@ -1550,7 +1550,7 @@ commands = {
"<new_name>",
"Renames the cluster"),
"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"
" to the nodes in the cluster"),
"verify": (
......@@ -1590,10 +1590,10 @@ commands = {
"list-tags": (
ListTags, ARGS_NONE, [], "", "List the tags of the cluster"),
"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"),
"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"),
"search-tags": (
SearchTags, [ArgUnknown(min=1, max=1)], [PRIORITY_OPT], "",
......@@ -1617,8 +1617,8 @@ commands = {
DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_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,
DISK_STATE_OPT, SUBMIT_OPT, ENABLED_DISK_TEMPLATES_OPT,
IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS,
DISK_STATE_OPT] + SUBMIT_OPTS +
[ENABLED_DISK_TEMPLATES_OPT, IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS,
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
......
......@@ -631,8 +631,7 @@ commands = {
action="append", help="Select nodes to sleep on"),
cli_option("-r", "--repeat", type="int", default="0", dest="repeat",
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"),
"submit-job": (
GenericOpCodes, [ArgFile(min=1)],
......
......@@ -323,12 +323,12 @@ commands = {
"add": (
AddGroup, ARGS_ONE_GROUP,
[DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, DISK_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT, PRIORITY_OPT,
SUBMIT_OPT] + INSTANCE_POLICY_OPTS,
HV_STATE_OPT, DISK_STATE_OPT, PRIORITY_OPT]
+ SUBMIT_OPTS + INSTANCE_POLICY_OPTS,
"<group_name>", "Add a new node group to the cluster"),
"assign-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"),
"list": (
ListGroups, ARGS_MANY_GROUPS,
......@@ -342,20 +342,21 @@ commands = {
"Lists all available fields for node groups"),
"modify": (
SetGroupParams, ARGS_ONE_GROUP,
[DRY_RUN_OPT, SUBMIT_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, HV_STATE_OPT,
DISK_STATE_OPT, DISK_PARAMS_OPT, PRIORITY_OPT] + INSTANCE_POLICY_OPTS,
[DRY_RUN_OPT] + SUBMIT_OPTS + [ALLOC_POLICY_OPT, NODE_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT, DISK_PARAMS_OPT, PRIORITY_OPT]
+ INSTANCE_POLICY_OPTS,
"<group_name>", "Alters the parameters of a node group"),
"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>",
"Remove an (empty) node group from the cluster"),
"rename": (
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"),
"evacuate": (
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>]",
"Evacuate all instances within a group"),
"list-tags": (
......@@ -363,11 +364,11 @@ commands = {
"<group_name>", "List the tags of the given group"),
"add-tags": (
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"),
"remove-tags": (
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"),
"info": (
GroupInfo, ARGS_MANY_GROUPS, [], "[<group_name>...]",
......
......@@ -1458,7 +1458,7 @@ commands = {
"Creates and adds a new instance to the cluster"),
"batch-create": (
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>",
"Create a bunch of instances based on specs in the file."),
"console": (
......@@ -1467,7 +1467,8 @@ commands = {
"[--show-cmd] <instance>", "Opens a console on the specified instance"),
"failover": (
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,
IGNORE_IPOLICY_OPT],
"[-f] <instance>", "Stops the instance, changes its primary node and"
......@@ -1478,13 +1479,15 @@ commands = {
MigrateInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT, DRY_RUN_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"
" (only for mirrored instances)"),
"move": (
MoveInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SUBMIT_OPT, SINGLE_NODE_OPT, SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_CONSIST_OPT, IGNORE_IPOLICY_OPT],
[FORCE_OPT] + SUBMIT_OPTS +
[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"
" (only for instances of type file and lv)"),
"info": (
......@@ -1511,30 +1514,31 @@ commands = {
ReinstallInstance, [ArgInstance()],
[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_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, SELECT_OS_OPT,
SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT, OSPARAMS_OPT],
m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, SELECT_OS_OPT]
+ SUBMIT_OPTS + [DRY_RUN_OPT, PRIORITY_OPT, OSPARAMS_OPT],
"[-f] <instance>", "Reinstall a stopped instance"),
"remove": (
RemoveInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT, SUBMIT_OPT,
DRY_RUN_OPT, PRIORITY_OPT],
[FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT] + SUBMIT_OPTS
+ [DRY_RUN_OPT, PRIORITY_OPT],
"[-f] <instance>", "Shuts down the instance and removes it"),
"rename": (
RenameInstance,
[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"),
"replace-disks": (
ReplaceDisks, ARGS_ONE_INSTANCE,
[AUTO_REPLACE_OPT, DISKIDX_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT,
NEW_SECONDARY_OPT, ON_PRIMARY_OPT, ON_SECONDARY_OPT, SUBMIT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT],
NEW_SECONDARY_OPT, ON_PRIMARY_OPT, ON_SECONDARY_OPT] + SUBMIT_OPTS
+ [DRY_RUN_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT],
"[-s|-p|-a|-n NODE|-I NAME] <instance>",
"Replaces disks for the instance"),
"modify": (
SetInstanceParams, ARGS_ONE_INSTANCE,
[BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT, SUBMIT_OPT,
DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT,
[BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT] + SUBMIT_OPTS +
[DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT,
OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT,
ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT,
NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT],
......@@ -1543,57 +1547,60 @@ commands = {
GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
[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_inst_tags_opt, m_inst_opt, m_force_multi, TIMEOUT_OPT, SUBMIT_OPT,
DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, NO_REMEMBER_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],
"<instance>", "Stops an instance"),
"startup": (
GenericManyOps("startup", _StartupInstance), [ArgInstance()],
[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_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,
NO_REMEMBER_OPT, STARTUP_PAUSED_OPT],
"<instance>", "Starts an instance"),
"reboot": (
GenericManyOps("reboot", _RebootInstance), [ArgInstance()],
[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_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_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_inst_tags_opt, SHUTDOWN_TIMEOUT_OPT, DRY_RUN_OPT, PRIORITY_OPT],
"<instance>", "Reboots an instance"),
"activate-disks": (
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"),
"deactivate-disks": (
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"),
"recreate-disks": (
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],
"<instance>", "Recreate an instance's disks"),
"grow-disk": (
GrowDisk,
[ArgInstance(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"),
"change-group": (
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"),
"list-tags": (
ListTags, ARGS_ONE_INSTANCE, [],
"<instance_name>", "List the tags of the given instance"),
"add-tags": (
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"),
"remove-tags": (
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"),
}
......
......@@ -313,7 +313,7 @@ commands = {
AddNetwork, ARGS_ONE_NETWORK,
[DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_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"),
"list": (
ListNetworks, ARGS_MANY_NETWORKS,
......@@ -330,9 +330,10 @@ commands = {
"[<network_name>...]", "Show information about the network(s)"),
"modify": (
SetNetworkParams, ARGS_ONE_NETWORK,
[DRY_RUN_OPT, SUBMIT_OPT, ADD_RESERVED_IPS_OPT, REMOVE_RESERVED_IPS_OPT,
GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
PRIORITY_OPT],
[DRY_RUN_OPT] + SUBMIT_OPTS +
[ADD_RESERVED_IPS_OPT,
REMOVE_RESERVED_IPS_OPT, GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT,
GATEWAY6_OPT, PRIORITY_OPT],
"<network_name>", "Alters the parameters of a network"),
"connect": (
ConnectNetwork,
......@@ -352,7 +353,7 @@ commands = {
"Unmap a given network from a specified node group"),
"remove": (
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>",
"Remove an (empty) network from the cluster"),
"list-tags": (
......@@ -360,11 +361,11 @@ commands = {
"<network_name>", "List the tags of the given network"),
"add-tags": (
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"),
"remove-tags": (
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"),
}
......
......@@ -1090,7 +1090,7 @@ commands = {
"evacuate": (
EvacuateNode, ARGS_ONE_NODE,
[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>",
"Relocate the primary and/or secondary instances from a node"),
"failover": (
......@@ -1103,7 +1103,7 @@ commands = {
MigrateNode, ARGS_ONE_NODE,
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT,
IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT,
NORUNTIME_CHGS_OPT, SUBMIT_OPT],
NORUNTIME_CHGS_OPT] + SUBMIT_OPTS,
"[-f] <node>",
"Migrate all the primary instance on a node away from it"
" (only for instances of type drbd)"),
......@@ -1126,21 +1126,24 @@ commands = {
"Lists all available fields for nodes"),
"modify": (
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,
AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT,
NODE_POWERED_OPT, HV_STATE_OPT, DISK_STATE_OPT],
"<node_name>", "Alters the parameters of a node"),
"powercycle": (
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"),
"power": (
PowerNode,
[ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS),
ArgNode()],
[SUBMIT_OPT, AUTO_PROMOTE_OPT, PRIORITY_OPT, IGNORE_STATUS_OPT,
FORCE_OPT, NOHDR_OPT, SEP_OPT, OOB_TIMEOUT_OPT, POWER_DELAY_OPT],
SUBMIT_OPTS +
[AUTO_PROMOTE_OPT, PRIORITY_OPT,
IGNORE_STATUS_OPT, FORCE_OPT, NOHDR_OPT, SEP_OPT, OOB_TIMEOUT_OPT,
POWER_DELAY_OPT],
"on|off|cycle|status [nodes...]",
"Change power state of node by calling out-of-band helper."),
"remove": (
......@@ -1162,14 +1165,14 @@ commands = {
[ArgNode(min=1, max=1),
ArgChoice(min=1, max=1, choices=_MODIFIABLE_STORAGE_TYPES),
ArgFile(min=1, max=1)],
[ALLOCATABLE_OPT, DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT],
[ALLOCATABLE_OPT, DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<node_name> <storage_type> <name>", "Modify storage volume on a node"),
"repair-storage": (
RepairStorage,
[ArgNode(min=1, max=1),
ArgChoice(min=1, max=1, choices=_REPAIRABLE_STORAGE_TYPES),
ArgFile(min=1, max=1)],
[IGNORE_CONSIST_OPT, DRY_RUN_OPT, PRIORITY_OPT, SUBMIT_OPT],
[IGNORE_CONSIST_OPT, DRY_RUN_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<node_name> <storage_type> <name>",
"Repairs a storage volume on a node"),
"list-tags": (
......@@ -1177,11 +1180,11 @@ commands = {
"<node_name>", "List the tags of the given node"),
"add-tags": (
AddTags, [ArgNode(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT],
[TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<node_name> tag...", "Add tags to the given node"),
"remove-tags": (
RemoveTags, [ArgNode(min=1, max=1), ArgUnknown()],
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT],
[TAG_SRC_OPT, PRIORITY_OPT] + SUBMIT_OPTS,
"<node_name> tag...", "Remove tags from the given node"),
"health": (
Health, ARGS_MANY_NODES,
......@@ -1193,7 +1196,7 @@ commands = {
"[<node_name>]", "Query the list of used DRBD minors on the given node"),
"restricted-command": (
RestrictedCommand, [ArgUnknown(min=1, max=1)] + ARGS_MANY_NODES,
[SYNC_OPT, PRIORITY_OPT, SUBMIT_OPT, SHOW_MACHINE_OPT, NODEGROUP_OPT],
[SYNC_OPT, PRIORITY_OPT] + SUBMIT_OPTS + [SHOW_MACHINE_OPT, NODEGROUP_OPT],
"<command> <node_name> [<node_name>...]",
"Executes a restricted command on node(s)"),
}
......
......@@ -289,7 +289,7 @@ commands = {
"modify": (
ModifyOS, ARGS_ONE_OS,
[HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT,
HID_OS_OPT, BLK_OS_OPT, SUBMIT_OPT],
HID_OS_OPT, BLK_OS_OPT] + SUBMIT_OPTS,
"", "Modify the OS parameters"),
}
......
......@@ -240,7 +240,7 @@ availability for a certain command can be checked by calling the
command using the ``--help`` option.
| **gnt-...** *command* [\--dry-run] [\--priority {low | normal | high}]
| [\--submit]
| [\--submit] [\--print-job-id]
The ``--dry-run`` option can be used to check whether an operation
would succeed.
......@@ -252,6 +252,9 @@ The ``--submit`` option is used to send the job to the master daemon but
not wait for its completion. The job ID will be shown so that it can be
examined using **gnt-job info**.
The ``--print-job-id`` option makes the command print the job id as first
line on stdout, so that it is easy to parse by other programs.
Defaults
~~~~~~~~
......
......@@ -26,6 +26,7 @@ EXPORT
| **export** {-n *node*} [\--shutdown-timeout=*N*] [\--noshutdown]
| [\--remove-instance] [\--ignore-remove-failures] [\--submit]
| [\--print-job-id]
| {*instance*}
Exports an instance to the target node. All the instance data and
......@@ -75,7 +76,7 @@ IMPORT
| [-t [diskless | plain | drbd | file]]
| [\--identify-defaults]
| [\--ignore-ipolicy]
| [\--submit]
| [\--submit] [\--print-job-id]
| {*instance*}
Imports a new instance from an export residing on *source-node* in
......
......@@ -592,7 +592,7 @@ be 1.
MODIFY
~~~~~~
| **modify** [\--submit]
| **modify** [\--submit] [\--print-job-id]
| [\--vg-name *vg-name*]
| [\--enabled-hypervisors *hypervisors*]
| [{-H|\--hypervisor-parameters} *hypervisor*:*hv-param*=*value*[,*hv-param*=*value*...]]
......@@ -693,7 +693,7 @@ The ``info`` option shows whether the watcher is currently paused.
REDIST-CONF
~~~~~~~~~~~
**redist-conf** [\--submit]
**redist-conf** [\--submit] [\--print-job-id]
This command forces a full push of configuration files from the
master node to the other nodes in the cluster. This is normally not
......
......@@ -23,7 +23,7 @@ COMMANDS
ADD
~~~
| **add** [\--submit]
| **add** [\--submit] [\--print-job-id]
| [\--node-parameters=*NDPARAMS*]
| [\--alloc-policy=*POLICY*]
| [{-D|\--disk-parameters} *disk-template*:*disk-param*=*value*[,*disk-param*=*value*...]]
......@@ -75,7 +75,7 @@ ASSIGN-NODES
~~~~~~~~~~~~
| **assign-nodes**
| [\--force] [\--submit]
| [\--force] [\--submit] [\--print-job-id]
| {*group*} {*node*...}
Assigns one or more nodes to the specified group, moving them from their
......@@ -93,7 +93,7 @@ options.
MODIFY
~~~~~~
| **modify** [\--submit]
| **modify** [\--submit] [\--print-job-id]
| [\--node-parameters=*NDPARAMS*]
| [\--alloc-policy=*POLICY*]
| [\--hypervisor-state *hvstate*]
......@@ -124,7 +124,7 @@ options.
REMOVE
~~~~~~
| **remove** [\--submit] {*group*}
| **remove** [\--submit] [\--print-job-id] {*group*}
Deletes the indicated node group, which must be empty. There must always be at
least one group, so the last group cannot be removed.
......@@ -176,7 +176,7 @@ List available fields for node groups.
RENAME
~~~~~~
| **rename** [\--submit] {*oldname*} {*newname*}
| **rename** [\--submit] [\--print-job-id] {*oldname*} {*newname*}
Renames a given group from *oldname* to *newname*.
......@@ -187,7 +187,8 @@ options.
EVACUATE
~~~~~~~~
**evacuate** [\--submit] [\--iallocator *NAME*] [\--to *GROUP*...] {*group*}
| **evacuate** [\--submit] [\--print-job-id]
| [\--iallocator *NAME*] [\--to *GROUP*...] {*group*}
This command will move all instances out of the given node group.
Instances are placed in a new group by an iallocator, either given on
......
......@@ -40,7 +40,7 @@ ADD
| [\--file-storage-dir *dir\_path*] [\--file-driver {loop \| blktap}]
| {{-n|\--node} *node[:secondary-node]* \| {-I|\--iallocator} *name*}
| {{-o|\--os-type} *os-type*}
| [\--submit]
| [\--submit] [\--print-job-id]
| [\--ignore-ipolicy]
| {*instance*}
......@@ -945,8 +945,8 @@ follows::
REMOVE
^^^^^^
**remove** [\--ignore-failures] [\--shutdown-timeout=*N*] [\--submit]
[\--force] {*instance*}
| **remove** [\--ignore-failures] [\--shutdown-timeout=*N*] [\--submit]
| [\--print-job-id] [\--force] {*instance*}
Remove an instance. This will remove all data from the instance and
there is *no way back*. If you are not sure if you use an instance
......@@ -1076,7 +1076,7 @@ MODIFY
| [\--os-type=*OS* [\--force-variant]]
| [{-O|\--os-parameters} *param*=*value*... ]
| [\--offline \| \--online]
| [\--submit]
| [\--submit] [\--print-job-id]
| [\--ignore-ipolicy]
| {*instance*}
......@@ -1165,7 +1165,8 @@ REINSTALL
| **reinstall** [{-o|\--os-type} *os-type*] [\--select-os] [-f *force*]
| [\--force-multiple]
| [\--instance \| \--node \| \--primary \| \--secondary \| \--all]
| [{-O|\--os-parameters} *OS\_PARAMETERS*] [\--submit] {*instance*...}
| [{-O|\--os-parameters} *OS\_PARAMETERS*] [\--submit] [\--print-job-id]
| {*instance*...}
Reinstalls the operating system on the given instance(s). The
instance(s) must be stopped when running this command. If the ``-o
......@@ -1190,7 +1191,7 @@ options.
RENAME
^^^^^^
| **rename** [\--no-ip-check] [\--no-name-check] [\--submit]
| **rename** [\--no-ip-check] [\--no-name-check] [\--submit] [\--print-job-id]
| {*instance*} {*new\_name*}
Renames the given instance. The instance must be stopped when running
......@@ -1226,7 +1227,7 @@ STARTUP
| \--tags \| \--node-tags \| \--pri-node-tags \| \--sec-node-tags]
| [{-H|\--hypervisor-parameters} ``key=value...``]
| [{-B|\--backend-parameters} ``key=value...``]
| [\--submit] [\--paused]
| [\--submit] [\--print-job-id] [\--paused]
| {*name*...}
Starts one or more instances, depending on the following options. The
......@@ -1324,7 +1325,7 @@ SHUTDOWN
| [\--force] [\--force-multiple] [\--ignore-offline] [\--no-remember]
| [\--instance \| \--node \| \--primary \| \--secondary \| \--all \|
| \--tags \| \--node-tags \| \--pri-node-tags \| \--sec-node-tags]
| [\--submit]
| [\--submit] [\--print-job-id]