Ejemplo n.º 1
0
    def max_size(self):
        if self._max_size is None:
            if self.raid_type not in ("linear", "single", None):
                raid_level = get_raid_level(self.raid_type)
                self._max_size = raid_level.get_net_array_size(len(self.parents),
                                                               min([free for _parent, free in self.parents]))
            else:
                self._max_size = sum([free for _parent, free in self.parents])

        return self._max_size
Ejemplo n.º 2
0
def get_raid_level_by_name(name):
    """Get the RAID level object for the given name.

    :param name: a name of the RAID level
    :return: an instance of RAIDLevel
    """
    if not name:
        return None

    return raid.get_raid_level(name)
Ejemplo n.º 3
0
    def total_size(self):
        """ Total size selected in this area """
        total_size = size.Size(0)

        # for raids, total size must be calculated separately
        if self.raid_type not in ("linear", "single", None):
            raid_level = get_raid_level(self.raid_type)
            total_size = raid_level.get_net_array_size(len([chooser for chooser in self.choosers if chooser.selected]),
                                                       min([chooser.selected_size for chooser in self.choosers if chooser.selected]))
        else:
            for chooser in self.choosers:
                total_size += chooser.selected_size

        return total_size
Ejemplo n.º 4
0
def selectedRaidLevel(raidLevelCombo):
    """Interpret the selection of a RAID level combo box.

       :returns: the selected raid level, None if none selected
       :rtype: instance of blivet.devicelibs.raid.RaidLevel or NoneType
    """
    if not raidLevelCombo.get_property("visible"):
        # the combo is hidden when raid level isn't applicable
        return None

    itr = raidLevelCombo.get_active_iter()
    store = raidLevelCombo.get_model()

    if not itr:
        return

    selected_level = store[itr][1]
    if selected_level == "none":
        return None
    else:
        return raid.get_raid_level(selected_level)
Ejemplo n.º 5
0
def selectedRaidLevel(raidLevelCombo):
    """Interpret the selection of a RAID level combo box.

       :returns: the selected raid level, None if none selected
       :rtype: instance of blivet.devicelibs.raid.RaidLevel or NoneType
    """
    if not raidLevelCombo.get_property("visible"):
        # the combo is hidden when raid level isn't applicable
        return None

    itr = raidLevelCombo.get_active_iter()
    store = raidLevelCombo.get_model()

    if not itr:
        return

    selected_level = store[itr][1]
    if selected_level == "none":
        return None
    else:
        return raid.get_raid_level(selected_level)
Ejemplo n.º 6
0
    def test_disk_raid_properties(self):
        volumes = {
            "/dev/test1":
            disklib.LSMInfo("Test 1", ["/dev/test1"],
                            raid.get_raid_level("raid0"), Size("512 KiB"), 4),
            "/dev/test2":
            disklib.LSMInfo("Test 2", ["/dev/test2"], None, None, None)
        }

        test1 = DiskDevice("test1")
        test2 = DiskDevice("test2")
        test3 = DiskDevice("test3")
        # DiskDevice attributes should have the same values as the corresponding LSMInfo, or None
        with patch("blivet.devices.disk.disklib") as _disklib:
            _disklib.volumes = volumes

            test1_volume = volumes[test1.path]
            self.assertEqual(test1._volume, volumes[test1.path])
            self.assertEqual(test1.raid_system, test1_volume.system)
            self.assertEqual(test1.raid_level, test1_volume.raid_type)
            self.assertEqual(test1.raid_stripe_size,
                             test1_volume.raid_stripe_size)
            self.assertEqual(test1.raid_disk_count,
                             test1_volume.raid_disk_count)

            test2_volume = volumes[test2.path]
            self.assertEqual(test2._volume, volumes[test2.path])
            self.assertEqual(test2._volume, test2_volume)
            self.assertEqual(test2.raid_system, test2_volume.system)
            self.assertEqual(test2.raid_level, test2_volume.raid_type)
            self.assertEqual(test2.raid_stripe_size,
                             test2_volume.raid_stripe_size)
            self.assertEqual(test2.raid_disk_count,
                             test2_volume.raid_disk_count)

            self.assertIsNone(test3._volume)
            self.assertIsNone(test3.raid_system)
            self.assertIsNone(test3.raid_level)
            self.assertIsNone(test3.raid_stripe_size)
            self.assertIsNone(test3.raid_disk_count)
Ejemplo n.º 7
0
    def test_disk_raid_properties(self):
        volumes = {"/dev/test1": disklib.LSMInfo("Test 1",
                                                 ["/dev/test1"],
                                                 raid.get_raid_level("raid0"),
                                                 Size("512 KiB"),
                                                 4),
                   "/dev/test2": disklib.LSMInfo("Test 2",
                                                 ["/dev/test2"],
                                                 None,
                                                 None,
                                                 None)}

        test1 = DiskDevice("test1")
        test2 = DiskDevice("test2")
        test3 = DiskDevice("test3")
        # DiskDevice attributes should have the same values as the corresponding LSMInfo, or None
        with patch("blivet.devices.disk.disklib") as _disklib:
            _disklib.volumes = volumes

            test1_volume = volumes[test1.path]
            self.assertEqual(test1._volume, volumes[test1.path])
            self.assertEqual(test1.raid_system, test1_volume.system)
            self.assertEqual(test1.raid_level, test1_volume.raid_type)
            self.assertEqual(test1.raid_stripe_size, test1_volume.raid_stripe_size)
            self.assertEqual(test1.raid_disk_count, test1_volume.raid_disk_count)

            test2_volume = volumes[test2.path]
            self.assertEqual(test2._volume, volumes[test2.path])
            self.assertEqual(test2._volume, test2_volume)
            self.assertEqual(test2.raid_system, test2_volume.system)
            self.assertEqual(test2.raid_level, test2_volume.raid_type)
            self.assertEqual(test2.raid_stripe_size, test2_volume.raid_stripe_size)
            self.assertEqual(test2.raid_disk_count, test2_volume.raid_disk_count)

            self.assertIsNone(test3._volume)
            self.assertIsNone(test3.raid_system)
            self.assertIsNone(test3.raid_level)
            self.assertIsNone(test3.raid_stripe_size)
            self.assertIsNone(test3.raid_disk_count)
Ejemplo n.º 8
0
 def _raid_level_visible(self, model, itr, user_data):
     raid_level_str = model[itr][1]
     raid_level = raid.get_raid_level(
         raid_level_str) if raid_level_str != "none" else None
     return raid_level in containerRaidLevelsSupported(self.device_type)
Ejemplo n.º 9
0
 def _raid_level_visible(self, model, itr, user_data):
     raid_level_str = model[itr][1]
     raid_level = raid.get_raid_level(raid_level_str) if raid_level_str != "none" else None
     return raid_level in containerRaidLevelsSupported(self.device_type)