コード例 #1
0
    def on_save_clicked(self, button):
        if self.exists:
            self.window.destroy()
            return

        # If no name was entered, quit the dialog as if they did nothing.
        name = self._name_entry.get_text().strip()
        if not name:
            self._error = _(EMPTY_NAME_MSG)
            self._error_label.set_text(self._error)
            self.window.show_all()
            return

        model, paths = self._treeview.get_selection().get_selected_rows()

        raid_level = selectedRaidLevel(self._raidLevelCombo)
        if raid_level:
            md_level = mdraid.getRaidLevel(raid_level)
            min_disks = md_level.min_members
            if len(paths) < min_disks:
                self._error = (_(RAID_NOT_ENOUGH_DISKS) % {
                    "level": md_level,
                    "min": min_disks,
                    "count": len(paths)
                })
                self._error_label.set_text(self._error)
                self.window.show_all()
                return

        idx = self._sizeCombo.get_active()
        if idx == 0:
            size = SIZE_POLICY_AUTO
        elif idx == 1:
            size = SIZE_POLICY_MAX
        elif idx == 2:
            size = size_from_entry(self._sizeEntry)
            if size is None:
                size = SIZE_POLICY_MAX

        # now save the changes

        self.selected = []
        for path in paths:
            itr = model.get_iter(path)
            disk_id = model.get_value(itr, 4)
            self.selected.append(self._get_disk_by_id(disk_id))

        self.name = name
        self.raid_level = raid_level
        self.encrypted = self._encryptCheckbutton.get_active()
        self.size_policy = size

        self._error_label.set_text("")
        self.window.destroy()
コード例 #2
0
    def on_save_clicked(self, button):
        if self.exists:
            self.window.destroy()
            return

        # If no name was entered, quit the dialog as if they did nothing.
        name = self._name_entry.get_text().strip()
        if not name:
            self._error = _(EMPTY_NAME_MSG)
            self._error_label.set_text(self._error)
            self.window.show_all()
            return

        model, paths = self._treeview.get_selection().get_selected_rows()

        raid_level = selectedRaidLevel(self._raidLevelCombo)
        if raid_level:
            md_level = mdraid.getRaidLevel(raid_level)
            min_disks = md_level.min_members
            if len(paths) < min_disks:
                self._error = (_(RAID_NOT_ENOUGH_DISKS) % {"level" : md_level,
                                                           "min" : min_disks,
                                                           "count" : len(paths)})
                self._error_label.set_text(self._error)
                self.window.show_all()
                return

        idx = self._sizeCombo.get_active()
        if idx == 0:
            size = SIZE_POLICY_AUTO
        elif idx == 1:
            size = SIZE_POLICY_MAX
        elif idx == 2:
            size = size_from_entry(self._sizeEntry)
            if size is None:
                size = SIZE_POLICY_MAX

        # now save the changes

        self.selected = []
        for path in paths:
            itr = model.get_iter(path)
            disk_id = model.get_value(itr, 4)
            self.selected.append(self._get_disk_by_id(disk_id))

        self.name = name
        self.raid_level = raid_level
        self.encrypted = self._encryptCheckbutton.get_active()
        self.size_policy = size

        self._error_label.set_text("")
        self.window.destroy()
コード例 #3
0
ファイル: mdraid_test.py プロジェクト: Sabayon/blivet
    def testMDRaid(self):

        ##
        ## getRaidLevel
        ##
        self.assertEqual(mdraid.getRaidLevel("container").name, "container")
        self.assertEqual(mdraid.getRaidLevel("stripe").name, "raid0")
        self.assertEqual(mdraid.getRaidLevel("mirror").name, "raid1")
        self.assertEqual(mdraid.getRaidLevel("4").name, "raid4")
        self.assertEqual(mdraid.getRaidLevel(5).name, "raid5")
        self.assertEqual(mdraid.getRaidLevel("RAID6").name, "raid6")
        self.assertEqual(mdraid.getRaidLevel("raid10").name, "raid10")

        ##
        ## get_raid_superblock_size
        ##
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="256 GiB")),
                         Size(spec="128 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="128 GiB")),
                         Size(spec="128 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="64 GiB")),
                         Size(spec="64 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="63 GiB")),
                         Size(spec="32 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="10 GiB")),
                         Size(spec="8 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="1 GiB")),
                         Size(spec="1 MiB"))
        self.assertEqual(
            mdraid.get_raid_superblock_size(Size(spec="1023 MiB")),
            Size(spec="1 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size(spec="512 MiB")),
                         Size(spec="1 MiB"))

        self.assertEqual(
            mdraid.get_raid_superblock_size(Size(spec="257 MiB"),
                                            version="version"),
            mdraid.MD_SUPERBLOCK_SIZE)
コード例 #4
0
ファイル: mdraid_test.py プロジェクト: ryanlerch/blivet
    def testMDRaid(self):

        ##
        ## getRaidLevel
        ##
        self.assertEqual(mdraid.getRaidLevel("container").name, "container")
        self.assertEqual(mdraid.getRaidLevel("stripe").name, "raid0")
        self.assertEqual(mdraid.getRaidLevel("mirror").name, "raid1")
        self.assertEqual(mdraid.getRaidLevel("4").name, "raid4")
        self.assertEqual(mdraid.getRaidLevel(5).name, "raid5")
        self.assertEqual(mdraid.getRaidLevel("RAID6").name, "raid6")
        self.assertEqual(mdraid.getRaidLevel("raid10").name, "raid10")

        ##
        ## get_raid_superblock_size
        ##
        self.assertEqual(mdraid.get_raid_superblock_size(Size("256 GiB")),
                         Size("128 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("128 GiB")),
                         Size("128 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("64 GiB")),
                         Size("64 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("63 GiB")),
                         Size("32 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("10 GiB")),
                         Size("8 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("1 GiB")),
                         Size("1 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("1023 MiB")),
                         Size("1 MiB"))
        self.assertEqual(mdraid.get_raid_superblock_size(Size("512 MiB")),
                         Size("1 MiB"))

        self.assertEqual(mdraid.get_raid_superblock_size(Size("257 MiB"),
                                                         version="version"),
                         mdraid.MD_SUPERBLOCK_SIZE)