[PATCH 12/13] Decide on supported RAID levels in a better way
Vratislav Podzimek
vpodzime at redhat.com
Mon Mar 10 13:22:18 UTC 2014
Supported RAID levels shouldn't be defined in a cryptic way in a .glade file and
processed in at the same cryptic way.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/storage_utils.py | 19 ++++++++++++
pyanaconda/ui/gui/spokes/custom.glade | 36 ----------------------
pyanaconda/ui/gui/spokes/custom.py | 10 +++---
.../ui/gui/spokes/lib/custom_storage_helpers.glade | 36 ----------------------
.../ui/gui/spokes/lib/custom_storage_helpers.py | 11 ++++---
5 files changed, 30 insertions(+), 82 deletions(-)
diff --git a/pyanaconda/storage_utils.py b/pyanaconda/storage_utils.py
index b971111..504f72d 100644
--- a/pyanaconda/storage_utils.py
+++ b/pyanaconda/storage_utils.py
@@ -25,6 +25,20 @@ import locale
from blivet.size import Size
from blivet.errors import SizeParamsError
+from blivet.devicefactory import DEVICE_TYPE_LVM
+from blivet.devicefactory import DEVICE_TYPE_BTRFS
+from blivet.devicefactory import DEVICE_TYPE_MD
+
+# should this and the get_supported_raid_levels go to blivet.devicefactory???
+SUPPORTED_RAID_LEVELS = {DEVICE_TYPE_LVM: {"none", "raid0", "raid1"},
+ DEVICE_TYPE_MD: {"raid0", "raid1", "raid4", "raid5",
+ "raid6", "raid10"},
+ DEVICE_TYPE_BTRFS: {"none", "raid0", "raid1",
+ "raid10"},
+ # no device type for LVM VG
+ # VG: {"none", "raid0", "raid1", "raid4",
+ # "raid5", "raid6", "raid10"},
+ }
def size_from_input(input_str):
"""Get size from user's input"""
@@ -48,3 +62,8 @@ def size_from_input(input_str):
size = Size(spec="1 MiB")
return size
+
+def get_supported_raid_levels(device_type):
+ """Get supported RAID levels for the given device type."""
+
+ return SUPPORTED_RAID_LEVELS.get(device_type, set())
diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index 82110d7..b0e7560 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -1226,71 +1226,35 @@ until you click on the main menu's 'Begin Installation' button.</property>
<column type="gchararray"/>
<!-- column-name canonRaidLevel -->
<column type="gchararray"/>
- <!-- column-name validForLVM -->
- <column type="gboolean"/>
- <!-- column-name validForRAID -->
- <column type="gboolean"/>
- <!-- column-name validForBTRFS -->
- <column type="gboolean"/>
- <!-- column-name validForVG -->
- <column type="gboolean"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">None</col>
<col id="1">none</col>
- <col id="2">True</col>
- <col id="3">False</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID0 <span foreground="grey">(Performance)</span></col>
<col id="1">raid0</col>
- <col id="2">True</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID1 <span foreground="grey">(Redundancy)</span></col>
<col id="1">raid1</col>
- <col id="2">True</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID4 <span foreground="grey">(Error Checking)</span></col>
<col id="1">raid4</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID5 <span foreground="grey">(Distributed Error Checking)</span></col>
<col id="1">raid5</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID6 <span foreground="grey">(Redundant Error Checking)</span></col>
<col id="1">raid6</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID10 <span foreground="grey">(Performance, Redundancy)</span></col>
<col id="1">raid10</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
</data>
</object>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 45050d4..afae999 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -63,6 +63,8 @@ from blivet.errors import LUKSDeviceWithoutKeyError
from blivet.devicelibs import mdraid
from blivet.devices import LUKSDevice
+from pyanaconda.storage_utils import get_supported_raid_levels
+
from pyanaconda.ui.communication import hubQ
from pyanaconda.ui.gui.spokes import NormalSpoke
from pyanaconda.ui.gui.spokes.storage import StorageChecker
@@ -1134,12 +1136,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
def _raid_level_visible(self, model, itr, user_data):
device_type = self._get_current_device_type()
- if device_type == DEVICE_TYPE_LVM:
- return model[itr][2]
- elif device_type == DEVICE_TYPE_MD:
- return model[itr][3]
- elif device_type == DEVICE_TYPE_BTRFS:
- return model[itr][4]
+ raid_level = model[itr][1]
+ return raid_level in get_supported_raid_levels(device_type)
def _populate_raid(self, raid_level):
""" Set up the raid-specific portion of the device details. """
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
index 72afdc1..d05d4be 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.glade
@@ -19,71 +19,35 @@
<column type="gchararray"/>
<!-- column-name canonRaidLevel -->
<column type="gchararray"/>
- <!-- column-name validForLVM -->
- <column type="gboolean"/>
- <!-- column-name validForRAID -->
- <column type="gboolean"/>
- <!-- column-name validForBTRFS -->
- <column type="gboolean"/>
- <!-- column-name validForVG -->
- <column type="gboolean"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">None</col>
<col id="1">none</col>
- <col id="2">True</col>
- <col id="3">False</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID0 <span foreground="grey">(Performance)</span></col>
<col id="1">raid0</col>
- <col id="2">True</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID1 <span foreground="grey">(Redundancy)</span></col>
<col id="1">raid1</col>
- <col id="2">True</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID4 <span foreground="grey">(Error Checking)</span></col>
<col id="1">raid4</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID5 <span foreground="grey">(Distributed Error Checking)</span></col>
<col id="1">raid5</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID6 <span foreground="grey">(Redundant Error Checking)</span></col>
<col id="1">raid6</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">False</col>
- <col id="5">True</col>
</row>
<row>
<col id="0" translatable="yes">RAID10 <span foreground="grey">(Performance, Redundancy)</span></col>
<col id="1">raid10</col>
- <col id="2">False</col>
- <col id="3">True</col>
- <col id="4">True</col>
- <col id="5">True</col>
</row>
</data>
</object>
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index ae62476..5bdeea0 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -29,7 +29,7 @@ import re
from pyanaconda.product import productName
from pyanaconda.iutil import lowerASCII
-from pyanaconda.storage_utils import size_from_input
+from pyanaconda.storage_utils import size_from_input, get_supported_raid_levels
from pyanaconda.ui.gui import GUIObject
from pyanaconda.ui.gui.utils import fancy_set_sensitive, really_hide, really_show
from pyanaconda.i18n import _, N_, C_
@@ -40,6 +40,7 @@ from blivet.formats import getFormat
from blivet.devicefactory import SIZE_POLICY_AUTO
from blivet.devicefactory import SIZE_POLICY_MAX
from blivet.devicefactory import DEVICE_TYPE_LVM
+from blivet.devicefactory import DEVICE_TYPE_MD
from blivet.devicefactory import DEVICE_TYPE_BTRFS
from blivet.devicefactory import DEVICE_TYPE_LVM_THINP
from blivet.devicelibs import mdraid
@@ -488,11 +489,13 @@ class ContainerDialog(GUIObject):
self._sizeEntry.set_sensitive(True)
def _raid_level_visible(self, model, itr, user_data):
+ raid_level = model[itr][1]
+
# This is weird because for lvm's container-wide raid we use md.
if self.device_type in (DEVICE_TYPE_LVM, DEVICE_TYPE_LVM_THINP):
- return model[itr][4]
- elif self.device_type == DEVICE_TYPE_BTRFS:
- return model[itr][3]
+ return raid_level in get_supported_raid_levels(DEVICE_TYPE_MD)
+ else:
+ return raid_level in get_supported_raid_levels(self.device_type)
def _populate_raid(self):
""" Set up the raid-specific portion of the device details. """
--
1.8.5.3
More information about the anaconda-patches
mailing list