Revision 3b559640 lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
848 | 848 |
return highest + 1 |
849 | 849 |
|
850 | 850 |
@classmethod |
851 |
def _IsValidMeta(cls, meta_device): |
|
852 |
"""Check if the given meta device looks like a valid one. |
|
853 |
|
|
854 |
""" |
|
855 |
minor = cls._FindUnusedMinor() |
|
856 |
minor_path = cls._DevPath(minor) |
|
857 |
result = utils.RunCmd(["drbdmeta", minor_path, |
|
858 |
"v08", meta_device, "0", |
|
859 |
"dstate"]) |
|
860 |
if result.failed: |
|
861 |
logging.error("Invalid meta device %s: %s", meta_device, result.output) |
|
862 |
return False |
|
863 |
return True |
|
864 |
|
|
865 |
@classmethod |
|
866 | 851 |
def _GetShowParser(cls): |
867 | 852 |
"""Return a parser for `drbd show` output. |
868 | 853 |
|
... | ... | |
1023 | 1008 |
def _AssembleLocal(cls, minor, backend, meta): |
1024 | 1009 |
"""Configure the local part of a DRBD device. |
1025 | 1010 |
|
1026 |
This is the first thing that must be done on an unconfigured DRBD |
|
1027 |
device. And it must be done only once. |
|
1028 |
|
|
1029 | 1011 |
""" |
1030 |
if not cls._IsValidMeta(meta): |
|
1031 |
return False |
|
1032 | 1012 |
args = ["drbdsetup", cls._DevPath(minor), "disk", |
1033 | 1013 |
backend, meta, "0", "-e", "detach", "--create-device"] |
1034 | 1014 |
result = utils.RunCmd(args) |
... | ... | |
1109 | 1089 |
if not self._CheckMetaSize(meta.dev_path): |
1110 | 1090 |
raise errors.BlockDeviceError("Invalid meta device size") |
1111 | 1091 |
self._InitMeta(self._FindUnusedMinor(), meta.dev_path) |
1112 |
if not self._IsValidMeta(meta.dev_path): |
|
1113 |
raise errors.BlockDeviceError("Cannot initalize meta device") |
|
1114 | 1092 |
|
1115 | 1093 |
if not self._AssembleLocal(self.minor, backend.dev_path, meta.dev_path): |
1116 | 1094 |
raise errors.BlockDeviceError("Can't attach to local storage") |
... | ... | |
1551 | 1529 |
raise errors.BlockDeviceError("Can't attach to meta device") |
1552 | 1530 |
if not cls._CheckMetaSize(meta.dev_path): |
1553 | 1531 |
raise errors.BlockDeviceError("Invalid meta device size") |
1554 |
cls._InitMeta(cls._FindUnusedMinor(), meta.dev_path) |
|
1555 |
if not cls._IsValidMeta(meta.dev_path): |
|
1556 |
raise errors.BlockDeviceError("Cannot initalize meta device") |
|
1532 |
cls._InitMeta(aminor, meta.dev_path) |
|
1557 | 1533 |
return cls(unique_id, children) |
1558 | 1534 |
|
1559 | 1535 |
def Grow(self, amount): |
Also available in: Unified diff