diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-02-01 09:36:39 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-02-01 10:41:39 -0500 |
commit | 63ee213c1b17b6e1fb526451d3c5736bd51eab86 (patch) | |
tree | 2ecfcea4abca49059e06fa709b4adadab56b5d61 /src | |
parent | 7ca6230df2dc22e43228c3d8e8cfe9851b0e0f3d (diff) | |
download | bcfg2-63ee213c1b17b6e1fb526451d3c5736bd51eab86.tar.gz bcfg2-63ee213c1b17b6e1fb526451d3c5736bd51eab86.tar.bz2 bcfg2-63ee213c1b17b6e1fb526451d3c5736bd51eab86.zip |
get VCS revision in a more resilient way
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 37da4a4b6..81bfebbb5 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -336,9 +336,23 @@ class BaseCore(object): self.fam.handle_event_set(self.lock) except: continue - # VCS plugin periodic updates - for plugin in self.plugins_by_type(Bcfg2.Server.Plugin.Version): - self.revision = plugin.get_revision() + self._update_vcs_revision() + + @track_statistics() + def _update_vcs_revision(self): + """ Update the revision of the current configuration on-disk + from the VCS plugin """ + for plugin in self.plugins_by_type(Bcfg2.Server.Plugin.Version): + try: + newrev = plugin.get_revision() + if newrev != self.revision: + self.logger.debug("Updated to revision %s" % newrev) + self.revision = newrev + break + except: + self.logger.warning("Error getting revision from %s: %s" % + (plugin.name, sys.exc_info()[1])) + self.revision = '-1' def init_plugin(self, plugin): """ Import and instantiate a single plugin. The plugin is @@ -364,8 +378,8 @@ class BaseCore(object): try: plug = getattr(mod, plugin.split('.')[-1]) except AttributeError: - self.logger.error("Failed to load plugin %s (AttributeError)" % - plugin) + self.logger.error("Failed to load plugin %s: %s" % + (plugin, sys.exc_info()[1])) return # Blacklist conflicting plugins cplugs = [conflict for conflict in plug.conflicts |