Revision 735e1318 lib/client/gnt_instance.py
b/lib/client/gnt_instance.py | ||
---|---|---|
39 | 39 |
from ganeti import netutils |
40 | 40 |
from ganeti import ssh |
41 | 41 |
from ganeti import objects |
42 |
from ganeti import ht |
|
42 | 43 |
|
43 | 44 |
|
44 | 45 |
_EXPAND_CLUSTER = "cluster" |
... | ... | |
601 | 602 |
|
602 | 603 |
""" |
603 | 604 |
instance_name = args[0] |
605 |
|
|
606 |
disks = [] |
|
607 |
|
|
604 | 608 |
if opts.disks: |
605 |
try: |
|
606 |
opts.disks = [int(v) for v in opts.disks.split(",")] |
|
607 |
except (ValueError, TypeError), err: |
|
608 |
ToStderr("Invalid disks value: %s" % str(err)) |
|
609 |
return 1 |
|
610 |
else: |
|
611 |
opts.disks = [] |
|
609 |
for didx, ddict in opts.disks: |
|
610 |
didx = int(didx) |
|
611 |
|
|
612 |
if not ht.TDict(ddict): |
|
613 |
msg = "Invalid disk/%d value: expected dict, got %s" % (didx, ddict) |
|
614 |
raise errors.OpPrereqError(msg) |
|
615 |
|
|
616 |
if constants.IDISK_SIZE in ddict: |
|
617 |
try: |
|
618 |
ddict[constants.IDISK_SIZE] = \ |
|
619 |
utils.ParseUnit(ddict[constants.IDISK_SIZE]) |
|
620 |
except ValueError, err: |
|
621 |
raise errors.OpPrereqError("Invalid disk size for disk %d: %s" % |
|
622 |
(didx, err)) |
|
623 |
|
|
624 |
disks.append((didx, ddict)) |
|
625 |
|
|
626 |
# TODO: Verify modifyable parameters (already done in |
|
627 |
# LUInstanceRecreateDisks, but it'd be nice to have in the client) |
|
612 | 628 |
|
613 | 629 |
if opts.node: |
614 | 630 |
pnode, snode = SplitNodeOption(opts.node) |
... | ... | |
619 | 635 |
nodes = [] |
620 | 636 |
|
621 | 637 |
op = opcodes.OpInstanceRecreateDisks(instance_name=instance_name, |
622 |
disks=opts.disks, |
|
623 |
nodes=nodes) |
|
638 |
disks=disks, nodes=nodes) |
|
624 | 639 |
SubmitOrSend(op, opts) |
640 |
|
|
625 | 641 |
return 0 |
626 | 642 |
|
627 | 643 |
|
... | ... | |
1545 | 1561 |
"[-f] <instance>", "Deactivate an instance's disks"), |
1546 | 1562 |
"recreate-disks": ( |
1547 | 1563 |
RecreateDisks, ARGS_ONE_INSTANCE, |
1548 |
[SUBMIT_OPT, DISKIDX_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT],
|
|
1564 |
[SUBMIT_OPT, DISK_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT], |
|
1549 | 1565 |
"<instance>", "Recreate an instance's disks"), |
1550 | 1566 |
"grow-disk": ( |
1551 | 1567 |
GrowDisk, |
Also available in: Unified diff