Esempio n. 1
0
 def test_allocates_all_free_space_for_vm_for_cinder_role(self):
     node = self.create_node('cinder')
     self.should_contain_os_with_minimal_size(VolumeManager(node))
     self.all_free_space_except_os_for_volume(
         VolumeManager(node).volumes, 'cinder')
     self.check_disk_size_equal_sum_of_all_volumes(
         VolumeManagerExtension.get_node_volumes(node))
Esempio n. 2
0
    def test_check_disk_space_for_deployment(self):
        min_size = 100000

        volumes_metadata = self.env.get_default_volumes_metadata()
        volumes_roles_mapping = volumes_metadata['volumes_roles_mapping']

        for role, space_info in six.iteritems(volumes_roles_mapping):
            node, min_installation_size = self.\
                create_node_and_calculate_min_size(
                    role, space_info, volumes_metadata)

            self.update_node_with_single_disk(node, min_size)
            vm = VolumeManager(node)
            with patch.object(vm,
                              '_VolumeManager'
                              '__calc_minimal_installation_size',
                              return_value=min_size):
                vm.check_disk_space_for_deployment()

            self.update_node_with_single_disk(node, min_size - 1)
            vm = VolumeManager(node)
            with patch.object(vm,
                              '_VolumeManager'
                              '__calc_minimal_installation_size',
                              return_value=min_size):
                self.assertRaises(
                    errors.NotEnoughFreeSpace,
                    vm.check_disk_space_for_deployment
                )
Esempio n. 3
0
 def test_allocates_space_single_disk_for_ceph_for_ceph_role(self):
     node = self.create_node('ceph-osd')
     self.update_node_with_single_disk(node, 30000)
     self.should_contain_os_with_minimal_size(VolumeManager(node))
     self.all_free_space_except_os_for_volume(
         VolumeManager(node).volumes, 'ceph')
     self.check_disk_size_equal_sum_of_all_volumes(
         VolumeManagerExtension.get_node_volumes(node))
Esempio n. 4
0
 def test_multirole_controller_cinder_ceph(self):
     node = self.create_node('controller', 'cinder', 'ceph-osd')
     self.should_contain_os_with_minimal_size(VolumeManager(node))
     self.should_allocates_same_size(
         VolumeManager(node).volumes, ['image', 'cinder', 'ceph'])
     self.logical_volume_sizes_should_equal_all_phisical_volumes(
         VolumeManagerExtension.get_node_volumes(node))
     self.check_disk_size_equal_sum_of_all_volumes(
         VolumeManagerExtension.get_node_volumes(node))
Esempio n. 5
0
    def test_calc_minimal_installation_size(self):
        volumes_metadata = self.env.get_default_volumes_metadata()
        volumes_roles_mapping = volumes_metadata['volumes_roles_mapping']

        for role, space_info in six.iteritems(volumes_roles_mapping):
            node = self.create_node(role)
            vm = VolumeManager(node)
            self.assertEqual(
                vm._VolumeManager__calc_minimal_installation_size(),
                self.__calc_minimal_installation_size(vm))
Esempio n. 6
0
    def test_calc_minimal_installation_size(self):
        volumes_metadata = self.env.get_default_volumes_metadata()
        volumes_roles_mapping = volumes_metadata['volumes_roles_mapping']

        for role, space_info in six.iteritems(volumes_roles_mapping):
            node = self.create_node(role)
            vm = VolumeManager(node)
            self.assertEqual(
                vm._VolumeManager__calc_minimal_installation_size(),
                self.__calc_minimal_installation_size(vm)
            )
Esempio n. 7
0
    def test_check_volume_size_for_deployment(self):
        node = self.create_node('controller', 'ceph-osd')
        # First disk contains more than minimum size of all VGs
        self.update_node_with_single_disk(node, 116384)
        # Second is taken entirely by ceph
        self.add_disk_to_node(node, 65536)
        VolumeManager(node).check_volume_sizes_for_deployment()

        # First disk contains less than minimum size of all VGs
        self.update_node_with_single_disk(node, 16384)
        # Second is taken entirely by ceph
        self.add_disk_to_node(node, 65536)
        self.assertRaises(
            errors.NotEnoughFreeSpace,
            VolumeManager(node).check_volume_sizes_for_deployment)
Esempio n. 8
0
 def create_node_and_calculate_min_size(self, role, space_info,
                                        volumes_metadata):
     node = self.create_node(role)
     volume_manager = VolumeManager(node)
     min_installation_size = self.__calc_minimal_installation_size(
         volume_manager)
     return node, min_installation_size
Esempio n. 9
0
    def test_get_default_attrs(self):
        self.env.create_node(api=False)
        node_db = self.env.nodes[0]
        volumes_from_api = self.get(node_db.id)

        default_volumes = VolumeManager(node_db).gen_volumes_info()
        disks = only_disks(default_volumes)

        self.assertEqual(len(disks), len(volumes_from_api))
Esempio n. 10
0
    def test_check_disk_space_for_deployment(self):
        min_size = 100000

        volumes_metadata = self.env.get_default_volumes_metadata()
        volumes_roles_mapping = volumes_metadata['volumes_roles_mapping']

        for role, space_info in six.iteritems(volumes_roles_mapping):
            node, min_installation_size = self.\
                create_node_and_calculate_min_size(
                    role, space_info, volumes_metadata)

            self.update_node_with_single_disk(node, min_size)
            vm = VolumeManager(node)
            with patch.object(vm, '_VolumeManager'
                              '__calc_minimal_installation_size',
                              return_value=min_size):
                vm.check_disk_space_for_deployment()

            self.update_node_with_single_disk(node, min_size - 1)
            vm = VolumeManager(node)
            with patch.object(vm, '_VolumeManager'
                              '__calc_minimal_installation_size',
                              return_value=min_size):
                self.assertRaises(errors.NotEnoughFreeSpace,
                                  vm.check_disk_space_for_deployment)
Esempio n. 11
0
    def test_allocates_all_free_space_for_os_for_controller_role(self):
        node = self.create_node('controller')
        disks = only_disks(VolumeManager(node).volumes)
        disks_size_sum = sum([disk['size'] for disk in disks])
        os_sum_size = self.os_size(disks)
        mysql_sum_size = self.mysql_size(disks)
        glance_sum_size = self.glance_size(disks)
        horizon_sum_size = self.horizon_size(disks)
        logs_sum_size = self.logs_size(disks)
        reserved_size = self.reserved_size(disks)

        self.assertEqual(
            disks_size_sum - reserved_size, os_sum_size + glance_sum_size +
            mysql_sum_size + logs_sum_size + horizon_sum_size)
        self.logical_volume_sizes_should_equal_all_phisical_volumes(
            VolumeManagerExtension.get_node_volumes(node))
        self.check_disk_size_equal_sum_of_all_volumes(
            VolumeManagerExtension.get_node_volumes(node))
Esempio n. 12
0
 def update_ram_and_assert_swap_size(self, node, size, swap_size):
     new_meta = deepcopy(node.meta)
     new_meta['memory']['total'] = (1024**2) * size
     node.meta = new_meta
     self.env.db.commit()
     self.assertEqual(VolumeManager(node)._calc_swap_size(), swap_size)
Esempio n. 13
0
 def volume_manager(self):
     # TODO(eli): will be moved into an extension.
     # Should be done as a part of blueprint:
     # https://blueprints.launchpad.net/fuel/+spec
     #                                 /volume-manager-refactoring
     return VolumeManager(self)
Esempio n. 14
0
 def test_find_existing_disk_empty_volumes(self):
     disk_info = {'disk': 'disk_id', 'extra': []}
     with patch.object(VolumeManager, '_build_disk_id_by_keys') \
             as id_builder:
         self.assertIsNone(VolumeManager.find_existing_disk(disk_info, []))
         self.assertEqual(0, id_builder.call_count)
Esempio n. 15
0
 def test_find_existing_disk_empty_volumes(self):
     disk_info = {'disk': 'disk_id', 'extra': []}
     with patch.object(VolumeManager, '_build_disk_id_by_keys') \
             as id_builder:
         self.assertIsNone(VolumeManager.find_existing_disk(disk_info, []))
         self.assertEqual(0, id_builder.call_count)
Esempio n. 16
0
 def check_expected_volume_found_for_disk(self, disk_info, fake_volumes,
                                          expected_volume):
     self.assertEqual(
         expected_volume,
         VolumeManager.find_existing_disk(disk_info, fake_volumes)[0])
Esempio n. 17
0
 def test_find_existing_disk_empty_volumes(self):
     disk_info = {"disk": "disk_id", "extra": []}
     with patch.object(VolumeManager, "_build_disk_id_by_keys") as id_builder:
         self.assertIsNone(VolumeManager.find_existing_disk(disk_info, []))
         self.assertEqual(0, id_builder.call_count)
Esempio n. 18
0
 def test_allocates_full_disks_for_ceph_for_ceph_role(self):
     node = self.create_node('ceph-osd')
     self.should_contain_os_with_minimal_size(VolumeManager(node))
     self.all_free_space_except_os_disks_for_volume(VolumeManager(node),
                                                    'ceph')
Esempio n. 19
0
 def check_expected_volume_found_for_disk(self, disk_info, fake_volumes,
                                          expected_volume):
     self.assertEqual(expected_volume,
                      VolumeManager.find_existing_disk(disk_info,
                                                       fake_volumes)[0])
Esempio n. 20
0
 def volume_manager(self):
     return VolumeManager(self)