Ack. ----- "Hans de Goede" <hdegoede@xxxxxxxxxx> wrote: > Make MDRaidArrayDevice.__init__ raise a value exception when creating > a new (so non existing) raid set and there are not enough members for > the requested raid level. > > And catch this value exception in the GUI raid dialog and kickstart > raid > commands. > --- > iw/raid_dialog_gui.py | 7 ++++++- > kickstart.py | 5 ++++- > storage/devices.py | 6 ++++++ > 3 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py > index e2ffe9a..8431e71 100644 > --- a/iw/raid_dialog_gui.py > +++ b/iw/raid_dialog_gui.py > @@ -201,12 +201,17 @@ class RaidEditor: > format = fmt_class(mountpoint=mountpoint) > members = len(raidmembers) - spares > > - request = self.storage.newMDArray(minor=raidminor, > + try: > + request = > self.storage.newMDArray(minor=raidminor, > level=raidlevel, > format=format, > > parents=raidmembers, > > totalDevices=len(raidmembers), > > memberDevices=members) > + except ValueError, e: > + self.intf.messageWindow(_("Error"), str(e), > + custom_icon="error") > + continue > > # we must destroy luks leaf before original raid > request > if self.origrequest.format.type == "luks": > diff --git a/kickstart.py b/kickstart.py > index 147431b..aca5319 100644 > --- a/kickstart.py > +++ b/kickstart.py > @@ -877,7 +877,10 @@ class Raid(commands.raid.F12_Raid): > except KeyError: > pass > > - request = storage.newMDArray(**kwargs) > + try: > + request = storage.newMDArray(**kwargs) > + except ValueError, e: > + raise KickstartValueError, > formatErrorMsg(self.lineno, msg=str(e)) > > # FIXME: no way to specify an fsprofile right now > # if pd.fsprofile: > diff --git a/storage/devices.py b/storage/devices.py > index 7b4b314..5049765 100644 > --- a/storage/devices.py > +++ b/storage/devices.py > @@ -2197,6 +2197,12 @@ class MDRaidArrayDevice(StorageDevice): > elif level is not None: > self.level = mdraid.raidLevel(level) > > + # For new arrays check if we have enough members > + if (not exists and parents and > + len(parents) < > mdraid.get_raid_min_members(self.level)): > + raise ValueError, _("A RAID%d set requires atleast %d > members") % ( > + self.level, > mdraid.get_raid_min_members(self.level)) > + > self.uuid = uuid > self._totalDevices = numeric_type(totalDevices) > self._memberDevices = numeric_type(memberDevices) > -- > 1.6.5.2 > > _______________________________________________ > Anaconda-devel-list mailing list > Anaconda-devel-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/anaconda-devel-list _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list