Revision 9b12ed0f
b/lib/cli.py | ||
---|---|---|
1546 | 1546 |
" information passed") |
1547 | 1547 |
disks = [] |
1548 | 1548 |
else: |
1549 |
if not opts.disks and not opts.sd_size: |
|
1549 |
if (not opts.disks and not opts.sd_size |
|
1550 |
and mode == constants.INSTANCE_CREATE): |
|
1550 | 1551 |
raise errors.OpPrereqError("No disk information specified") |
1551 | 1552 |
if opts.disks and opts.sd_size is not None: |
1552 | 1553 |
raise errors.OpPrereqError("Please use either the '--disk' or" |
1553 | 1554 |
" '-s' option") |
1554 | 1555 |
if opts.sd_size is not None: |
1555 | 1556 |
opts.disks = [(0, {"size": opts.sd_size})] |
1556 |
try: |
|
1557 |
disk_max = max(int(didx[0]) + 1 for didx in opts.disks) |
|
1558 |
except ValueError, err: |
|
1559 |
raise errors.OpPrereqError("Invalid disk index passed: %s" % str(err)) |
|
1560 |
disks = [{}] * disk_max |
|
1557 |
|
|
1558 |
if opts.disks: |
|
1559 |
try: |
|
1560 |
disk_max = max(int(didx[0]) + 1 for didx in opts.disks) |
|
1561 |
except ValueError, err: |
|
1562 |
raise errors.OpPrereqError("Invalid disk index passed: %s" % str(err)) |
|
1563 |
disks = [{}] * disk_max |
|
1564 |
else: |
|
1565 |
disks = [] |
|
1561 | 1566 |
for didx, ddict in opts.disks: |
1562 | 1567 |
didx = int(didx) |
1563 | 1568 |
if not isinstance(ddict, dict): |
b/lib/cmdlib.py | ||
---|---|---|
6265 | 6265 |
" is missing the disk_template information", |
6266 | 6266 |
errors.ECODE_INVAL) |
6267 | 6267 |
|
6268 |
if not self.op.disks: |
|
6269 |
if einfo.has_option(constants.INISECT_INS, "disk_count"): |
|
6270 |
disks = [] |
|
6271 |
# TODO: import the disk iv_name too |
|
6272 |
for idx in range(einfo.getint(constants.INISECT_INS, "disk_count")): |
|
6273 |
disk_sz = einfo.getint(constants.INISECT_INS, "disk%d_size" % idx) |
|
6274 |
disks.append({"size": disk_sz}) |
|
6275 |
self.op.disks = disks |
|
6276 |
else: |
|
6277 |
raise errors.OpPrereqError("No disk info specified and the export" |
|
6278 |
" is missing the disk information", |
|
6279 |
errors.ECODE_INVAL) |
|
6280 |
|
|
6268 | 6281 |
if (self.op.hypervisor is None and |
6269 | 6282 |
einfo.has_option(constants.INISECT_INS, "hypervisor")): |
6270 | 6283 |
self.op.hypervisor = einfo.get(constants.INISECT_INS, "hypervisor") |
Also available in: Unified diff