Revision 29a32ce5

b/lib/ssconf.py
387 387
  else:
388 388
    if name != local_name:
389 389
      raise errors.GenericError("Current cluster name is '%s'" % local_name)
390

  
391

  
392
def VerifyKeys(keys):
393
  """Raises an exception if unknown ssconf keys are given.
394

  
395
  @type keys: sequence
396
  @param keys: Key names to verify
397
  @raise errors.GenericError: When invalid keys were found
398

  
399
  """
400
  invalid = frozenset(keys) - _VALID_KEYS
401
  if invalid:
402
    raise errors.GenericError("Invalid ssconf keys: %s" %
403
                              utils.CommaJoin(sorted(invalid)))
b/test/ganeti.ssconf_unittest.py
169 169
                        "cluster.example.com", _cfg_location=self.tmpdir)
170 170

  
171 171

  
172
class TestVerifyKeys(unittest.TestCase):
173
  def testNoKeys(self):
174
    ssconf.VerifyKeys({})
175

  
176
  def testValidKeys(self):
177
    ssconf.VerifyKeys(ssconf._VALID_KEYS)
178

  
179
    for key in ssconf._VALID_KEYS:
180
      ssconf.VerifyKeys([key])
181

  
182
  def testInvalidKeys(self):
183
    for key in ["", ".", " ", "foo", "bar", "HelloWorld"]:
184
      self.assertRaises(errors.GenericError, ssconf.VerifyKeys, [key])
185

  
186

  
172 187
if __name__ == "__main__":
173 188
  testutils.GanetiTestProgram()

Also available in: Unified diff