----- Original Message -----
From: "Vratislav Podzimek" vpodzime@redhat.com To: "anaconda patch review" anaconda-patches@lists.fedorahosted.org Sent: Wednesday, June 25, 2014 2:01:15 AM Subject: Re: [blivet:master 5/7] Canonicalize mdadm generated UUIDS (#1070095)
On Tue, 2014-06-24 at 13:04 -0400, mulhern wrote:
Related: rhbz#1070095
Examined alternatives are:
- To make use of the uuid.UUID class to store uuids. The difficulty
with this idea is that some things that are labeled uuids are not proper uuids at all. 2) To make the udev_info dict more object oriented, and have it sanitize uuids when they are added. A lot of work for very limited benefit. 3) To canonicalize uuids everytime they are extracted from the info. Brittle, since you can't stop code from accessing the entries directly, and annoyingly inefficient.
This alternative is pretty simple, and to a certain extent it's a workaround for a bug in mdadm, so it wins.
Signed-off-by: mulhern amulhern@redhat.com
blivet/devicelibs/mdraid.py | 9 +++++++++ tests/devicelibs_test/mdraid_test.py | 5 +++++ 2 files changed, 14 insertions(+)
diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py index f46571a..ae500a4 100644 --- a/blivet/devicelibs/mdraid.py +++ b/blivet/devicelibs/mdraid.py @@ -242,6 +242,15 @@ 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'
- import uuid
- for k, v in ((k,v) for (k,v) in info.iteritems() if
k.endswith("UUID")):
This almost looks like a candidate for PEP to enable things like: for k, v in info.iteritems() if k.endswith("UUID"): directly. Thanks for using the generator and generating method of info.
info[k] = str(uuid.UUID(''.join(v.split(':'))))
I believe str(uuid.UUID(v.replace(":", "")) would be better readable.
-- Vratislav Podzimek
Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
Done.
- mulhern