Ejemplo n.º 1
0
    def test_recalculates_vg_sizes_when_disks_volumes_size_update(self):
        node_db = self.create_node()
        disks = self.get(node_db.id)

        vgs_before_update = filter(
            lambda volume: volume.get('type') == 'vg',
            VolumeManagerExtension.get_node_volumes(node_db))

        new_volume_size = 4200
        updated_disks_count = 0
        for disk in disks:
            if disk['size'] > 0:
                for volume in disk['volumes']:
                    volume['size'] = new_volume_size
                updated_disks_count += 1

        self.put(node_db.id, disks)

        vgs_after_update = filter(
            lambda volume: volume.get('type') == 'vg',
            VolumeManagerExtension.get_node_volumes(node_db))

        for vg_before, vg_after in zip(vgs_before_update, vgs_after_update):
            size_volumes_before = sum(
                [volume.get('size', 0) for volume in vg_before['volumes']])
            size_volumes_after = sum(
                [volume.get('size', 0) for volume in vg_after['volumes']])

            self.assertNotEqual(size_volumes_before, size_volumes_after)

            volume_group_size = new_volume_size * updated_disks_count
            self.assertEqual(size_volumes_after, volume_group_size)
Ejemplo n.º 2
0
    def test_recalculates_vg_sizes_when_disks_volumes_size_update(self):
        node_db = self.create_node()
        disks = self.get(node_db.id)

        vgs_before_update = filter(
            lambda volume: volume.get('type') == 'vg',
            VolumeManagerExtension.get_node_volumes(node_db))

        new_volume_size = 4200
        updated_disks_count = 0
        for disk in disks:
            if disk['size'] > 0:
                for volume in disk['volumes']:
                    volume['size'] = new_volume_size
                updated_disks_count += 1

        self.put(node_db.id, disks)

        vgs_after_update = filter(
            lambda volume: volume.get('type') == 'vg',
            VolumeManagerExtension.get_node_volumes(node_db))

        for vg_before, vg_after in zip(vgs_before_update, vgs_after_update):
            size_volumes_before = sum([
                volume.get('size', 0) for volume in vg_before['volumes']])
            size_volumes_after = sum([
                volume.get('size', 0) for volume in vg_after['volumes']])

            self.assertNotEqual(size_volumes_before, size_volumes_after)

            volume_group_size = new_volume_size * updated_disks_count
            self.assertEqual(size_volumes_after, volume_group_size)
Ejemplo n.º 3
0
 def test_allocates_all_free_space_for_vm_for_compute_role(self):
     node = self.create_node('compute')
     self.should_contain_os_with_minimal_size(VolumeManager(node))
     self.all_free_space_except_os_for_volume(
         VolumeManager(node).volumes, 'vm')
     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))
Ejemplo 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(node.volume_manager)
     self.should_allocates_same_size(
         node.volume_manager.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))
Ejemplo n.º 5
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))
Ejemplo n.º 6
0
 def test_allocates_all_free_space_for_vm_for_compute_role(self):
     node = self.create_node('compute')
     self.should_contain_os_with_minimal_size(node.volume_manager)
     self.all_free_space_except_os_for_volume(
         node.volume_manager.volumes, 'vm')
     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))
Ejemplo n.º 7
0
    def test_allocates_all_free_space_for_os_for_controller_role(self):
        node = self.create_node('controller')
        disks = only_disks(node.volume_manager.volumes)
        disks_size_sum = sum([disk['size'] for disk in disks])
        os_sum_size = self.os_size(disks)
        glance_sum_size = self.glance_size(disks)
        reserved_size = self.reserved_size(disks)

        self.assertEqual(disks_size_sum - reserved_size,
                         os_sum_size + glance_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))
Ejemplo n.º 8
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))
Ejemplo n.º 9
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(node.volume_manager)
     self.all_free_space_except_os_for_volume(node.volume_manager.volumes,
                                              'cinder')
     self.check_disk_size_equal_sum_of_all_volumes(
         VolumeManagerExtension.get_node_volumes(node))
Ejemplo n.º 10
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(node.volume_manager)
     self.all_free_space_except_os_for_volume(
         node.volume_manager.volumes, 'ceph')
     self.check_disk_size_equal_sum_of_all_volumes(
         VolumeManagerExtension.get_node_volumes(node))
Ejemplo n.º 11
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))
Ejemplo n.º 12
0
    def test_allocates_all_free_space_for_os_for_controller_role(self):
        node = self.create_node('controller')
        disks = only_disks(node.volume_manager.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)
        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)
        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))
Ejemplo n.º 13
0
 def setUp(self):
     super(TestVolumeManagerHelpers, self).setUp()
     self.env.create(nodes_kwargs=[
         {
             'roles': ['controller']
         },
     ])
     self.node = self.env.nodes[0]
     self.volumes = VolumeManagerExtension.get_node_volumes(self.node)
Ejemplo n.º 14
0
 def setUp(self):
     super(TestVolumeManagerHelpers, self).setUp()
     self.env.create(
         nodes_kwargs=[
             {'roles': ['controller']},
         ]
     )
     self.node = self.env.nodes[0]
     self.volumes = VolumeManagerExtension.get_node_volumes(self.node)
Ejemplo n.º 15
0
    def test_node_serialization(self):
        for node in self.serialized_cluster['nodes']:
            node_db = self.db.query(Node).filter_by(
                hostname=node['name']).first()
            # Get interface (in our case we created only one for each node)
            intr_db = node_db.nic_interfaces[0]
            intr_name = intr_db.name
            intr_mac = intr_db.mac
            kernal_params = self.attributes.get('kernel_params', {}) \
                .get('kernel', {}).get('value')
            self.assertEqual(
                node['ks_meta']['cloud_init_templates'], {
                    'boothook': 'boothook_fuel_6.1_centos.jinja2',
                    'cloud_config': 'cloud_config_fuel_6.1_centos.jinja2',
                    'meta_data': 'meta_data_fuel_6.1_centos.jinja2'
                })
            self.assertEqual(node['uid'], node_db.uid)
            self.assertEqual(node['power_address'], node_db.ip)
            self.assertEqual(node['name'], "node-{0}".format(node_db.id))
            self.assertEqual(node['hostname'],
                             objects.Node.get_node_fqdn(node_db))
            self.assertEqual(node['power_pass'],
                             settings.PATH_TO_BOOTSTRAP_SSH_KEY)

            self.assertDictEqual(
                node['kernel_options'], {
                    'netcfg/choose_interface':
                    objects.Node.get_admin_physical_iface(node_db).mac,
                    'udevrules':
                    '{0}_{1}'.format(intr_mac, intr_name)
                })

            self.assertDictEqual(
                node['ks_meta']['pm_data'], {
                    'ks_spaces':
                    VolumeManagerExtension.get_node_volumes(node_db),
                    'kernel_params': kernal_params
                })
            # Check node interfaces section
            self.assertEqual(node['interfaces'][intr_name]['mac_address'],
                             intr_mac)
            self.assertEqual(node['interfaces'][intr_name]['static'], '0')
            self.assertEqual(node['interfaces'][intr_name]['dns_name'],
                             objects.Node.get_node_fqdn(node_db))
            # Check node interfaces extra section
            self.assertEqual(node['interfaces_extra'][intr_name], {
                'peerdns': 'no',
                'onboot': 'yes'
            })
            # check identity key for mcollective
            self.assertEqual(node['ks_meta']['mco_identity'], node_db.id)
    def test_node_serialization(self):
        for node in self.serialized_cluster['nodes']:
            node_db = self.db.query(Node).filter_by(
                hostname=node['name']
            ).first()
            # Get interface (in our case we created only one for each node)
            intr_db = node_db.nic_interfaces[0]
            intr_name = intr_db.name
            intr_mac = intr_db.mac
            kernal_params = self.attributes.get('kernel_params', {}) \
                .get('kernel', {}).get('value')
            self.assertEqual(
                node['ks_meta']['cloud_init_templates'], {
                    'boothook': 'boothook_fuel_6.1_centos.jinja2',
                    'cloud_config': 'cloud_config_fuel_6.1_centos.jinja2',
                    'meta_data': 'meta_data_fuel_6.1_centos.jinja2'
                }
            )
            self.assertEqual(node['uid'], node_db.uid)
            self.assertEqual(node['power_address'], node_db.ip)
            self.assertEqual(node['name'], "node-{0}".format(node_db.id))
            self.assertEqual(node['hostname'],
                             objects.Node.get_node_fqdn(node_db))
            self.assertEqual(
                node['power_pass'], settings.PATH_TO_BOOTSTRAP_SSH_KEY)

            self.assertDictEqual(node['kernel_options'], {
                'netcfg/choose_interface':
                objects.Node.get_admin_physical_iface(node_db).mac,
                'udevrules': '{0}_{1}'.format(intr_mac, intr_name)
            })

            self.assertDictEqual(node['ks_meta']['pm_data'], {
                'ks_spaces': VolumeManagerExtension.get_node_volumes(node_db),
                'kernel_params': kernal_params
            })
            # Check node interfaces section
            self.assertEqual(
                node['interfaces'][intr_name]['mac_address'], intr_mac)
            self.assertEqual(
                node['interfaces'][intr_name]['static'], '0')
            self.assertEqual(
                node['interfaces'][intr_name]['dns_name'],
                objects.Node.get_node_fqdn(node_db))
            # Check node interfaces extra section
            self.assertEqual(node['interfaces_extra'][intr_name], {
                'peerdns': 'no',
                'onboot': 'yes'
            })
            # check identity key for mcollective
            self.assertEqual(node['ks_meta']['mco_identity'], node_db.id)
Ejemplo n.º 17
0
    def test_update_ceph_partition(self):
        node = self.create_node(roles=['ceph-osd'])
        disks = self.get(node.id)

        new_volume_size = 4321
        for disk in disks:
            if disk['size'] > 0:
                for volume in disk['volumes']:
                    volume['size'] = new_volume_size

        self.put(node.id, disks)
        partitions_after_update = filter(
            lambda volume: volume.get('type') == 'partition',
            VolumeManagerExtension.get_node_volumes(node))

        for partition_after in partitions_after_update:
            self.assertEqual(partition_after['size'], new_volume_size)
Ejemplo n.º 18
0
    def test_update_ceph_partition(self):
        node = self.create_node(roles=["ceph-osd"])
        disks = self.get(node.id)

        new_volume_size = 4321
        for disk in disks:
            if disk["size"] > 0:
                for volume in disk["volumes"]:
                    volume["size"] = new_volume_size

        self.put(node.id, disks)
        partitions_after_update = filter(
            lambda volume: volume.get("type") == "partition", VolumeManagerExtension.get_node_volumes(node)
        )

        for partition_after in partitions_after_update:
            self.assertEqual(partition_after["size"], new_volume_size)
Ejemplo n.º 19
0
    def test_update_ceph_partition(self):
        node = self.create_node(roles=['ceph-osd'])
        disks = self.get(node.id)

        new_volume_size = 4321
        for disk in disks:
            if disk['size'] > 0:
                for volume in disk['volumes']:
                    volume['size'] = new_volume_size

        self.put(node.id, disks)
        partitions_after_update = filter(
            lambda volume: volume.get('type') == 'partition',
            VolumeManagerExtension.get_node_volumes(node))

        for partition_after in partitions_after_update:
            self.assertEqual(partition_after['size'], new_volume_size)