Revision 6c626518 lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
275 | 275 |
|
276 | 276 |
""" |
277 | 277 |
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: |
278 |
raise ValueError("Invalid configuration data %s" % str(unique_id)) |
|
278 |
raise errors.ProgrammerError("Invalid configuration data %s" % |
|
279 |
str(unique_id)) |
|
279 | 280 |
vg_name, lv_name = unique_id |
280 | 281 |
pvs_info = cls.GetPVInfo(vg_name) |
281 | 282 |
if not pvs_info: |
... | ... | |
295 | 296 |
result = utils.RunCmd(["lvcreate", "-L%dm" % size, "-n%s" % lv_name, |
296 | 297 |
vg_name] + pvlist) |
297 | 298 |
if result.failed: |
298 |
raise errors.BlockDeviceError("%s - %s" % (result.fail_reason,
|
|
299 |
result.output))
|
|
299 |
raise errors.BlockDeviceError("LV create failed (%s): %s" %
|
|
300 |
(result.fail_reason, result.output))
|
|
300 | 301 |
return LogicalVolume(unique_id, children) |
301 | 302 |
|
302 | 303 |
@staticmethod |
... | ... | |
1646 | 1647 |
@return: an instance of FileStorage |
1647 | 1648 |
|
1648 | 1649 |
""" |
1650 |
# TODO: decide whether we should check for existing files and |
|
1651 |
# abort or not |
|
1649 | 1652 |
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: |
1650 | 1653 |
raise ValueError("Invalid configuration data %s" % str(unique_id)) |
1651 | 1654 |
dev_path = unique_id[1] |
1652 | 1655 |
try: |
1653 | 1656 |
f = open(dev_path, 'w') |
1654 |
except IOError, err: |
|
1655 |
raise errors.BlockDeviceError("Could not create '%'" % err) |
|
1656 |
else: |
|
1657 | 1657 |
f.truncate(size * 1024 * 1024) |
1658 | 1658 |
f.close() |
1659 |
except IOError, err: |
|
1660 |
raise errors.BlockDeviceError("Error in file creation: %" % str(err)) |
|
1659 | 1661 |
|
1660 | 1662 |
return FileStorage(unique_id, children) |
1661 | 1663 |
|
Also available in: Unified diff