diff --git a/lib/cli.py b/lib/cli.py index 9cc095cc26b59765b866d820a7117c2214861f9e..4575b055cbaf6300f71c65eee8ec91d2a542f7a8 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -125,6 +125,7 @@ __all__ = [ "OSPARAMS_OPT", "OS_OPT", "OS_SIZE_OPT", + "PREALLOC_WIPE_DISKS_OPT", "PRIMARY_IP_VERSION_OPT", "PRIORITY_OPT", "RAPI_CERT_OPT", @@ -1082,6 +1083,12 @@ BLK_OS_OPT = cli_option("--blacklisted", dest="blacklisted", type="bool", default=None, metavar=_YORNO, help="Sets the blacklisted flag on the OS") +PREALLOC_WIPE_DISKS_OPT = cli_option("--prealloc-wipe-disks", default=None, + type="bool", metavar=_YORNO, + dest="prealloc_wipe_disks", + help=("Wipe disks prior to instance" + " creation")) + #: Options provided by all commands COMMON_OPTS = [DEBUG_OPT] diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 869d2a9a43cf5d49210be2bd329f1bf6eee472ad..f6ac72faf092a98a14c1d5a80e3768288cd79701 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2454,6 +2454,7 @@ class LUSetClusterParams(LogicalUnit): ("add_uids", None, ht.NoType), ("remove_uids", None, ht.NoType), ("maintain_node_health", None, ht.TMaybeBool), + ("prealloc_wipe_disks", None, ht.TMaybeBool), ("nicparams", None, ht.TOr(ht.TDict, ht.TNone)), ("drbd_helper", None, ht.TOr(ht.TString, ht.TNone)), ("default_iallocator", None, ht.TOr(ht.TString, ht.TNone)), @@ -2726,6 +2727,9 @@ class LUSetClusterParams(LogicalUnit): if self.op.maintain_node_health is not None: self.cluster.maintain_node_health = self.op.maintain_node_health + if self.op.prealloc_wipe_disks is not None: + self.cluster.prealloc_wipe_disks = self.op.prealloc_wipe_disks + if self.op.add_uids is not None: uidpool.AddToUidPool(self.cluster.uid_pool, self.op.add_uids) diff --git a/lib/opcodes.py b/lib/opcodes.py index 238a2a782fcf6c98c07f7393c4f3382963090fd3..dd4e093c80a09affa4ecd58933119143f5479f8b 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -318,6 +318,7 @@ class OpSetClusterParams(OpCode): "reserved_lvs", "hidden_os", "blacklisted_os", + "prealloc_wipe_disks", ] diff --git a/man/gnt-cluster.sgml b/man/gnt-cluster.sgml index 43d66086575390ad558098fd1ac8ebcd0cf022e6..c1a8bb1a35120befbf1f1ec50a1d383ee705daea 100644 --- a/man/gnt-cluster.sgml +++ b/man/gnt-cluster.sgml @@ -258,7 +258,7 @@ <sbr> <arg>--primary-ip-version <replaceable>version</replaceable></arg> <sbr> - <arg>--prealloc-wipe-disks</arg> + <arg>--prealloc-wipe-disks <group choice="req"><arg>yes</arg><arg>no</arg></group></arg> <sbr> <arg choice="req"><replaceable>clustername</replaceable></arg> </cmdsynopsis> @@ -658,6 +658,8 @@ <sbr> <arg>--maintain-node-health <group choice="req"><arg>yes</arg><arg>no</arg></group></arg> <sbr> + <arg choice="opt">--prealloc-wipe-disks <group choice="req"><arg>yes</arg><arg>no</arg></group></arg> + <sbr> <arg choice="opt">-I <replaceable>default instance allocator</replaceable></arg> <sbr> @@ -676,6 +678,7 @@ <option>--backend-parameters</option>, <option>--nic-parameters</option>, <option>--maintain-node-health</option>, + <option>--prealloc-wipe-disks</option>, <option>--uid-pool</option> options are described in the <command>init</command> command. </para> diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 4887bc187dbe13e50b0cc69d9c5fe487db12295a..2590c102d96027363c943f3cb85fea56dcb7ccbe 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -42,11 +42,6 @@ from ganeti import objects from ganeti import uidpool from ganeti import compat -PREALLOC_WIPE_DISKS_OPT = cli_option("--prealloc-wipe-disks", default=False, - action="store_true", - dest="prealloc_wipe_disks", - help=("Wipe disks prior to instance" - " creation")) @UsesRPC def InitCluster(opts, args): @@ -110,6 +105,9 @@ def InitCluster(opts, args): if uid_pool is not None: uid_pool = uidpool.ParseUidPool(uid_pool) + if opts.prealloc_wipe_disks is None: + opts.prealloc_wipe_disks = False + try: primary_ip_version = int(opts.primary_ip_version) except (ValueError, TypeError), err: @@ -716,7 +714,8 @@ def SetClusterParams(opts, args): opts.add_uids is not None or opts.remove_uids is not None or opts.default_iallocator is not None or - opts.reserved_lvs is not None): + opts.reserved_lvs is not None or + opts.prealloc_wipe_disks is not None): ToStderr("Please give at least one of the parameters.") return 1 @@ -785,6 +784,7 @@ def SetClusterParams(opts, args): add_uids=add_uids, remove_uids=remove_uids, default_iallocator=opts.default_iallocator, + prealloc_wipe_disks=opts.prealloc_wipe_disks, reserved_lvs=opts.reserved_lvs) SubmitOpCode(op, opts=opts) return 0 @@ -945,7 +945,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, PRIORITY_OPT], + DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT], "[opts...]", "Alters the parameters of the cluster"), "renew-crypto": (