summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_mcollective.py
blob: f9448d80c3e5b37c717b74fb66c1481a921cdca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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))