Commit 29a32ce5 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ssconf: Add function to verify keys

The new utility for configuring the node daemon will have to check
whether it received valid ssconf names.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarGuido Trotter <>
parent 0cc3f0d7
......@@ -387,3 +387,17 @@ def VerifyClusterName(name, _cfg_location=None):
if name != local_name:
raise errors.GenericError("Current cluster name is '%s'" % local_name)
def VerifyKeys(keys):
"""Raises an exception if unknown ssconf keys are given.
@type keys: sequence
@param keys: Key names to verify
@raise errors.GenericError: When invalid keys were found
invalid = frozenset(keys) - _VALID_KEYS
if invalid:
raise errors.GenericError("Invalid ssconf keys: %s" %
......@@ -169,5 +169,20 @@ class TestVerifyClusterName(unittest.TestCase):
"", _cfg_location=self.tmpdir)
class TestVerifyKeys(unittest.TestCase):
def testNoKeys(self):
def testValidKeys(self):
for key in ssconf._VALID_KEYS:
def testInvalidKeys(self):
for key in ["", ".", " ", "foo", "bar", "HelloWorld"]:
self.assertRaises(errors.GenericError, ssconf.VerifyKeys, [key])
if __name__ == "__main__":
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