]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc: move deep_merge out of the MergeConfig class - it's generic
authorJosh Durgin <josh.durgin@dreamhost.com>
Thu, 17 Nov 2011 21:06:36 +0000 (13:06 -0800)
committerJosh Durgin <josh.durgin@dreamhost.com>
Thu, 17 Nov 2011 21:06:36 +0000 (13:06 -0800)
teuthology/misc.py
teuthology/run.py

index 9cf4e05090fe201d8457610083ff66559578f237..0e6b7676c17e24622a41433e3cc1232d75c03c5a 100644 (file)
@@ -422,3 +422,22 @@ def replace_all_with_clients(cluster, config):
     for client in all_roles_of_type(cluster, 'client'):
         norm_config['client.{id}'.format(id=client)] = config['all']
     return norm_config
+
+def deep_merge(a, b):
+    if a is None:
+        return b
+    if b is None:
+        return a
+    if isinstance(a, list):
+        assert isinstance(b, list)
+        a.extend(b)
+        return a
+    if isinstance(a, dict):
+        assert isinstance(b, dict)
+        for (k, v) in b.iteritems():
+            if k in a:
+                a[k] = deep_merge(a[k], v)
+            else:
+                a[k] = v
+        return a
+    return b
index a2c3e002744464ec87f7ddfe3125ae644c5aedd6..e31f7e53d7a0cb5ef3dfa5906f1c9422b338f65b 100644 (file)
@@ -14,29 +14,11 @@ def config_file(string):
     return config
 
 class MergeConfig(argparse.Action):
-    def deep_merge(self, a, b):
-        if a is None:
-            return b
-        if b is None:
-            return a
-        if isinstance(a, list):
-            assert isinstance(b, list)
-            a.extend(b)
-            return a
-        if isinstance(a, dict):
-            assert isinstance(b, dict)
-            for (k, v) in b.iteritems():
-                if k in a:
-                    a[k] = self.deep_merge(a[k], v)
-                else:
-                    a[k] = v
-            return a
-        return b
-
     def __call__(self, parser, namespace, values, option_string=None):
         config = getattr(namespace, self.dest)
+        from teuthology.misc import deep_merge
         for new in values:
-            self.deep_merge(config, new)
+            deep_merge(config, new)
 
 def parse_args():
     parser = argparse.ArgumentParser(description='Run ceph integration tests')