Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -241,6 +241,7 @@ def _SplitKeyVal(opt, data): ...@@ -241,6 +241,7 @@ def _SplitKeyVal(opt, data):
""" """
NO_PREFIX = "no_" NO_PREFIX = "no_"
UN_PREFIX = "-"
kv_dict = {} kv_dict = {}
for elem in data.split(","): for elem in data.split(","):
if "=" in elem: if "=" in elem:
...@@ -248,6 +249,8 @@ def _SplitKeyVal(opt, data): ...@@ -248,6 +249,8 @@ def _SplitKeyVal(opt, data):
else: else:
if elem.startswith(NO_PREFIX): if elem.startswith(NO_PREFIX):
key, val = elem[len(NO_PREFIX):], False key, val = elem[len(NO_PREFIX):], False
elif elem.startswith(UN_PREFIX):
key, val = elem[len(UN_PREFIX):], None
else: else:
key, val = elem, True key, val = elem, True
if key in kv_dict: if key in kv_dict:
......
...@@ -61,8 +61,8 @@ class TestParseTimespec(unittest.TestCase): ...@@ -61,8 +61,8 @@ class TestParseTimespec(unittest.TestCase):
class TestSplitKeyVal(unittest.TestCase): class TestSplitKeyVal(unittest.TestCase):
"""Testing case for cli._SplitKeyVal""" """Testing case for cli._SplitKeyVal"""
DATA = "a=b,c,no_d" DATA = "a=b,c,no_d,-e"
RESULT = {"a": "b", "c": True, "d": False} RESULT = {"a": "b", "c": True, "d": False, "e": None}
def testSplitKeyVal(self): def testSplitKeyVal(self):
"""Test splitting""" """Test splitting"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment