diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-07-14 14:37:53 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-07-14 14:37:53 -0400 |
commit | 8191489d547d36f1c5a63a8fe4de02ea8d3d7da2 (patch) | |
tree | e3589e63c89dacfecd8a384147f50537bb888c82 /tests/unittests/test_handler/test_handler_mcollective.py | |
parent | 7b4eef8f57ffb02c3851c7bfc36d614ebab8f341 (diff) | |
parent | 74e4dff3774075b4e471df0258c8584feeb352bb (diff) | |
download | vyos-cloud-init-8191489d547d36f1c5a63a8fe4de02ea8d3d7da2.tar.gz vyos-cloud-init-8191489d547d36f1c5a63a8fe4de02ea8d3d7da2.zip |
merge from trunk
Diffstat (limited to 'tests/unittests/test_handler/test_handler_mcollective.py')
-rw-r--r-- | tests/unittests/test_handler/test_handler_mcollective.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_mcollective.py b/tests/unittests/test_handler/test_handler_mcollective.py new file mode 100644 index 00000000..f9448d80 --- /dev/null +++ b/tests/unittests/test_handler/test_handler_mcollective.py @@ -0,0 +1,60 @@ +from cloudinit.config import cc_mcollective +from cloudinit import util + +from .. import helpers + +import configobj +import logging +import shutil +from six import BytesIO +import tempfile + +LOG = logging.getLogger(__name__) + + +class TestConfig(helpers.FilesystemMockingTestCase): + def setUp(self): + super(TestConfig, self).setUp() + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + + def test_basic_config(self): + cfg = { + 'mcollective': { + 'conf': { + 'loglevel': 'debug', + 'connector': 'rabbitmq', + 'logfile': '/var/log/mcollective.log', + 'ttl': '4294957', + 'collectives': 'mcollective', + 'main_collective': 'mcollective', + 'securityprovider': 'psk', + 'daemonize': '1', + 'factsource': 'yaml', + 'direct_addressing': '1', + 'plugin.psk': 'unset', + 'libdir': '/usr/share/mcollective/plugins', + 'identity': '1', + }, + }, + } + self.patchUtils(self.tmp) + cc_mcollective.configure(cfg['mcollective']['conf']) + contents = util.load_file("/etc/mcollective/server.cfg", decode=False) + contents = configobj.ConfigObj(BytesIO(contents)) + expected = { + 'loglevel': 'debug', + 'connector': 'rabbitmq', + 'logfile': '/var/log/mcollective.log', + 'ttl': '4294957', + 'collectives': 'mcollective', + 'main_collective': 'mcollective', + 'securityprovider': 'psk', + 'daemonize': '1', + 'factsource': 'yaml', + 'direct_addressing': '1', + 'plugin.psk': 'unset', + 'libdir': '/usr/share/mcollective/plugins', + 'identity': '1', + } + self.assertEqual(expected, dict(contents)) |