Commit 05d47e33 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-instance replace-disks: Add new --auto option


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 942be002
......@@ -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
......
......@@ -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,"
......
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