summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-29 09:35:39 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-29 09:35:39 -0400
commitef87028da290f8c196075f4e8154596329d56f15 (patch)
tree1ce3f883c1e26e4cfb2fa289a681167eb7db5579 /src/lib
parent44756f91921d03a012fef6ac321ae78e67c7585a (diff)
downloadbcfg2-ef87028da290f8c196075f4e8154596329d56f15.tar.gz
bcfg2-ef87028da290f8c196075f4e8154596329d56f15.tar.bz2
bcfg2-ef87028da290f8c196075f4e8154596329d56f15.zip
fixed unit tests
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Bcfg2/Server/Plugin/helpers.py9
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py3
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: