Commit 8f8442d6 authored by Thomas Thrainer's avatar Thomas Thrainer

Fix parsing of drbdsetup show output for DRBD 8.4

DRBD 8.4 contains two `disk` entries under the `volume` section. In some
circumstances, the parsing code could wrongly use the empty one which
causes DRBD8Dev._SlowAssemble() to fail. This fixes issue 516.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 32449822
......@@ -429,6 +429,18 @@ class DRBD84ShowInfo(BaseShowInfo):
return resource
@classmethod
def _TransformVolumeSection(cls, vol_content, retval):
for entry in vol_content:
if entry[0] == "disk" and len(entry) == 2 and \
isinstance(entry[1], basestring):
retval["local_dev"] = entry[1]
elif entry[0] == "meta-disk":
if len(entry) > 1:
retval["meta_dev"] = entry[1]
if len(entry) > 2:
retval["meta_index"] = entry[2]
@classmethod
def _TransformParseResult(cls, parse_result):
retval = {}
......@@ -439,14 +451,7 @@ class DRBD84ShowInfo(BaseShowInfo):
if lst[0] == "address":
retval["local_addr"] = tuple(lst[1:])
elif lst[0] == "volume":
for inner in lst[1:]:
if inner[0] == "disk" and len(inner) == 2:
retval["local_dev"] = inner[1]
elif inner[0] == "meta-disk":
if len(inner) > 1:
retval["meta_dev"] = inner[1]
if len(inner) > 2:
retval["meta_index"] = inner[2]
cls._TransformVolumeSection(lst[1:], retval)
elif sname == "_remote_host":
for lst in section[1:]:
if lst[0] == "address":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment