From 6851a2931869aa9d9181b7b2d95f048aa5415a23 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 22 Jul 2015 18:39:32 +0200 Subject: Rules: New options replace_name to replace %{name} in attributes If you use the regex feature of Rules/Defaults you may need the real name of the matched entry in an attribute (for example home of POSIXUser). You can now enable replace_name for rules or defaults and %{name} will be replaces in the attribues of the Element before adding them to the target entry. This allows you to write something like that in Defaults to assing a default home directory somewhere else to all users with unset home: --- testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py') diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py index 9b4a6af88..3c660099e 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestDefaults.py @@ -22,6 +22,10 @@ from Testinterfaces import TestGoalValidator class TestDefaults(TestRules, TestGoalValidator): test_obj = Defaults + def setUp(self): + TestRules.setUp(self) + set_setup_default("defaults_replace_name", True) + def get_obj(self, *args, **kwargs): return TestRules.get_obj(self, *args, **kwargs) @@ -91,3 +95,8 @@ class TestDefaults(TestRules, TestGoalValidator): def test_regex(self): self._do_test('regex') + + def test_replace_name(self): + Bcfg2.Options.setup.defaults_replace_name = True + self._do_test('replace_name') + Bcfg2.Options.setup.defaults_replace_name = False -- cgit v1.2.3-1-g7c22