Commit db5a8a2d authored by Iustin Pop's avatar Iustin Pop

Explicitly add dry-run to some commands

Based on manual inspection (that the command only does a submit of some
jobs/opcodes), we re-add the dry-run option on a subset of the existing
commands.

A few more commands could use dry-run, but the code doesn't deal nicely
with no results, so fixing those is left for later patches.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent a0a6ff34
#!/usr/bin/python
#
# Copyright (C) 2006, 2007 Google Inc.
# Copyright (C) 2006, 2007, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -136,6 +136,7 @@ import_opts = [
SRC_DIR_OPT,
SRC_NODE_OPT,
SUBMIT_OPT,
DRY_RUN_OPT,
]
......@@ -147,7 +148,7 @@ commands = {
'export': (
ExportInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SINGLE_NODE_OPT, NOSHUTDOWN_OPT, SHUTDOWN_TIMEOUT_OPT,
REMOVE_INSTANCE_OPT, IGNORE_REMOVE_FAILURES_OPT],
REMOVE_INSTANCE_OPT, IGNORE_REMOVE_FAILURES_OPT, DRY_RUN_OPT],
"-n <target_node> [opts...] <name>",
"Exports an instance to an image"),
'import': (
......@@ -155,7 +156,7 @@ commands = {
"[...] -t disk-type -n node[:secondary-node] <name>",
"Imports an instance from an exported image"),
'remove': (
RemoveExport, [ArgUnknown(min=1, max=1)], [],
RemoveExport, [ArgUnknown(min=1, max=1)], [DRY_RUN_OPT],
"<name>", "Remove exports of named instance from the filesystem."),
}
......
#!/usr/bin/python
#
# Copyright (C) 2006, 2007 Google Inc.
# Copyright (C) 2006, 2007, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -856,22 +856,23 @@ commands = {
"", "Destroy cluster"),
'rename': (
RenameCluster, [ArgHost(min=1, max=1)],
[FORCE_OPT],
[FORCE_OPT, DRY_RUN_OPT],
"<new_name>",
"Renames the cluster"),
'redist-conf': (
RedistributeConfig, ARGS_NONE, [SUBMIT_OPT],
RedistributeConfig, ARGS_NONE, [SUBMIT_OPT, DRY_RUN_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],
[VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT,
DRY_RUN_OPT],
"", "Does a check on the cluster configuration"),
'verify-disks': (
VerifyDisks, ARGS_NONE, [],
"", "Does a check on the cluster disk status"),
'repair-disk-sizes': (
RepairDiskSizes, ARGS_MANY_INSTANCES, [],
RepairDiskSizes, ARGS_MANY_INSTANCES, [DRY_RUN_OPT],
"", "Updates mismatches in recorded disk sizes"),
'master-failover': (
MasterFailover, ARGS_NONE, [NOVOTING_OPT],
......@@ -923,7 +924,8 @@ commands = {
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
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],
NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT,
DRY_RUN_OPT],
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
......
#!/usr/bin/python
#
# Copyright (C) 2006, 2007 Google Inc.
# Copyright (C) 2006, 2007, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -407,6 +407,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,
],
"[opts...] <duration>", "Executes a TestDelay OpCode"),
'submit-job': (
......@@ -420,6 +421,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,
],
"<op_list_file...>", "Submits jobs built from json files"
" containing a list of serialized opcodes"),
......@@ -447,6 +449,7 @@ commands = {
help="Select number of VCPUs for the instance"),
cli_option("--tags", default=None,
help="Comma separated list of tags"),
DRY_RUN_OPT,
],
"{opts...} <instance>", "Executes a TestAllocator OpCode"),
"test-jobqueue": (
......
......@@ -1402,6 +1402,7 @@ add_opts = [
NO_INSTALL_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
DRY_RUN_OPT,
]
commands = {
......@@ -1410,7 +1411,7 @@ 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)], [],
BatchCreate, [ArgFile(min=1, max=1)], [DRY_RUN_OPT],
"<instances.json>",
"Create a bunch of instances based on specs in the file."),
'console': (
......@@ -1419,17 +1420,19 @@ 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_OPT, SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_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],
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, CLEANUP_OPT, DRY_RUN_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],
[FORCE_OPT, SUBMIT_OPT, SINGLE_NODE_OPT, SHUTDOWN_TIMEOUT_OPT,
DRY_RUN_OPT],
"[-f] <instance>", "Move instance to an arbitrary node"
" (only for instances of type file and lv)"),
'info': (
......@@ -1459,63 +1462,67 @@ 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],
SUBMIT_OPT, DRY_RUN_OPT],
"[-f] <instance>", "Reinstall a stopped instance"),
'remove': (
RemoveInstance, ARGS_ONE_INSTANCE,
[FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT, SUBMIT_OPT],
[FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT, SUBMIT_OPT,
DRY_RUN_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],
[NOIPCHECK_OPT, NONAMECHECK_OPT, SUBMIT_OPT, DRY_RUN_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],
NEW_SECONDARY_OPT, ON_PRIMARY_OPT, ON_SECONDARY_OPT, SUBMIT_OPT,
DRY_RUN_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],
OSPARAMS_OPT, DRY_RUN_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],
m_inst_tags_opt, m_inst_opt, m_force_multi, TIMEOUT_OPT, SUBMIT_OPT,
DRY_RUN_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],
BACKEND_OPT, DRY_RUN_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],
m_inst_tags_opt, SHUTDOWN_TIMEOUT_OPT, DRY_RUN_OPT],
"<instance>", "Reboots an instance"),
'activate-disks': (
ActivateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, IGNORE_SIZE_OPT],
ActivateDisks, ARGS_ONE_INSTANCE,
[SUBMIT_OPT, IGNORE_SIZE_OPT],
"<instance>", "Activate an instance's disks"),
'deactivate-disks': (
DeactivateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT],
DeactivateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DRY_RUN_OPT],
"<instance>", "Deactivate an instance's disks"),
'recreate-disks': (
RecreateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DISKIDX_OPT],
RecreateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DISKIDX_OPT, DRY_RUN_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],
[SUBMIT_OPT, NWSYNC_OPT, DRY_RUN_OPT],
"<instance> <disk> <size>", "Grow an instance's disk"),
'list-tags': (
ListTags, ARGS_ONE_INSTANCE, [],
......
......@@ -679,14 +679,14 @@ commands = {
'modify': (
SetNodeParams, ARGS_ONE_NODE,
[FORCE_OPT, SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT,
AUTO_PROMOTE_OPT],
AUTO_PROMOTE_OPT, DRY_RUN_OPT],
"<node_name>", "Alters the parameters of a node"),
'powercycle': (
PowercycleNode, ARGS_ONE_NODE,
[FORCE_OPT, CONFIRM_OPT],
[FORCE_OPT, CONFIRM_OPT, DRY_RUN_OPT],
"<node_name>", "Tries to forcefully powercycle a node"),
'remove': (
RemoveNode, ARGS_ONE_NODE, [],
RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT],
"<node_name>", "Removes a node from the cluster"),
'volumes': (
ListVolumes, [ArgNode()],
......@@ -703,14 +703,14 @@ commands = {
[ArgNode(min=1, max=1),
ArgChoice(min=1, max=1, choices=_MODIFIABLE_STORAGE_TYPES),
ArgFile(min=1, max=1)],
[ALLOCATABLE_OPT],
[ALLOCATABLE_OPT, DRY_RUN_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],
[IGNORE_CONSIST_OPT, DRY_RUN_OPT],
"<node_name> <storage_type> <name>",
"Repairs a storage volume on a node"),
'list-tags': (
......
#!/usr/bin/python
#
# Copyright (C) 2006, 2007 Google Inc.
# Copyright (C) 2006, 2007, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -269,7 +269,7 @@ commands = {
ShowOSInfo, [ArgOs()], [], "", "Show detailed information about "
"operating systems"),
'modify': (
ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT], "",
ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT], "",
"Modify the OS parameters"),
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment