Commit 7da478a4 by Matthew Jones

Fix an issue where cache plugins weren't updated

The first call to persisting facts would work due to the assignment of a
MutableMapping calling __setitem__ but subsequent module fact data would
not be propogated to the fact cache plugins because update() doesn't
invoke __setitem__.  This changes the behavior a little bit and ensures
set() is called on cache plugins.
parent d1b98ec7
...@@ -68,3 +68,8 @@ class FactCache(MutableMapping): ...@@ -68,3 +68,8 @@ class FactCache(MutableMapping):
def flush(self): def flush(self):
""" Flush the fact cache of all keys. """ """ Flush the fact cache of all keys. """
self._plugin.flush() self._plugin.flush()
def update(self, key, value):
host_cache = self._plugin.get(key)
host_cache.update(value)
self._plugin.set(key, host_cache)
...@@ -546,7 +546,7 @@ class VariableManager: ...@@ -546,7 +546,7 @@ class VariableManager:
self._fact_cache[host.name] = facts self._fact_cache[host.name] = facts
else: else:
try: try:
self._fact_cache[host.name].update(facts) self._fact_cache.update(host.name, facts)
except KeyError: except KeyError:
self._fact_cache[host.name] = facts self._fact_cache[host.name] = facts
......
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