[blivet:master 08/11] Add a udev_device_get_md_metadata() method to udev and use it.

Vratislav Podzimek vpodzime at redhat.com
Mon Jul 7 18:42:20 UTC 2014


On Mon, 2014-07-07 at 09:04 -0400, Anne Mulhern wrote:
> 
> 
> 
> ----- Original Message -----
> > From: "Vratislav Podzimek" <vpodzime at redhat.com>
> > To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> > Sent: Friday, July 4, 2014 3:03:14 AM
> > Subject: Re: [blivet:master 08/11] Add a udev_device_get_md_metadata()	method to udev and use it.
> > 
> > On Thu, 2014-07-03 at 11:19 -0400, mulhern wrote:
> > > Signed-off-by: mulhern <amulhern at redhat.com>
> > > ---
> > >  blivet/devicetree.py |  6 ++++--
> > >  blivet/udev.py       | 12 ++++++++++++
> > >  2 files changed, 16 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/blivet/devicetree.py b/blivet/devicetree.py
> > > index aaa287c..64aa5ac 100644
> > > --- a/blivet/devicetree.py
> > > +++ b/blivet/devicetree.py
> > > @@ -1602,7 +1602,7 @@ class DeviceTree(object):
> > >  
> > >                  if dev_uuid == md_uuid and dev_level == md_level:
> > >                      md_name = udev.udev_device_get_md_name(dev)
> > > -                    md_metadata = dev.get("MD_METADATA")
> > > +                    md_metadata = udev.udev_device_get_md_metadata(dev)
> > >                      if not md_name:
> > >                          # containers don't typically have names and they
> > >                          also
> > >                          # don't have a symlink in /dev/md
> > > @@ -1616,7 +1616,9 @@ class DeviceTree(object):
> > >  
> > >              # mdexamine yields MD_METADATA only for metadata version >
> > >              0.90
> > >              # if MD_METADATA is missing, assume metadata version is 0.90
> > > -            md_metadata = md_metadata or info.get("MD_METADATA", "0.90")
> > > +            md_metadata = md_metadata or \
> > > +               udev.udev_device_get_md_metadata(info) or \
> > > +               "0.90"
> > >  
> > >              if not md_name:
> > >                  md_path = info.get("DEVICE", "")
> > > diff --git a/blivet/udev.py b/blivet/udev.py
> > > index bc4e21f..d3a8259 100644
> > > --- a/blivet/udev.py
> > > +++ b/blivet/udev.py
> > > @@ -434,6 +434,18 @@ def udev_device_get_md_name(info):
> > >      #  * No known metadata versions for mdraid/mdadm
> > >      return info.get("MD_DEVNAME")
> > >  
> > > +def udev_device_get_md_metadata(info):
> > > +    """ Return the metadata version number.
> > > +
> > > +        :param dict info: dictionary of name-value pairs as strings
> > > +        :returns: the metadata version number of the md array
> > > +        :rtype: str or NoneType
> > > +    """
> > > +    # Value for MD_METADATA known to be obtained from:
> > > +    #  * pyudev/libudev
> > > +    #  * mdraid/mdadm (not version numbers < 1)
> > > +    return info.get("MD_METADATA")
> > > +
> > >  def udev_device_get_vg_name(info):
> > >      return info['LVM2_VG_NAME']
> > A similar note here inspired by a new udev_ function added to the udev
> > module -- could we remove the 'udev_' prefix from all those functions?
> > It made sense when there were * imports from the module, but it's just
> > pain now.
> > 
> > --
> > Vratislav Podzimek
> > 
> > Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
> > 
> > 
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> >
> 
> Unless anybody objects I'll go ahead and add a patch for this as well.
Thanks!

> 
> It will affect around 13 files and 350 lines.
> 
> Pros: more pythonic and less verbose naming scheme
> Cons: a lot of lines changed for a mostly cosmetic change
I think the Pros outweigh the Cons.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list