Beispiel #1
0
    def test_import(self):
        self.fs.create_file('/config.json', contents=json.dumps({
            'minions': {
                'all': ['node1.ceph.com', 'node2.ceph.com'],
                'admin': ['node1.ceph.com']
            },
            'time_server': {
                'server_host': 'node1.ceph.com',
                'subnet': '10.20.188.0/24'
            }}))
        self.assertTrue(run_import("/config.json"))
        self.assertInSysOut('Configuration imported.')
        self.assertGrains('node1.ceph.com',
                          'ceph-salt', {'member': True,
                                        'roles': ['admin'],
                                        'execution': {}})
        self.assertGrains('node2.ceph.com',
                          'ceph-salt', {'member': True,
                                        'roles': [],
                                        'execution': {}})
        self.assertEqual(PillarManager.get('ceph-salt:minions:all'), ['node1.ceph.com',
                                                                      'node2.ceph.com'])
        self.assertEqual(PillarManager.get('ceph-salt:minions:admin'), ['node1.ceph.com'])
        self.assertIsNone(PillarManager.get('ceph-salt:bootstrap_minion'))
        self.assertEqual(PillarManager.get('ceph-salt:time_server:server_host'), 'node1.ceph.com')
        self.assertEqual(PillarManager.get('ceph-salt:time_server:subnet'), '10.20.188.0/24')

        self.shell.run_cmdline('/time_server/subnet reset')
        self.shell.run_cmdline('/time_server/server_hostname reset')
        self.shell.run_cmdline('/ceph_cluster/roles/admin remove node1.ceph.com')
        self.shell.run_cmdline('/ceph_cluster/minions remove node2.ceph.com')
        self.shell.run_cmdline('/ceph_cluster/minions remove node1.ceph.com')

        self.fs.remove('/config.json')
Beispiel #2
0
    def test_import_invalid_host(self):
        self.fs.create_file('/config.json', contents=json.dumps({
            'minions': {
                'all': ['node1.ceph.com', 'node2.ceph.com', 'node9.ceph.com'],
                'admin': ['node1.ceph.com']
            }}))

        self.assertFalse(run_import("/config.json"))
        self.assertInSysOut("Cannot find minion 'node9.ceph.com'")

        self.fs.remove('/config.json')
Beispiel #3
0
    def test_import_invalid_host(self):
        self.fs.create_file('/config.json',
                            contents=json.dumps({
                                'minions': {
                                    'all': ['node1', 'node2', 'node9'],
                                    'admin': [],
                                    'mgr': ['node1'],
                                    'mon': {
                                        'node2': '10.20.39.202'
                                    }
                                }
                            }))

        self.assertFalse(run_import("/config.json"))
        self.assertInSysOut("Cannot find host 'node9'")

        self.fs.remove('/config.json')
Beispiel #4
0
    def test_import(self):
        self.fs.create_file('/config.json',
                            contents=json.dumps({
                                'minions': {
                                    'all': ['node1', 'node2'],
                                    'admin': [],
                                    'mgr': ['node1'],
                                    'mon': {
                                        'node2': '10.20.39.202'
                                    }
                                },
                                'time_server': {
                                    'server_host': 'server1'
                                }
                            }))
        self.assertTrue(run_import("/config.json"))
        self.assertInSysOut('Configuration imported.')
        self.assertGrains('node1.ceph.com', 'ceph-salt', {
            'member': True,
            'roles': ['mgr'],
            'execution': {}
        })
        self.assertGrains('node2.ceph.com', 'ceph-salt', {
            'member': True,
            'roles': ['mon'],
            'execution': {}
        })
        self.assertEqual(PillarManager.get('ceph-salt:minions:all'),
                         ['node1', 'node2'])
        self.assertEqual(PillarManager.get('ceph-salt:minions:admin'), [])
        self.assertEqual(PillarManager.get('ceph-salt:minions:mgr'), ['node1'])
        self.assertEqual(PillarManager.get('ceph-salt:minions:mon'),
                         {'node2': '10.20.39.202'})
        self.assertIsNone(PillarManager.get('ceph-salt:bootstrap_minion'))
        self.assertEqual(
            PillarManager.get('ceph-salt:time_server:server_host'), 'server1')

        self.shell.run_cmdline('/Time_Server/Server_Hostname reset')
        self.shell.run_cmdline('/Cluster/Roles/Mon rm node2.ceph.com')
        self.shell.run_cmdline('/Cluster/Roles/Mgr rm node1.ceph.com')
        self.shell.run_cmdline('/Cluster/Minions rm node2.ceph.com')
        self.shell.run_cmdline('/Cluster/Minions rm node1.ceph.com')
        self.fs.remove('/config.json')