Commit 31e22135 authored by Iustin Pop's avatar Iustin Pop
Browse files

Remove utils.CheckDict since it's no longer used

Only the custom handling in for call_node_info used this, so now
it can be removed.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent 070e998b
......@@ -373,32 +373,6 @@ def FingerprintFiles(files):
return ret
def CheckDict(target, template, logname=None):
"""Ensure a dictionary has a required set of keys.
For the given dictionaries I{target} and I{template}, ensure
I{target} has all the keys from I{template}. Missing keys are added
with values from template.
@type target: dict
@param target: the dictionary to update
@type template: dict
@param template: the dictionary holding the default values
@type logname: str or None
@param logname: if not None, causes the missing keys to be
logged with this name
missing = []
for k in template:
if k not in target:
target[k] = template[k]
if missing and logname:
logging.warning('%s missing keys %s', logname, ', '.join(missing))
def ForceDictType(target, key_types, allowed_values=None):
"""Force the values of a dict to have certain types.
......@@ -40,7 +40,7 @@ from ganeti import constants
from ganeti import utils
from ganeti import errors
from ganeti.utils import IsProcessAlive, RunCmd, \
RemoveFile, CheckDict, MatchNameComponent, FormatUnit, \
RemoveFile, MatchNameComponent, FormatUnit, \
ParseUnit, AddAuthorizedKey, RemoveAuthorizedKey, \
ShellQuote, ShellQuoteArgs, TcpPing, ListVisibleFiles, \
SetEtcHostsEntry, RemoveEtcHostsEntry, FirstFree, OwnIpAddress, \
......@@ -306,27 +306,6 @@ class TestRename(unittest.TestCase):
class TestCheckdict(unittest.TestCase):
"""Test case for the CheckDict function"""
def testAdd(self):
"""Test that CheckDict adds a missing key with the correct value"""
tgt = {'a':1}
tmpl = {'b': 2}
CheckDict(tgt, tmpl)
if 'b' not in tgt or tgt['b'] != 2:"Failed to update dict")
def testNoUpdate(self):
"""Test that CheckDict does not overwrite an existing key"""
tgt = {'a':1, 'b': 3}
tmpl = {'b': 2}
CheckDict(tgt, tmpl)
self.failUnlessEqual(tgt['b'], 3)
class TestMatchNameComponent(unittest.TestCase):
"""Test case for the MatchNameComponent function"""
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