summaryrefslogtreecommitdiffstats
path: root/cobbler/utils.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-11-05 16:11:09 -0500
committerMichael DeHaan <mdehaan@redhat.com>2007-11-05 16:11:09 -0500
commitf26dbdbbb9232eb1856a6ee1273f8bb8cd7f4e06 (patch)
tree2496a70c3253b773df3c1ac6f68c61b280ab8987 /cobbler/utils.py
parent71ead12117368b36ba0dea56c779e225fbb55fa2 (diff)
downloadthird_party-cobbler-f26dbdbbb9232eb1856a6ee1273f8bb8cd7f4e06.tar.gz
third_party-cobbler-f26dbdbbb9232eb1856a6ee1273f8bb8cd7f4e06.tar.xz
third_party-cobbler-f26dbdbbb9232eb1856a6ee1273f8bb8cd7f4e06.zip
Optimize sync performance by caching the results of calls to "blender".
Diffstat (limited to 'cobbler/utils.py')
-rw-r--r--cobbler/utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 4f63651..3189a36 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -271,12 +271,18 @@ def grab_tree(api_handle, obj):
results.append(settings)
return results
-def blender(api_handle,remove_hashes, root_obj):
+def blender(api_handle,remove_hashes, root_obj, blend_cache=None):
"""
Combine all of the data in an object tree from the perspective
of that point on the tree, and produce a merged hash containing
consolidated data.
"""
+
+ blend_key = "%s/%s/%s" % (root_obj.TYPE_NAME, root_obj.name, remove_hashes)
+ if blend_cache is not None:
+ if blend_cache.has_key(blend_key):
+ return blend_cache[blend_key]
+
settings = api_handle.settings()
tree = grab_tree(api_handle, root_obj)
tree.reverse() # start with top of tree, override going down
@@ -311,6 +317,8 @@ def blender(api_handle,remove_hashes, root_obj):
if remove_hashes:
results = flatten(results)
+ if blend_cache is not None:
+ blend_cache[blend_key] = results
return results
def flatten(data):