[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]

 



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
-- 
1.7.0.1

_______________________________________________
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