[blivet:f21-branch/master 2/3] Don't check for mdmember format when parent is container (#1150147)

Anne Mulhern amulhern at redhat.com
Fri Oct 10 16:42:49 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, October 10, 2014 11:31:44 AM
> Subject: Re: [blivet:f21-branch/master 2/3] Don't check for mdmember format	when parent is container (#1150147)
> 
> On 10/10/2014 10:25 AM, mulhern wrote:
> > Related: fed#1150147
> >
> > Set the required member device format to device format in this case,
> > which should cover everything.
> >
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >   blivet/devices.py | 24 ++++++++++++++++++++++--
> >   1 file changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 6ee5bfe..2afce57 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -2327,9 +2327,29 @@ class ContainerDevice(StorageDevice):
> >           doc="The container UUID attribute in the member format class")
> >
> >       def __init__(self, *args, **kwargs):
> > -        self.formatClass = get_device_format_class(self._formatClassName)
> > +        formatClassName = self._formatClassName
> > +
> > +        parents = kwargs["parents"]
> > +        # Override MDRaidArrayDevice's format class restriction if the
> > +        # member is an mdcontainer.
> > +        # Note that self.formatClass must be set before superclass
> > +        # constructor is called since superclass constructor requires that
> > +        # self._addParent() method have a defined self.formatClass.
> > +        if parents and isinstance(self, MDRaidArrayDevice):
> > +            if isinstance(parents, list):
> > +                parent = parents[0]
> > +            else:
> > +                parent = parents
> > +
> > +            try:
> > +                if parent.type == "mdcontainer":
> > +                    formatClassName = None
> > +            except AttributeError:
> > +                pass
> > +
> > +        self.formatClass = get_device_format_class(formatClassName)
> >           if not self.formatClass:
> > -            raise errors.StorageError("cannot find '%s' class" %
> > self._formatClassName)
> > +            raise errors.StorageError("cannot find '%s' class" %
> > formatClassName)
> >
> >           super(ContainerDevice, self).__init__(*args, **kwargs)
> >
> 
> I'm curious why you opted to put this in ContainerDevice instead of
> doing it in MDRaidArrayDevice. It would be less code and it would keep
> the ContainerDevice class free of type-specific code.
> 
> David
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

It would actually be a bit more code...my cover letter compares this
solution to putting this same logic in MDRaidArrayDevice constructor.

- mulhern


More information about the anaconda-patches mailing list