diff options
-rw-r--r-- | doc/releases/1.4.0pre2.txt | 3 | ||||
-rw-r--r-- | src/lib/Bcfg2/Options/Parser.py | 11 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Admin.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 3 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 2 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/NagiosGen.py | 9 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/SSLServer.py | 4 | ||||
-rw-r--r-- | testsuite/Testsrc/Testlib/TestOptions/TestOptions.py | 7 |
8 files changed, 36 insertions, 7 deletions
diff --git a/doc/releases/1.4.0pre2.txt b/doc/releases/1.4.0pre2.txt index 7bbed5603..572748f73 100644 --- a/doc/releases/1.4.0pre2.txt +++ b/doc/releases/1.4.0pre2.txt @@ -17,6 +17,8 @@ and as such is not likely suitable for general production deployment. That said, please help us test the release in non- and preproduction environments. +* NagiosGen: Add bundles to configuration + backwards-incompatible user-facing changes ------------------------------------------ @@ -35,3 +37,4 @@ Special thanks to the following contributors for this release * Alexander Sulfrain * Matt Kemp + * Jeremie Banier diff --git a/src/lib/Bcfg2/Options/Parser.py b/src/lib/Bcfg2/Options/Parser.py index c846e8093..d146e3aa2 100644 --- a/src/lib/Bcfg2/Options/Parser.py +++ b/src/lib/Bcfg2/Options/Parser.py @@ -6,7 +6,7 @@ import sys from Bcfg2.version import __version__ from Bcfg2.Compat import ConfigParser -from Bcfg2.Options import Option, PathOption, BooleanOption, _debug +from Bcfg2.Options import Option, PathOption, _debug __all__ = ["setup", "OptionParserException", "Parser", "get_parser", "new_parser"] @@ -43,9 +43,16 @@ class Parser(argparse.ArgumentParser): help="Path to configuration file", default="/etc/bcfg2.conf") + #: Verbose version string that is printed if executed with --version + _version_string = "%s %s on Python %s" % ( + os.path.basename(sys.argv[0]), + __version__, + ".".join(str(v) for v in sys.version_info[0:3])) + #: Builtin options that apply to all commands options = [configfile, - BooleanOption('--version', help="Print the version and exit"), + Option('--version', help="Print the version and exit", + action="version", version=_version_string), Option('-E', '--encoding', metavar='<encoding>', default='UTF-8', help="Encoding of config files", cf=('components', 'encoding'))] diff --git a/src/lib/Bcfg2/Server/Admin.py b/src/lib/Bcfg2/Server/Admin.py index ef7741880..c294e6be5 100644 --- a/src/lib/Bcfg2/Server/Admin.py +++ b/src/lib/Bcfg2/Server/Admin.py @@ -1198,7 +1198,9 @@ class CLI(Bcfg2.Options.CommandRegistry): def run(self): """ Run bcfg2-admin """ try: - self.commands[Bcfg2.Options.setup.subcommand].setup() + cmd = self.commands[Bcfg2.Options.setup.subcommand] + if hasattr(cmd, 'setup'): + cmd.setup() return self.runcommand() finally: self.shutdown() diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index bc305e47a..a6fe02c6b 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -560,7 +560,8 @@ class Core(object): structures = list( chain(*[struct.BuildStructures(metadata) for struct in self.plugins_by_type(Structure)])) - sbundles = [b.get('name') for b in structures if b.tag == 'Bundle'] + sbundles = [b.get('name') for b in structures + if b.tag == 'Bundle' or b.tag == 'Independent'] missing = [b for b in metadata.bundles if b not in sbundles] if missing: self.logger.error("Client %s configuration missing bundles: %s" % diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index 1d15656af..26f39e50d 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -502,6 +502,8 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, """This class contains data for bcfg2 server metadata.""" __author__ = 'bcfg-dev@mcs.anl.gov' sort_order = 500 + __rmi__ = Bcfg2.Server.Plugin.DatabaseBacked.__rmi__ + ['list_clients', + 'remove_client'] options = Bcfg2.Server.Plugin.DatabaseBacked.options + [ Bcfg2.Options.Common.password, diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py index 045e46350..d3c38ef19 100644 --- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py +++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py @@ -45,7 +45,11 @@ class NagiosGen(Plugin, Generator): raise PluginExecutionError("Failed to find IP address for %s" % metadata.hostname) host_groups = [grp for grp in metadata.groups - if os.path.isfile('%s/%s-group.cfg' % (self.data, grp))] + if os.path.isfile('%s/%s-group.cfg' % + (self.data, grp))] + \ + [bundle for bundle in metadata.bundles + if os.path.isfile('%s/%s-bundle.cfg' % + (self.data, bundle))] host_config = ['define host {', self.line_fmt % ('host_name', metadata.hostname), self.line_fmt % ('alias', metadata.hostname), @@ -81,7 +85,8 @@ class NagiosGen(Plugin, Generator): def createserverconfig(self, entry, _): """Build monolithic server configuration file.""" host_configs = glob.glob(os.path.join(self.data, '*-host.cfg')) - group_configs = glob.glob(os.path.join(self.data, '*-group.cfg')) + group_configs = glob.glob(os.path.join(self.data, '*-group.cfg')) + \ + glob.glob(os.path.join(self.data, '*-bundle.cfg')) host_data = [] group_data = [] for host in host_configs: diff --git a/src/lib/Bcfg2/Server/SSLServer.py b/src/lib/Bcfg2/Server/SSLServer.py index 6ad5b5635..1f8febd0e 100644 --- a/src/lib/Bcfg2/Server/SSLServer.py +++ b/src/lib/Bcfg2/Server/SSLServer.py @@ -43,8 +43,10 @@ class XMLRPCDispatcher(SimpleXMLRPCServer.SimpleXMLRPCDispatcher): params = (address, ) + params response = self.instance._dispatch(method, params, self.funcs) # py3k compatibility - if type(response) not in [bool, str, list, dict]: + if type(response) not in [bool, str, list, dict, set, type(None)]: response = (response.decode('utf-8'), ) + elif type(response) == set: + response = (list(response), ) else: response = (response, ) raw_response = xmlrpclib.dumps(response, methodresponse=True, diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py index a2dc8ffe2..034a4580a 100644 --- a/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py +++ b/testsuite/Testsrc/Testlib/TestOptions/TestOptions.py @@ -185,6 +185,13 @@ class TestBasicOptions(OptionTestCase): options = self._test_options(env={"TEST_PATH_OPTION": "/foo"}) self.assertEqual(options.test_path_option, "/foo") + def test_version(self): + """print version and exit on --version""" + self.assertRaises( + SystemExit, + self._test_options, + options=['--version']) + def test_set_boolean_in_cli(self): """set boolean options in CLI options.""" # passing the option yields the reverse of the default, no |