From 31e22135c87209c6a6d1bbb39ed28363b7528348 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 10 Jun 2009 11:40:55 +0200
Subject: [PATCH] Remove utils.CheckDict since it's no longer used

Only the custom handling in rpc.py for call_node_info used this, so now
it can be removed.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/utils.py                  | 26 --------------------------
 test/ganeti.utils_unittest.py | 23 +----------------------
 2 files changed, 1 insertion(+), 48 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index 48388babe..49f4c99d6 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -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:
-      missing.append(k)
-      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.
 
diff --git a/test/ganeti.utils_unittest.py b/test/ganeti.utils_unittest.py
index 846b4b446..ddb47000d 100755
--- a/test/ganeti.utils_unittest.py
+++ b/test/ganeti.utils_unittest.py
@@ -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):
                      mkdir=True)
 
 
-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:
-      self.fail("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"""
 
-- 
GitLab