summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_mcollective.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-07-14 14:37:53 -0400
committerScott Moser <smoser@ubuntu.com>2016-07-14 14:37:53 -0400
commit5528e872787f1db9b492be6ace547d5fca267747 (patch)
treee3589e63c89dacfecd8a384147f50537bb888c82 /tests/unittests/test_handler/test_handler_mcollective.py
parent85f4bef14bd51775d8faf470d951ce1eff92e7b4 (diff)
parentf92858727965cbb85dfac24a9a79a71779e5edff (diff)
downloadcloud-init-5528e872787f1db9b492be6ace547d5fca267747.tar.gz
merge from trunk
Diffstat (limited to 'tests/unittests/test_handler/test_handler_mcollective.py')
-rw-r--r--tests/unittests/test_handler/test_handler_mcollective.py60
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))