Revision 7e9366f7 scripts/gnt-instance
b/scripts/gnt-instance | ||
---|---|---|
772 | 772 |
disks = [int(i) for i in opts.disks.split(",")] |
773 | 773 |
except ValueError, err: |
774 | 774 |
raise errors.OpPrereqError("Invalid disk index passed: %s" % str(err)) |
775 |
if opts.on_primary == opts.on_secondary: # no -p or -s passed, or both passed |
|
776 |
mode = constants.REPLACE_DISK_ALL |
|
777 |
elif opts.on_primary: # only on primary: |
|
775 |
cnt = [opts.on_primary, opts.on_secondary, |
|
776 |
new_2ndary is not None, iallocator is not None].count(True) |
|
777 |
if cnt != 1: |
|
778 |
raise errors.OpPrereqError("One and only one of the -p, -s, -n and -i" |
|
779 |
" options must be passed") |
|
780 |
elif opts.on_primary: |
|
778 | 781 |
mode = constants.REPLACE_DISK_PRI |
779 |
if new_2ndary is not None or iallocator is not None: |
|
780 |
raise errors.OpPrereqError("Can't change secondary node on primary disk" |
|
781 |
" replacement") |
|
782 |
elif opts.on_secondary is not None or iallocator is not None: |
|
783 |
# only on secondary |
|
782 |
elif opts.on_secondary: |
|
784 | 783 |
mode = constants.REPLACE_DISK_SEC |
784 |
elif new_2ndary is not None or iallocator is not None: |
|
785 |
# replace secondary |
|
786 |
mode = constants.REPLACE_DISK_CHG |
|
785 | 787 |
|
786 | 788 |
op = opcodes.OpReplaceDisks(instance_name=args[0], disks=disks, |
787 | 789 |
remote_node=new_2ndary, mode=mode, |
... | ... | |
1254 | 1256 |
[DEBUG_OPT, |
1255 | 1257 |
make_option("-n", "--new-secondary", dest="new_secondary", |
1256 | 1258 |
help=("New secondary node (for secondary" |
1257 |
" node change)"), metavar="NODE"), |
|
1259 |
" node change)"), metavar="NODE", |
|
1260 |
default=None), |
|
1258 | 1261 |
make_option("-p", "--on-primary", dest="on_primary", |
1259 | 1262 |
default=False, action="store_true", |
1260 | 1263 |
help=("Replace the disk(s) on the primary" |
... | ... | |
1267 | 1270 |
help=("Comma-separated list of disks" |
1268 | 1271 |
" to replace (e.g. sda) (optional," |
1269 | 1272 |
" defaults to all disks")), |
1270 |
make_option("--iallocator", metavar="<NAME>", |
|
1273 |
make_option("-i", "--iallocator", metavar="<NAME>",
|
|
1271 | 1274 |
help="Select new secondary for the instance" |
1272 | 1275 |
" automatically using the" |
1273 | 1276 |
" <NAME> iallocator plugin (enables" |
Also available in: Unified diff