[PATCH 13/13] Include udev's list of symbolic links in StorageDevice. (#914724)

David Lehman dlehman at redhat.com
Fri Mar 1 22:13:31 UTC 2013


---
 blivet/deviceaction.py |  1 +
 blivet/devices.py      |  2 ++
 blivet/devicetree.py   |  1 +
 blivet/udev.py         | 10 ++++++----
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
index e615536..7f4d9b6 100644
--- a/blivet/deviceaction.py
+++ b/blivet/deviceaction.py
@@ -441,6 +441,7 @@ class ActionCreateFormat(DeviceAction):
             self.device.updateSysfsPath()
             info = udev_get_block_device(self.device.sysfsPath)
             self.device.format.uuid = udev_device_get_uuid(info)
+            self.device.deviceLinks = udev_device_get_symlinks(info)
 
     def cancel(self):
         self.device.format = self.origFormat
diff --git a/blivet/devices.py b/blivet/devices.py
index 19885bf..f091378 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -494,6 +494,8 @@ class StorageDevice(Device):
 
         self._partedDevice = None
 
+        self.deviceLinks = []
+
         if self.exists and flags.testing and not self._size:
             def read_int_from_sys(path):
                 return int(open(path).readline().strip())
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index f969bab..1ea6f3b 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1026,6 +1026,7 @@ class DeviceTree(object):
         if device.format.type:
             log.info("got format: %r" % device.format)
         device.originalFormat = copy.copy(device.format)
+        device.deviceLinks = udev_device_get_symlinks(info)
 
     def handleUdevDiskLabelFormat(self, info, device):
         disklabel_type = info.get("ID_PART_TABLE_TYPE")
diff --git a/blivet/udev.py b/blivet/udev.py
index ec1dcaa..b944cb2 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -352,11 +352,13 @@ def udev_device_get_bus(udev_info):
 def udev_device_get_path(info):
     return info["ID_PATH"]
 
+def udev_device_get_symlinks(info):
+    return info.get("symlinks", [])
+
 def udev_device_get_by_path(info):
-    if info.has_key('symlinks'):
-        for link in info['symlinks']:
-            if link.startswith('/dev/disk/by-path/'):
-                return link
+    for link in udev_device_get_symlinks(info):
+        if link.startswith('/dev/disk/by-path/'):
+            return link
 
     return udev_device_get_name(info)
 
-- 
1.8.1



More information about the anaconda-patches mailing list