Change uuid parameter to array_uuid

Motivation is to avoid name conflict with uuid import, but new name
is a bit more descriptive.
Improve method docstring a bit as well.

Signed-off-by: mulhern <amulhern@redhat.com>
Use context manager with assertRaises*() tests.

Equivalent expressions that use a context manager are a lot easier to parse.
Add test for raid level descriptor None.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a few small tests for mdexamine

Signed-off-by: mulhern <amulhern@redhat.com>
Document udev.device_get_uuid() method.

Signed-off-by: mulhern <amulhern@redhat.com>
Add documentation to udev.device_get_md_*() methods.

The inline comments indicate the likely origin of the value.

Signed-off-by: mulhern <amulhern@redhat.com>
Do not convert the result of udev.device_get_md_devices() to int.

udev.device_get_md_devices() does the conversion.

Signed-off-by: mulhern <amulhern@redhat.com>
Check for md_level of None

udev_device_get_md_level() does not raise a KeyError, it returns None.

Signed-off-by: mulhern <amulhern@redhat.com>
Change use of METADATA to MD_METADATA.

Remove useless access before loop and add an explanatory comment.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a udev.device_get_md_metadata() method to udev and use it.

Signed-off-by: mulhern <amulhern@redhat.com>
Canonicalize mdadm generated UUIDS (#1070095)

Related: rhbz#1070095

Examined alternatives are:
1) 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>
Add new method udev.device_get_md_device_uuid() method (#1070095)

Related: rhbz#1070095

Note that the value is only obtained from mdadm and only if recent
metadata version is used.

Signed-off-by: mulhern <amulhern@redhat.com>
Attempt to reset the uuid of the mdraid member device (#1070095)

Resolves: rhbz#1070095

Note that this information is only available for metadata versions > 0.90.

Signed-off-by: mulhern <amulhern@redhat.com>