From 05d47e331790ae95e0900ea6a23f23bf0c8e2eec Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 12 Aug 2009 17:51:24 +0200 Subject: [PATCH] gnt-instance replace-disks: Add new --auto option Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- man/gnt-instance.sgml | 16 ++++++++++++++++ scripts/gnt-instance | 13 +++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index c2673ccfc..a7e9a7d34 100644 --- a/man/gnt-instance.sgml +++ b/man/gnt-instance.sgml @@ -1666,6 +1666,13 @@ instance5: 11225 <arg choice="req"><replaceable>instance</replaceable></arg> </cmdsynopsis> + <cmdsynopsis> + <command>replace-disks</command> + <arg>--submit</arg> + <arg choice="req">--auto</arg> + <arg choice="req"><replaceable>instance</replaceable></arg> + </cmdsynopsis> + <para> This command is a generalized form for replacing disks. It is currently only valid for the mirrored (DRBD) disk @@ -1696,6 +1703,15 @@ instance5: 11225 manually via the <option>--new-secondary</option> option. </para> + <para> + The fourth form (when using <option>--auto</option>) will + automatically determine which disks of an instance are faulty and + replace them within the same node. The <option>--auto</option> + option works only when an instance has only faulty disks on + either the primary or secondary node; it doesn't work when + both sides have faulty disks. + </para> + <para> The <option>--submit</option> option is used to send the job to the master daemon but not wait for its completion. The job diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 4c9861790..adf265170 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -826,15 +826,20 @@ def ReplaceDisks(opts, args): disks = [int(i) for i in opts.disks.split(",")] except ValueError, err: raise errors.OpPrereqError("Invalid disk index passed: %s" % str(err)) - cnt = [opts.on_primary, opts.on_secondary, + cnt = [opts.on_primary, opts.on_secondary, opts.auto, new_2ndary is not None, iallocator is not None].count(True) if cnt != 1: - raise errors.OpPrereqError("One and only one of the -p, -s, -n and -i" + raise errors.OpPrereqError("One and only one of the -p, -s, -a, -n and -i" " options must be passed") elif opts.on_primary: mode = constants.REPLACE_DISK_PRI elif opts.on_secondary: mode = constants.REPLACE_DISK_SEC + elif opts.auto: + mode = constants.REPLACE_DISK_AUTO + if disks: + raise errors.OpPrereqError("Cannot specify disks when using automatic" + " mode") elif new_2ndary is not None or iallocator is not None: # replace secondary mode = constants.REPLACE_DISK_CHG @@ -1463,6 +1468,10 @@ commands = { default=False, action="store_true", help=("Replace the disk(s) on the secondary" " node (only for the drbd template)")), + make_option("-a", "--auto", dest="auto", + default=False, action="store_true", + help=("Automatically replace faulty disks" + " (only for the drbd template)")), make_option("--disks", dest="disks", default=None, help="Comma-separated list of disks" " indices to replace (e.g. 0,2) (optional," -- GitLab