From 63012024b067a5de9391854f1bcd0f5d64c38b42 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Thu, 15 May 2008 09:00:10 +0000
Subject: [PATCH] Fix drbd show parser to handle valueless keywords

It turns out in some cases there can exist keywords without an
associated value exported by drbdsetup show. This patch makes the value
part optional in our parser, so that if it's not present the parsing
result will contain an array with just the keyword in it. This is not a
problem since we check all keyword names before accessing their values,
so we won't mistakenly try to access the value of a valueless keyword.

Reviewed-by: iustinp
---
 lib/bdev.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bdev.py b/lib/bdev.py
index eefbc06ab..4dea37790 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -1674,7 +1674,7 @@ class DRBD8(BaseDRBD):
 
     # a statement
     stmt = (~rbrace + keyword + ~lbrace +
-            (addr_port ^ value ^ quoted ^ meta_value) +
+            pyp.Optional(addr_port ^ value ^ quoted ^ meta_value) +
             pyp.Optional(defa) + semi +
             pyp.Optional(pyp.restOfLine).suppress())
 
-- 
GitLab