diff --git a/lib/cli.py b/lib/cli.py index 566dc47d6e4dbe9e3d12b080782e4e2b7d3d8cfb..e2d57024b60439b5b3f7cfecbce4a240c749f915 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -1064,7 +1064,7 @@ PRIMARY_IP_VERSION_OPT = \ PRIORITY_OPT = cli_option("--priority", default=None, dest="priority", metavar="|".join(name for name, _ in _PRIORITY_NAMES), choices=_PRIONAME_TO_VALUE.keys(), - help="Priority for opcode(s) processing") + help="Priority for opcode processing") #: Options provided by all commands COMMON_OPTS = [DEBUG_OPT] @@ -1657,9 +1657,11 @@ def SetGenericOpcodeOpts(opcode_list, options): if not options: return for op in opcode_list: + op.debug_level = options.debug if hasattr(options, "dry_run"): op.dry_run = options.dry_run - op.debug_level = options.debug + if getattr(options, "priority", None) is not None: + op.priority = _PRIONAME_TO_VALUE[options.priority] def GetClient(): diff --git a/scripts/gnt-backup b/scripts/gnt-backup index 877933af3f0b4eb208014e7210be48a984baa7a8..9fd3aa774b2edd4bc7dfd0e3859bc5393522a5e8 100755 --- a/scripts/gnt-backup +++ b/scripts/gnt-backup @@ -137,6 +137,7 @@ import_opts = [ SRC_NODE_OPT, SUBMIT_OPT, DRY_RUN_OPT, + PRIORITY_OPT, ] @@ -148,7 +149,8 @@ commands = { 'export': ( ExportInstance, ARGS_ONE_INSTANCE, [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], "-n <target_node> [opts...] <name>", "Exports an instance to an image"), 'import': ( @@ -156,7 +158,7 @@ commands = { "[...] -t disk-type -n node[:secondary-node] <name>", "Imports an instance from an exported image"), 'remove': ( - RemoveExport, [ArgUnknown(min=1, max=1)], [DRY_RUN_OPT], + RemoveExport, [ArgUnknown(min=1, max=1)], [DRY_RUN_OPT, PRIORITY_OPT], "<name>", "Remove exports of named instance from the filesystem."), } diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 484e830f2369d78479e4658f88331b7a1ac3734a..422b404f40b0a1f5a7fe4fbbfe9268eed319ec44 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -868,19 +868,19 @@ commands = { "<new_name>", "Renames the cluster"), 'redist-conf': ( - RedistributeConfig, ARGS_NONE, [SUBMIT_OPT, DRY_RUN_OPT], + RedistributeConfig, ARGS_NONE, [SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], "", "Forces a push of the configuration file and ssconf files" " to the nodes in the cluster"), 'verify': ( VerifyCluster, ARGS_NONE, [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT, - DRY_RUN_OPT], + DRY_RUN_OPT, PRIORITY_OPT], "", "Does a check on the cluster configuration"), 'verify-disks': ( - VerifyDisks, ARGS_NONE, [], + VerifyDisks, ARGS_NONE, [PRIORITY_OPT], "", "Does a check on the cluster disk status"), 'repair-disk-sizes': ( - RepairDiskSizes, ARGS_MANY_INSTANCES, [DRY_RUN_OPT], + RepairDiskSizes, ARGS_MANY_INSTANCES, [DRY_RUN_OPT, PRIORITY_OPT], "", "Updates mismatches in recorded disk sizes"), 'master-failover': ( MasterFailover, ARGS_NONE, [NOVOTING_OPT], @@ -908,14 +908,14 @@ commands = { 'list-tags': ( ListTags, ARGS_NONE, [], "", "List the tags of the cluster"), 'add-tags': ( - AddTags, [ArgUnknown()], [TAG_SRC_OPT], + AddTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT], "tag...", "Add tags to the cluster"), 'remove-tags': ( - RemoveTags, [ArgUnknown()], [TAG_SRC_OPT], + RemoveTags, [ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT], "tag...", "Remove tags from the cluster"), 'search-tags': ( - SearchTags, [ArgUnknown(min=1, max=1)], - [], "", "Searches the tags on all objects on" + SearchTags, [ArgUnknown(min=1, max=1)], [PRIORITY_OPT], "", + "Searches the tags on all objects on" " the cluster for a given pattern (regex)"), 'queue': ( QueueOps, @@ -933,7 +933,7 @@ commands = { NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT, - DRY_RUN_OPT], + DRY_RUN_OPT, PRIORITY_OPT], "[opts...]", "Alters the parameters of the cluster"), "renew-crypto": ( diff --git a/scripts/gnt-debug b/scripts/gnt-debug index e54a34a657fc3fbde34fbc681f76ba51b58018bf..fe8637f3b198363debd955132d7b9a2e68ee7f0d 100755 --- a/scripts/gnt-debug +++ b/scripts/gnt-debug @@ -471,7 +471,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, + DRY_RUN_OPT, PRIORITY_OPT, ], "[opts...] <duration>", "Executes a TestDelay OpCode"), 'submit-job': ( @@ -485,7 +485,7 @@ commands = { action="store_true", help="Show timing stats"), cli_option("--each", default=False, action="store_true", help="Submit each job separately"), - DRY_RUN_OPT, + DRY_RUN_OPT, PRIORITY_OPT, ], "<op_list_file...>", "Submits jobs built from json files" " containing a list of serialized opcodes"), @@ -513,11 +513,11 @@ commands = { help="Select number of VCPUs for the instance"), cli_option("--tags", default=None, help="Comma separated list of tags"), - DRY_RUN_OPT, + DRY_RUN_OPT, PRIORITY_OPT, ], "{opts...} <instance>", "Executes a TestAllocator OpCode"), "test-jobqueue": ( - TestJobqueue, ARGS_NONE, [], + TestJobqueue, ARGS_NONE, [PRIORITY_OPT], "", "Test a few aspects of the job queue"), "locks": ( ListLocks, ARGS_NONE, [NOHDR_OPT, SEP_OPT, FIELDS_OPT, INTERVAL_OPT], diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 8bab26e074f1de0feb6488080883a205ef8e2262..3c7e0663e9cf8cd4269b4a12dce738d55ae50d97 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -1398,6 +1398,7 @@ add_opts = [ OS_SIZE_OPT, SUBMIT_OPT, DRY_RUN_OPT, + PRIORITY_OPT, ] commands = { @@ -1406,33 +1407,34 @@ commands = { "[...] -t disk-type -n node[:secondary-node] -o os-type <name>", "Creates and adds a new instance to the cluster"), 'batch-create': ( - BatchCreate, [ArgFile(min=1, max=1)], [DRY_RUN_OPT], + BatchCreate, [ArgFile(min=1, max=1)], [DRY_RUN_OPT, PRIORITY_OPT], "<instances.json>", "Create a bunch of instances based on specs in the file."), 'console': ( ConnectToInstanceConsole, ARGS_ONE_INSTANCE, - [SHOWCMD_OPT], + [SHOWCMD_OPT, PRIORITY_OPT], "[--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, - DRY_RUN_OPT], + DRY_RUN_OPT, PRIORITY_OPT], "[-f] <instance>", "Stops the instance and starts it on the backup node," " using the remote mirror (only for instances of type drbd)"), 'migrate': ( 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], "[-f] <instance>", "Migrate instance to its secondary node" " (only for instances of type drbd)"), 'move': ( MoveInstance, ARGS_ONE_INSTANCE, [FORCE_OPT, SUBMIT_OPT, SINGLE_NODE_OPT, SHUTDOWN_TIMEOUT_OPT, - DRY_RUN_OPT], + DRY_RUN_OPT, PRIORITY_OPT], "[-f] <instance>", "Move instance to an arbitrary node" " (only for instances of type file and lv)"), 'info': ( ShowInstanceConfig, ARGS_MANY_INSTANCES, - [STATIC_OPT, ALL_OPT, ROMAN_OPT], + [STATIC_OPT, ALL_OPT, ROMAN_OPT, PRIORITY_OPT], "[-s] {--all | <instance>...}", "Show information on the specified instance(s)"), 'list': ( @@ -1457,78 +1459,80 @@ commands = { [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], + SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_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], + 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], + [NOIPCHECK_OPT, NONAMECHECK_OPT, SUBMIT_OPT, 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], + DRY_RUN_OPT, PRIORITY_OPT], "[-s|-p|-n NODE|-I NAME] <instance>", "Replaces all 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, - OSPARAMS_OPT, DRY_RUN_OPT], + OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<instance>", "Alters the parameters of an instance"), 'shutdown': ( GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()], [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], + DRY_RUN_OPT, PRIORITY_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, - BACKEND_OPT, DRY_RUN_OPT], + BACKEND_OPT, DRY_RUN_OPT, PRIORITY_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_inst_tags_opt, SHUTDOWN_TIMEOUT_OPT, DRY_RUN_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], + [SUBMIT_OPT, IGNORE_SIZE_OPT, PRIORITY_OPT], "<instance>", "Activate an instance's disks"), 'deactivate-disks': ( - DeactivateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DRY_RUN_OPT], + DeactivateDisks, ARGS_ONE_INSTANCE, + [SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<instance>", "Deactivate an instance's disks"), 'recreate-disks': ( - RecreateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DISKIDX_OPT, DRY_RUN_OPT], + RecreateDisks, ARGS_ONE_INSTANCE, + [SUBMIT_OPT, DISKIDX_OPT, DRY_RUN_OPT, PRIORITY_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], + [SUBMIT_OPT, NWSYNC_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<instance> <disk> <size>", "Grow an instance's disk"), 'list-tags': ( - ListTags, ARGS_ONE_INSTANCE, [], + ListTags, ARGS_ONE_INSTANCE, [PRIORITY_OPT], "<instance_name>", "List the tags of the given instance"), 'add-tags': ( AddTags, [ArgInstance(min=1, max=1), ArgUnknown()], - [TAG_SRC_OPT], + [TAG_SRC_OPT, PRIORITY_OPT], "<instance_name> tag...", "Add tags to the given instance"), 'remove-tags': ( RemoveTags, [ArgInstance(min=1, max=1), ArgUnknown()], - [TAG_SRC_OPT], + [TAG_SRC_OPT, PRIORITY_OPT], "<instance_name> tag...", "Remove tags from given instance"), } diff --git a/scripts/gnt-node b/scripts/gnt-node index cd17ad034899fa6ae77bb9994c8d75765a6e6f01..d4e7d6b9f13467733126f75551bbf928b6d39392 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -674,23 +674,25 @@ commands = { 'add': ( AddNode, [ArgHost(min=1, max=1)], [SECONDARY_IP_OPT, READD_OPT, NOSSH_KEYCHECK_OPT, NONODE_SETUP_OPT, - VERBOSE_OPT, NODEGROUP_OPT], + VERBOSE_OPT, NODEGROUP_OPT, PRIORITY_OPT], "[-s ip] [--readd] [--no-ssh-key-check] [--no-node-setup] [--verbose] " " <node_name>", "Add a node to the cluster"), 'evacuate': ( EvacuateNode, [ArgNode(min=1)], - [FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT], + [FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT, + PRIORITY_OPT], "[-f] {-I <iallocator> | -n <dst>} <node>", "Relocate the secondary instances from a node" " to other nodes (only for instances with drbd disk template)"), 'failover': ( - FailoverNode, ARGS_ONE_NODE, [FORCE_OPT, IGNORE_CONSIST_OPT], + FailoverNode, ARGS_ONE_NODE, [FORCE_OPT, IGNORE_CONSIST_OPT, PRIORITY_OPT], "[-f] <node>", "Stops the primary instances on a node and start them on their" " secondary node (only for instances with drbd disk template)"), 'migrate': ( - MigrateNode, ARGS_ONE_NODE, [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT], + MigrateNode, ARGS_ONE_NODE, + [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, PRIORITY_OPT], "[-f] <node>", "Migrate all the primary instance on a node away from it" " (only for instances of type drbd)"), @@ -707,22 +709,23 @@ commands = { 'modify': ( SetNodeParams, ARGS_ONE_NODE, [FORCE_OPT, SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT, - AUTO_PROMOTE_OPT, DRY_RUN_OPT], + AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<node_name>", "Alters the parameters of a node"), 'powercycle': ( PowercycleNode, ARGS_ONE_NODE, - [FORCE_OPT, CONFIRM_OPT, DRY_RUN_OPT], + [FORCE_OPT, CONFIRM_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<node_name>", "Tries to forcefully powercycle a node"), 'remove': ( - RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT], + RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT, PRIORITY_OPT], "<node_name>", "Removes a node from the cluster"), 'volumes': ( ListVolumes, [ArgNode()], - [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], + [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, PRIORITY_OPT], "[<node_name>...]", "List logical volumes on node(s)"), 'list-storage': ( ListStorage, ARGS_MANY_NODES, - [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, _STORAGE_TYPE_OPT], + [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, _STORAGE_TYPE_OPT, + PRIORITY_OPT], "[<node_name>...]", "List physical volumes on node(s). The available" " fields are (see the man page for details): %s." % (utils.CommaJoin(_LIST_STOR_HEADERS))), @@ -731,24 +734,25 @@ 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], + [ALLOCATABLE_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<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], + [IGNORE_CONSIST_OPT, DRY_RUN_OPT, PRIORITY_OPT], "<node_name> <storage_type> <name>", "Repairs a storage volume on a node"), 'list-tags': ( ListTags, ARGS_ONE_NODE, [], "<node_name>", "List the tags of the given node"), 'add-tags': ( - AddTags, [ArgNode(min=1, max=1), ArgUnknown()], [TAG_SRC_OPT], + AddTags, [ArgNode(min=1, max=1), ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT], "<node_name> tag...", "Add tags to the given node"), 'remove-tags': ( - RemoveTags, [ArgNode(min=1, max=1), ArgUnknown()], [TAG_SRC_OPT], + RemoveTags, [ArgNode(min=1, max=1), ArgUnknown()], + [TAG_SRC_OPT, PRIORITY_OPT], "<node_name> tag...", "Remove tags from the given node"), } diff --git a/scripts/gnt-os b/scripts/gnt-os index d07d75ce849a5da974a6ca2d62b76f1837deb4eb..6d0591bbf95299a8182ccb9698dd4197d675394d 100755 --- a/scripts/gnt-os +++ b/scripts/gnt-os @@ -261,16 +261,19 @@ def ModifyOS(opts, args): commands = { 'list': ( - ListOS, ARGS_NONE, [NOHDR_OPT], "", "Lists all valid operating systems" - " on the cluster"), + ListOS, ARGS_NONE, [NOHDR_OPT, PRIORITY_OPT], + "", "Lists all valid operating systems on the cluster"), 'diagnose': ( - DiagnoseOS, ARGS_NONE, [], "", "Diagnose all operating systems"), + DiagnoseOS, ARGS_NONE, [PRIORITY_OPT], + "", "Diagnose all operating systems"), 'info': ( - ShowOSInfo, [ArgOs()], [], "", "Show detailed information about " + ShowOSInfo, [ArgOs()], [PRIORITY_OPT], + "", "Show detailed information about " "operating systems"), 'modify': ( - ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT], "", - "Modify the OS parameters"), + ModifyOS, ARGS_ONE_OS, + [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT], + "", "Modify the OS parameters"), } if __name__ == '__main__':