diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index c2673ccfcd282727dd54aae87d8a453b2f36e320..a7e9a7d34569b7c42a20cec2b2be082859bb3696 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 4c98617907a55602e4b6835193df6712b8b7c839..adf265170934740f9fe682087e39bffcb6f4476f 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,"