コード例 #1
0
 def setUp(self):
     super(TestConfigManager, self).setUp()
     self.adapter_test_info = config_data.adapter_test_config
     self.cluster_test_info = config_data.cluster_test_config
     self.hosts_test_info = config_data.hosts_test_config
     self.test_config_manager = BaseConfigManager(self.adapter_test_info,
                                                  self.cluster_test_info,
                                                  self.hosts_test_info)
コード例 #2
0
 def setUp(self):
     super(TestConfigManager, self).setUp()
     self.adapter_test_info = config_data.adapter_test_config
     self.cluster_test_info = config_data.cluster_test_config
     self.hosts_test_info = config_data.hosts_test_config
     self.test_config_manager = BaseConfigManager(self.adapter_test_info,
                                                  self.cluster_test_info,
                                                  self.hosts_test_info)
コード例 #3
0
    def get_installer(cls, name, path, adapter_info, cluster_info, hosts_info):
        try:
            mod_file, path, descr = imp.find_module(name, [path])
            if mod_file:
                mod = imp.load_module(name, mod_file, path, descr)
                config_manager = BaseConfigManager(adapter_info, cluster_info,
                                                   hosts_info)
                return getattr(mod, mod.NAME)(config_manager)

        except ImportError as exc:
            logging.error('No such module found: %s', name)
            logging.exception(exc)

        return None
コード例 #4
0
    def _get_chef_installer(self):
        adapter_info = config_data.adapter_test_config
        cluster_info = config_data.cluster_test_config
        hosts_info = config_data.hosts_test_config

        config_manager = BaseConfigManager(adapter_info, cluster_info,
                                           hosts_info)

        ChefInstaller.get_tmpl_path = Mock()
        test_tmpl_dir = os.path.join(os.path.join(config_data.test_tmpl_dir,
                                                  'chef_installer'),
                                     'openstack_icehouse')
        ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir

        ChefInstaller._get_chef_api = Mock()
        ChefInstaller._get_chef_api.return_value = self.chef_test_api
        chef_installer = ChefInstaller(config_manager)
        return chef_installer
コード例 #5
0
ファイル: test_cobbler.py プロジェクト: vshunkov/compass-core
    def _get_cobbler_installer(self):
        adapter_info = config_data.adapter_test_config
        cluster_info = config_data.cluster_test_config
        hosts_info = deepcopy(config_data.hosts_test_config)
        # In config_data, only hosts with ID 1 and 2 needs to install OS.
        del hosts_info[3]

        config_manager = BaseConfigManager(adapter_info, cluster_info,
                                           hosts_info)

        CobblerInstaller._get_cobbler_server = Mock()
        CobblerInstaller._get_cobbler_server.return_value = "mock_server"
        CobblerInstaller._get_token = Mock()
        CobblerInstaller._get_token.return_value = "mock_token"

        CobblerInstaller.get_tmpl_path = Mock()
        test_tmpl_dir = os.path.join(config_data.test_tmpl_dir, 'cobbler')
        CobblerInstaller.get_tmpl_path.return_value = test_tmpl_dir
        return CobblerInstaller(config_manager)
コード例 #6
0
    def _get_chef_installer(self):
        adapter_info = config_data.adapter_test_config
        cluster_info = config_data.cluster_test_config
        hosts_info = config_data.hosts_test_config

        config_manager = BaseConfigManager(adapter_info, cluster_info,
                                           hosts_info)

        ChefInstaller.get_tmpl_path = Mock()
        test_tmpl_dir = os.path.join(
            os.path.join(config_data.test_plugins_dir, 'templates'),
            'openstack_icehouse')
        ChefInstaller.get_tmpl_path.return_value = test_tmpl_dir

        ChefInstaller._get_chef_api = Mock()
        ChefInstaller._get_chef_api.return_value = 'mock_server'
        ChefInstaller.get_all_roles = Mock()
        ChefInstaller.get_all_roles.return_value = []
        ChefInstaller.validate_roles = Mock()
        ChefInstaller.validate_roles.return_value = True
        chef_installer = ChefInstaller(config_manager)
        return chef_installer
コード例 #7
0
class TestConfigManager(unittest2.TestCase):
    """Test ConfigManager methods."""
    def setUp(self):
        super(TestConfigManager, self).setUp()
        self.adapter_test_info = config_data.adapter_test_config
        self.cluster_test_info = config_data.cluster_test_config
        self.hosts_test_info = config_data.hosts_test_config
        self.test_config_manager = BaseConfigManager(self.adapter_test_info,
                                                     self.cluster_test_info,
                                                     self.hosts_test_info)

    def tearDown(self):
        super(TestConfigManager, self).tearDown()
        del self.test_config_manager

    def test_get_cluster_baseinfo(self):
        expected_output = {
            "id": 1,
            "name": "test",
            "os_name": "Ubuntu-12.04-x86_64"
        }
        output = self.test_config_manager.get_cluster_baseinfo()
        self.maxDiff = None
        self.assertDictEqual(expected_output, output)

    def test_get_host_id_list(self):
        expected_output = [1, 2, 3]
        output = self.test_config_manager.get_host_id_list()
        self.assertEqual(expected_output, output)

    def test_get_cluster_roles_mapping(self):
        expected_output = {
            "os_controller": [{
                "hostname": "server01",
                "management": {
                    "interface": "vnet0",
                    "ip": "12.234.32.100",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "vnet1",
                    "ip": "172.16.1.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                }
            }],
            "os_compute_worker": [{
                "hostname": "server02",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.101",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.2",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                }
            }, {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "netmask": "255.255.255.0",
                    "subnet": "12.234.32.0/24"
                },
                'public': {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "netmask": "255.255.255.0",
                    "subnet": "10.0.0.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                }
            }],
            "os_network": [{
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            }]
        }
        self.maxDiff = None
        output = self.test_config_manager.get_cluster_roles_mapping()
        self.assertEqual(expected_output, output)

    def test_get_all_hosts_roles(self):
        expected_output = ['os-compute-worker', 'os-network', 'os-controller']
        output = self.test_config_manager.get_all_hosts_roles()
        self.assertEqual(len(expected_output), len(output))
        self.assertEqual(sorted(expected_output), sorted(output))

    def test_get_host_role_mapping(self):
        expected_output = {
            "os_network": {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            },
            "os_compute_worker": {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            }
        }
        self.maxDiff = None
        output = self.test_config_manager.get_host_roles_mapping(3)
        self.assertEqual(expected_output, output)
コード例 #8
0
class TestConfigManager(unittest2.TestCase):
    """Test ConfigManager methods."""
    def setUp(self):
        super(TestConfigManager, self).setUp()
        self.adapter_test_info = config_data.adapter_test_config
        self.cluster_test_info = config_data.cluster_test_config
        self.hosts_test_info = config_data.hosts_test_config
        self.test_config_manager = BaseConfigManager(self.adapter_test_info,
                                                     self.cluster_test_info,
                                                     self.hosts_test_info)

    def tearDown(self):
        super(TestConfigManager, self).tearDown()
        del self.test_config_manager

    def test_get_cluster_baseinfo(self):
        expected_output = {
            "id": 1,
            "name": "test",
            "os_name": "Ubuntu-12.04-x86_64"
        }
        output = self.test_config_manager.get_cluster_baseinfo()
        self.maxDiff = None
        self.assertDictEqual(expected_output, output)

    def test_get_host_id_list(self):
        expected_output = [1, 2, 3]
        output = self.test_config_manager.get_host_id_list()
        self.assertEqual(expected_output, output)

    def test_get_cluster_flavor_info(self):
        expected_output = self.cluster_test_info[const.FLAVOR]
        output = self.test_config_manager.get_cluster_flavor_info()
        self.assertDictEqual(expected_output, output)

    def test_get_cluster_roles_mapping(self):
        expected_output = {
            "os_controller": {
                "hostname": "server01",
                "management": {
                    "interface": "vnet0",
                    "ip": "12.234.32.100",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "vnet1",
                    "ip": "172.16.1.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                }
            },
            "os_compute_worker": {
                "hostname": "server02",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.101",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.2",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                }
            },
            "os_network": {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            }
        }
        self.maxDiff = None
        output = self.test_config_manager.get_cluster_roles_mapping()
        self.assertEqual(expected_output, output)

    def test_get_all_hosts_roles(self):
        expected_output = ['os-compute-worker', 'os-network', 'os-controller']
        output = self.test_config_manager.get_all_hosts_roles()
        self.assertEqual(len(expected_output), len(output))
        self.assertEqual(sorted(expected_output), sorted(output))

    def test_get_host_role_mapping(self):
        expected_output = {
            "os_network": {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            },
            "os_compute_worker": {
                "hostname": "server03",
                "management": {
                    "interface": "eth0",
                    "ip": "12.234.32.103",
                    "netmask": "255.255.255.0",
                    "is_mgmt": True,
                    "is_promiscuous": False,
                    "subnet": "12.234.32.0/24"
                },
                "tenant": {
                    "interface": "eth1",
                    "ip": "172.16.1.3",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": False,
                    "subnet": "172.16.1.0/24"
                },
                "public": {
                    "interface": "eth2",
                    "ip": "10.0.0.1",
                    "netmask": "255.255.255.0",
                    "is_mgmt": False,
                    "is_promiscuous": True,
                    "subnet": "10.0.0.0/24"
                }
            }
        }
        self.maxDiff = None
        output = self.test_config_manager.get_host_roles_mapping(3)
        self.assertEqual(expected_output, output)