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

mulhern amulhern at redhat.com
Thu Jul 3 15:19:47 UTC 2014


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']
 
-- 
1.9.3



More information about the anaconda-patches mailing list