Revision 9c793cfb lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
758 | 758 |
""" |
759 | 759 |
result = utils.RunCmd(["blockdev", "--getsize", meta_device]) |
760 | 760 |
if result.failed: |
761 |
logging.error("Failed to get device size: %s - %s", |
|
762 |
result.fail_reason, result.output) |
|
763 |
return False |
|
761 |
_ThrowError("Failed to get device size: %s - %s", |
|
762 |
result.fail_reason, result.output) |
|
764 | 763 |
try: |
765 | 764 |
sectors = int(result.stdout) |
766 | 765 |
except ValueError: |
767 |
logging.error("Invalid output from blockdev: '%s'", result.stdout) |
|
768 |
return False |
|
766 |
_ThrowError("Invalid output from blockdev: '%s'", result.stdout) |
|
769 | 767 |
bytes = sectors * 512 |
770 | 768 |
if bytes < 128 * 1024 * 1024: # less than 128MiB |
771 |
logging.error("Meta device too small (%.2fMib)", (bytes / 1024 / 1024)) |
|
772 |
return False |
|
769 |
_ThrowError("Meta device too small (%.2fMib)", (bytes / 1024 / 1024)) |
|
773 | 770 |
if bytes > (128 + 32) * 1024 * 1024: # account for an extra (big) PE on LVM |
774 |
logging.error("Meta device too big (%.2fMiB)", (bytes / 1024 / 1024)) |
|
775 |
return False |
|
776 |
return True |
|
771 |
_ThrowError("Meta device too big (%.2fMiB)", (bytes / 1024 / 1024)) |
|
777 | 772 |
|
778 | 773 |
def Rename(self, new_id): |
779 | 774 |
"""Rename a device. |
... | ... | |
1103 | 1098 |
_ThrowError("drbd%d: children not ready during AddChildren", self.minor) |
1104 | 1099 |
backend.Open() |
1105 | 1100 |
meta.Open() |
1106 |
if not self._CheckMetaSize(meta.dev_path): |
|
1107 |
raise errors.BlockDeviceError("Invalid meta device size") |
|
1101 |
self._CheckMetaSize(meta.dev_path) |
|
1108 | 1102 |
self._InitMeta(self._FindUnusedMinor(), meta.dev_path) |
1109 | 1103 |
|
1110 | 1104 |
self._AssembleLocal(self.minor, backend.dev_path, meta.dev_path) |
... | ... | |
1525 | 1519 |
meta.Assemble() |
1526 | 1520 |
if not meta.Attach(): |
1527 | 1521 |
raise errors.BlockDeviceError("Can't attach to meta device") |
1528 |
if not cls._CheckMetaSize(meta.dev_path): |
|
1529 |
raise errors.BlockDeviceError("Invalid meta device size") |
|
1522 |
cls._CheckMetaSize(meta.dev_path) |
|
1530 | 1523 |
cls._InitMeta(aminor, meta.dev_path) |
1531 | 1524 |
return cls(unique_id, children) |
1532 | 1525 |
|
Also available in: Unified diff