Fix looking up storage device IDs when writing out anaconda-ks.cfg (#591713).
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)
+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))
# 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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
12-15-2010, 09:12 PM
David Lehman
Fix looking up storage device IDs when writing out anaconda-ks.cfg (#591713).
On Wed, 2010-12-15 at 16:51 -0500, Chris Lumens wrote:
> 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.
Maybe we don't worry about looking up the new formats' UUIDs for the
device types that are represented by path in /etc/fstab (as opposed to
those that are referenced by UUID).
Ack.
> ---
> 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,
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list