diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-11 10:12:57 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-11 13:27:17 -0400 |
commit | c5b4bfd842a6f03a4c840cd32c3a99bcc57a8c48 (patch) | |
tree | ace0753e30905b3b6597a995d3cce247f4083874 /src/lib/Bcfg2/Server/Plugins/Packages/__init__.py | |
parent | 77960a22494ec97e71297cf406a19c8e138a793c (diff) | |
download | bcfg2-c5b4bfd842a6f03a4c840cd32c3a99bcc57a8c48.tar.gz bcfg2-c5b4bfd842a6f03a4c840cd32c3a99bcc57a8c48.tar.bz2 bcfg2-c5b4bfd842a6f03a4c840cd32c3a99bcc57a8c48.zip |
added short-lived caching of Packages Collection objects
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Packages/__init__.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/__init__.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py index 3f5c46aab..4070b13ca 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py @@ -15,7 +15,8 @@ from Bcfg2.Server.Plugins.Packages.PackagesConfig import PackagesConfig class Packages(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.StructureValidator, Bcfg2.Server.Plugin.Generator, - Bcfg2.Server.Plugin.Connector): + Bcfg2.Server.Plugin.Connector, + Bcfg2.Server.Plugin.GoalValidator): name = 'Packages' conflicts = ['Pkgmgr'] experimental = True @@ -101,8 +102,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, def HandlesEntry(self, entry, metadata): if entry.tag == 'Package': - if self.config.getboolean("global", "magic_groups", - default=True) == True: + if self.config.getboolean("global", "magic_groups", default=True): collection = self._get_collection(metadata) if collection.magic_groups_match(): return True @@ -267,3 +267,11 @@ class Packages(Bcfg2.Server.Plugin.Plugin, def get_additional_data(self, metadata): collection = self._get_collection(metadata) return dict(sources=collection.get_additional_data()) + + def validate_goals(self, metadata, _): + """ we abuse the GoalValidator plugin since validate_goals() + is the very last thing called during a client config run. so + we use this to clear the collection cache for this client, + which must persist only the duration of a client run """ + if metadata.hostname in Collection.clients: + del Collection.clients[metadata.hostname] |