[blivet:f21-branch 02/14] Factor canonicalize_UUID() into separate method.
mulhern
amulhern at redhat.com
Mon Sep 29 17:22:49 UTC 2014
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devicelibs/mdraid.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py
index e757923..5bb6226 100644
--- a/blivet/devicelibs/mdraid.py
+++ b/blivet/devicelibs/mdraid.py
@@ -221,6 +221,22 @@ def mddeactivate(device):
except MDRaidError as msg:
raise MDRaidError("mddeactivate failed for %s: %s" % (device, msg))
+def canonicalize_UUID(a_uuid):
+ """ Converts uuids to canonical form.
+
+ :param str a_uuid: the UUID
+
+ :returns: a canonicalized UUID
+ :rtype: str
+
+ mdadm's UUIDs are actual 128 bit uuids, but it formats them strangely.
+ This converts the uuids to canonical form.
+ Example:
+ mdadm UUID: '3386ff85:f5012621:4a435f06:1eb47236'
+ canonical UUID: '3386ff85-f501-2621-4a43-5f061eb47236'
+ """
+ return str(uuid.UUID(a_uuid.replace(':', '')))
+
def mdexamine(device):
""" Run mdadm --examine to obtain information about an array member.
@@ -254,13 +270,8 @@ def mdexamine(device):
if name == "metadata":
info["MD_METADATA"] = value
- # mdadm's UUIDs are actual 128 bit uuids, but it formats them strangely.
- # This converts the uuids to canonical form.
- # Example:
- # mdadm UUID: '3386ff85:f5012621:4a435f06:1eb47236'
- # canonical UUID: '3386ff85-f501-2621-4a43-5f061eb47236'
for k, v in ((k,v) for (k,v) in info.iteritems() if k.endswith("UUID")):
- info[k] = str(uuid.UUID(v.replace(':', '')))
+ info[k] = canonicalize_UUID(v)
return info
--
1.9.3
More information about the anaconda-patches
mailing list