[blivet:master 10/16] Check for required methods in MDRaidLevels.isRaidLevel.

Anne Mulhern amulhern at redhat.com
Tue May 6 18:36:17 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Tuesday, May 6, 2014 2:23:14 PM
> Subject: Re: [blivet:master 10/16] Check for required methods in	MDRaidLevels.isRaidLevel.
> 
> 
> 
> On 05/06/2014 11:42 AM, mulhern wrote:
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >   blivet/devicelibs/mdraid.py | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py
> > index 715f5df..1859f59 100644
> > --- a/blivet/devicelibs/mdraid.py
> > +++ b/blivet/devicelibs/mdraid.py
> > @@ -37,7 +37,11 @@ MD_CHUNK_SIZE = Size(spec="512 KiB")
> >   class MDRaidLevels(raid.RAIDLevels):
> >       @classmethod
> >       def isRaidLevel(cls, level):
> > -        return super(MDRaidLevels, cls).isRaidLevel(level)
> > +        return super(MDRaidLevels, cls).isRaidLevel(level) and \
> > +           hasattr(level, 'get_max_spares') and \
> > +           hasattr(level, 'get_base_member_size') and \
> > +           hasattr(level, 'get_recommended_stride') and \
> > +           hasattr(level, 'get_size')
> 
> Are these not enforced/required by the RAIDLevel class hierarchy itself?
> 
> >
> >   _RAID_levels = MDRaidLevels(["raid0", "raid1", "raid4", "raid5", "raid6",
> >   "raid10", "container"])
> >
> >
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

The RAIDLevel class is a superclass of RAID<n> classes that have
much stronger commonalities with each other than any of the RAID<n>
classes have with either Container or LinearRAID. It handles
common implementation of a lot of things between the
RAID<n> classes.

However, it would be easy to make a superclass of RAIDLevel,
LinearRAID, and Container which enforced the interface above.
Proably RAIDLevel should be renamed to, e.g., RAIDN, and the superclass
of all could be called RAIDLevel.

The reason I did not have such a superclass is because I believed that,
e.g., btrfs might evolve some different expectations of its RAID objects
than mdraid has and it might be better to keep those ideas distinct.

- mulhern


More information about the anaconda-patches mailing list