summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/Options.py1
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py5
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py36
3 files changed, 39 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py
index f9b6a998b..f47ac00d2 100644
--- a/src/lib/Bcfg2/Options.py
+++ b/src/lib/Bcfg2/Options.py
@@ -311,6 +311,7 @@ def list_split(c_string):
return re.split(r'\s*,\s*', c_string)
return []
+
def list_split_anchored_regex(c_string):
""" like list_split but split on whitespace and compile each element as
anchored regex """
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 59a73c4aa..0df88d522 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -395,8 +395,9 @@ class Probes(Bcfg2.Server.Plugin.Probing,
if self._group_allowed(newgroup):
cgroups.append(newgroup)
else:
- self.logger.info("Disallowed group assignment %s from %s"
- % (newgroup, client.hostname))
+ self.logger.info(
+ "Disallowed group assignment %s from %s" %
+ (newgroup, client.hostname))
dlines.remove(line)
dobj = ProbeData("\n".join(dlines))
cprobedata[data.get('name')] = dobj
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
index a87628eaf..2face023f 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
@@ -1,4 +1,5 @@
import os
+import re
import sys
import copy
import time
@@ -295,7 +296,9 @@ text
def inner():
return self.get_obj(core)
- return inner()
+ rv = inner()
+ rv.allowed_cgroups = [re.compile("^.*$")]
+ return rv
def test__init(self):
mock_load_data = Mock()
@@ -591,6 +594,37 @@ text
self.assertEqual(probes.cgroups[cname],
self.get_test_cgroups()[cname])
+ # test again, with an explicit list of allowed groups
+ probes.allowed_cgroups = [re.compile(r'^.*s$')]
+ for cname, cdata in self.get_test_probedata().items():
+ client = Mock()
+ client.hostname = cname
+ cgroups = []
+ cprobedata = ClientProbeDataSet()
+ for pname, pdata in cdata.items():
+ dataitem = lxml.etree.Element("Probe", name=pname)
+ if pname == "text":
+ # add some groups to the plaintext test to test
+ # group parsing
+ data = [pdata]
+ for group in self.get_test_cgroups()[cname]:
+ data.append("group:%s" % group)
+ dataitem.text = "\n".join(data)
+ else:
+ dataitem.text = str(pdata)
+
+ probes.ReceiveDataItem(client, dataitem, cgroups, cprobedata)
+
+ probes.cgroups[client.hostname] = cgroups
+ probes.probedata[client.hostname] = cprobedata
+ self.assertIn(client.hostname, probes.probedata)
+ self.assertIn(pname, probes.probedata[cname])
+ self.assertEqual(pdata, probes.probedata[cname][pname])
+ self.assertIn(client.hostname, probes.cgroups)
+ self.assertEqual(probes.cgroups[cname],
+ [g for g in self.get_test_cgroups()[cname]
+ if g.endswith("s")])
+
def test_get_additional_groups(self):
TestConnector.test_get_additional_groups(self)