Fix drbd show parser to handle valueless keywords
authorGuido Trotter <ultrotter@google.com>
Thu, 15 May 2008 08:58:47 +0000 (08:58 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 15 May 2008 08:58:47 +0000 (08:58 +0000)
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

index 18bfc41..5ca0fef 100644 (file)
@@ -1763,7 +1763,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())