This function resolves an arbitrary device specification (name, path, uuid, or label) to a device name. It returns None if there is a failure. --- storage/udev.py | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/storage/udev.py b/storage/udev.py index 5c17a34..ebd2f27 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -29,6 +29,27 @@ from errors import * import logging log = logging.getLogger("storage") +def udev_resolve_devspec(devspec): + if not devspec: + return None + + ret = None + for dev in udev_get_block_devices(): + if devspec.startswith("LABEL="): + if udev_device_get_label(dev) == devspec[6:]: + ret = dev + break + elif devspec.startswith("UUID="): + if udev_device_get_uuid(dev) == devspec[5:]: + ret = dev + break + else: + if udev_device_get_name(dev) == os.path.basename(devspec): + ret = dev + break + + if ret: + return udev_device_get_name(dev) def udev_get_block_devices(): udev_settle(timeout=30) -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list