[PATCH 06/14] Add a method to return a device's WWID.

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

 



---
 storage/udev.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/storage/udev.py b/storage/udev.py
index 4ea9a94..ee750bb 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -254,6 +254,20 @@ def udev_device_get_serial(udev_info):
     """ Get the serial number/UUID from the device as reported by udev. """
     return udev_info.get("ID_SERIAL_SHORT")
 
+def udev_device_get_wwid(udev_info):
+    """ The WWID of a device is typically just its serial number, but with
+        colons in the name to make it more readable. """
+    serial = udev_device_get_serial(udev_info)
+
+    if len(serial) == 32:
+        retval = ""
+        for i in range(0, 16):
+            retval += serial[i*2:i*2+2] + ":"
+
+        return retval[0:-1]
+
+    return ""
+
 def udev_device_get_vendor(udev_info):
     """ Get the vendor of the device as reported by udev. """
     return udev_info.get("ID_VENDOR_FROM_DATABASE", udev_info.get("ID_VENDOR"))
-- 
1.6.5.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