[PATCH] Fix looking up storage device IDs when writing out anaconda-ks.cfg (#591713).

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

 



Before, we were just writing out the UUID on the format objects.  However, the
object may not have a UUID when it's instantiated and we never go back and set
the attribute once we make filesystems.  So, we need to go and do a lookup at
the end when writeKS is done.  Using the major and minor device numbers is
unique enough for this purpose.
---
 pyanaconda/storage/devices.py          |    4 ++--
 pyanaconda/storage/formats/__init__.py |    9 +++++++++
 pyanaconda/storage/formats/lvmpv.py    |    2 +-
 pyanaconda/storage/formats/mdraid.py   |    2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index c101a66..a599937 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -1964,7 +1964,7 @@ class LVMVolumeGroupDevice(DMDevice):
         pvs = []
 
         for pv in self.pvs:
-            pvs.append("pv.%s" % pv.format.uuid)
+            pvs.append("pv.%s" % pv.format.majorminor)
 
         if preexisting:
             args.append("--useexisting")
@@ -2753,7 +2753,7 @@ class MDRaidArrayDevice(StorageDevice):
             args.append("--noformat")
 
         for mem in self.parents:
-            mems.append("raid.%s" % mem.format.uuid)
+            mems.append("raid.%s" % mem.format.majorminor)
 
         f.write("#raid ")
         self.format.writeKS(f)
diff --git a/pyanaconda/storage/formats/__init__.py b/pyanaconda/storage/formats/__init__.py
index 5edada4..f5377c6 100644
--- a/pyanaconda/storage/formats/__init__.py
+++ b/pyanaconda/storage/formats/__init__.py
@@ -22,12 +22,14 @@
 
 import os
 
+from pyanaconda.baseudev import udev_get_device
 from pyanaconda.iutil import notify_kernel
 from pyanaconda.iutil import get_sysfs_path_by_name
 from pyanaconda.iutil import execWithRedirect
 from ..storage_log import log_method_call
 from ..errors import *
 from ..devicelibs.dm import dm_node_from_name
+from ..udev import udev_device_get_major, udev_device_get_minor
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -391,6 +393,13 @@ class DeviceFormat(object):
         """ Whether devices with this formatting should be hidden in UIs. """
         return self._hidden
 
+    @property
+    def majorminor(self):
+        """A string suitable for using as a pseudo-unique ID in kickstart."""
+        sysfs_path = get_sysfs_path_by_name(self.device)
+        dev = udev_get_device(sysfs_path[4:])
+        return "%03d%03d" % (udev_device_get_major(dev), udev_device_get_minor(dev))
+
     def writeKS(self, f):
         return
 
diff --git a/pyanaconda/storage/formats/lvmpv.py b/pyanaconda/storage/formats/lvmpv.py
index 4b1adc4..6a9f492 100644
--- a/pyanaconda/storage/formats/lvmpv.py
+++ b/pyanaconda/storage/formats/lvmpv.py
@@ -150,7 +150,7 @@ class LVMPhysicalVolume(DeviceFormat):
                 os.path.isdir("/dev/mapper/%s" % self.vgName))
 
     def writeKS(self, f):
-        f.write("pv.%s" % self.uuid)
+        f.write("pv.%s" % self.majorminor)
 
 register_device_format(LVMPhysicalVolume)
 
diff --git a/pyanaconda/storage/formats/mdraid.py b/pyanaconda/storage/formats/mdraid.py
index c08c9cc..339f7aa 100644
--- a/pyanaconda/storage/formats/mdraid.py
+++ b/pyanaconda/storage/formats/mdraid.py
@@ -111,7 +111,7 @@ class MDRaidMember(DeviceFormat):
         return (self._hidden or self.biosraid)
 
     def writeKS(self, f):
-        f.write("raid.%s" % self.mdUuid)
+        f.write("raid.%s" % self.majorminor)
 
 # nodmraid -> Wether to use BIOS RAID or not
 # Note the anaconda cmdline has not been parsed yet when we're first imported,
-- 
1.7.1.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