Re: [PATCH rhel6-branch 3/3] Handle devices that don't have a /dev/disk/by-path/ symlink (#563242)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack.

On Wed, 12 May 2010, Peter Jones wrote:

Looks like for non-disk devices, udev doesn't build a /dev/disk/by-path/
symlink, so we can't reliably use that. If we're in that case, just use
device.path .
---
storage/devices.py    |    9 ++++++---
storage/devicetree.py |    8 ++++----
storage/errors.py     |    3 +++
3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 03a8cdf..0b561e8 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -150,12 +150,15 @@ def deviceNameToDiskByPath(deviceName=None):
    if not deviceName:
        return ""

+    ret = None
    for dev in udev_get_block_devices():
        if udev_device_get_name(dev) == deviceName:
-            return udev_device_get_by_path(dev)
-
-    return None
+            ret = udev_device_get_by_path(dev)
+            break

+    if ret:
+        return ret
+    raise DeviceNotFoundError(deviceName)

class Device(object):
    """ A generic device.
diff --git a/storage/devicetree.py b/storage/devicetree.py
index c171968..93aa005 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1357,11 +1357,11 @@ class DeviceTree(object):
            initcb = lambda: True
        else:
            description = device.description or device.model
-            bypath = deviceNameToDiskByPath(device.name)
-            if bypath:
-                bypath = os.path.basename(bypath)
+            try:
+                bypath = os.path.basename(deviceNameToDiskByPath(device.name))
                details = "\n\nDevice details:\n%s" % (bypath,)
-            else:
+            except DeviceNotFoundError:
+                # some devices don't have a /dev/disk/by-path/ #!@#@!@#
                bypath = device.name
                details = ""

diff --git a/storage/errors.py b/storage/errors.py
index c4d4313..ea7e79c 100644
--- a/storage/errors.py
+++ b/storage/errors.py
@@ -129,6 +129,9 @@ class MPathError(StorageError):
class DeviceTreeError(StorageError):
    pass

+class DeviceNotFoundError(StorageError):
+    pass
+
# DeviceAction
class DeviceActionError(StorageError):
    pass


- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkvsF+8ACgkQ5hsjjIy1VklgAQCfVbJQwPVAnnvTegx+4KGO5prJ
AU0An3uSZIbShMMSDT8nRLDHcFqYf+qb
=CxWl
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux