diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugin/helpers.py | 9 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Probes.py | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py index a9e7b6067..894ed9851 100644 --- a/src/lib/Bcfg2/Server/Plugin/helpers.py +++ b/src/lib/Bcfg2/Server/Plugin/helpers.py @@ -164,18 +164,21 @@ class DatabaseBacked(Plugin): return False @staticmethod - def get_db_lock(fn): + def get_db_lock(func): """ Decorator to be used by a method of a :class:`DatabaseBacked` plugin that will update database data. """ + + @wraps(func) def _acquire_and_run(self, *args, **kwargs): + """ The decorated function """ if self._must_lock: # pylint: disable=W0212 try: self.core.db_write_lock.acquire() - rv = fn(self, *args, **kwargs) + rv = func(self, *args, **kwargs) finally: self.core.db_write_lock.release() else: - rv = fn(self, *args, **kwargs) + rv = func(self, *args, **kwargs) return rv return _acquire_and_run diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 941bc4fd8..90dff4a66 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -186,6 +186,7 @@ class Probes(Bcfg2.Server.Plugin.Probing, self.load_data() __init__.__doc__ = Bcfg2.Server.Plugin.DatabaseBacked.__init__.__doc__ + @Bcfg2.Server.Plugin.track_statistics() def write_data(self, client): """ Write probe data out for use with bcfg2-info """ if self._use_db: @@ -288,10 +289,12 @@ class Probes(Bcfg2.Server.Plugin.Probing, self.cgroups[pgroup.hostname] = [] self.cgroups[pgroup.hostname].append(pgroup.group) + @Bcfg2.Server.Plugin.track_statistics() def GetProbes(self, meta): return self.probes.get_probe_data(meta) GetProbes.__doc__ = Bcfg2.Server.Plugin.Probing.GetProbes.__doc__ + @Bcfg2.Server.Plugin.track_statistics() def ReceiveData(self, client, datalist): if self.core.metadata_cache_mode in ['cautious', 'aggressive']: if client.hostname in self.cgroups: |