Commit fcd62d84 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement parameter removal in SplitKeyVal

This patch adds paramter removal in SplitKeyVal, by prefixing a
value-less key with "-"; this is needed in resetting parameters back to
cluster defaults, but care must be applied now that None can come from
the parser.

Reviewed-by: imsnah
parent 5bf7b5cf
......@@ -241,6 +241,7 @@ def _SplitKeyVal(opt, data):
"""
NO_PREFIX = "no_"
UN_PREFIX = "-"
kv_dict = {}
for elem in data.split(","):
if "=" in elem:
......@@ -248,6 +249,8 @@ def _SplitKeyVal(opt, data):
else:
if elem.startswith(NO_PREFIX):
key, val = elem[len(NO_PREFIX):], False
elif elem.startswith(UN_PREFIX):
key, val = elem[len(UN_PREFIX):], None
else:
key, val = elem, True
if key in kv_dict:
......
......@@ -61,8 +61,8 @@ class TestParseTimespec(unittest.TestCase):
class TestSplitKeyVal(unittest.TestCase):
"""Testing case for cli._SplitKeyVal"""
DATA = "a=b,c,no_d"
RESULT = {"a": "b", "c": True, "d": False}
DATA = "a=b,c,no_d,-e"
RESULT = {"a": "b", "c": True, "d": False, "e": None}
def testSplitKeyVal(self):
"""Test splitting"""
......
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