Otherwise it is sometimes impossible to deduce for devices that had been down (for instance a raid we do *not* use for installation). cherry-pick of 106f7d44099f2a11c156ed30d08f14d860c5d4be Related: rhbz#731973 --- storage/devices.py | 1 + storage/formats/__init__.py | 37 +++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/storage/devices.py b/storage/devices.py index 5a64e70..637980e 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -646,6 +646,7 @@ class StorageDevice(Device): if self.status: if self.originalFormat.exists: self.originalFormat.teardown() + self.format.cacheMajorminor() if self.format.exists: self.format.teardown() udev_settle() diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py index f4eee3a..6307dcd 100644 --- a/storage/formats/__init__.py +++ b/storage/formats/__init__.py @@ -171,6 +171,7 @@ class DeviceFormat(object): self.uuid = kwargs.get("uuid") self.exists = kwargs.get("exists") self.options = kwargs.get("options") + self._majorminor = None self._migrate = False # don't worry about existence if this is a DeviceFormat instance @@ -255,6 +256,16 @@ class DeviceFormat(object): except Exception, e: log.warning("failed to notify kernel of change: %s" % e) + def cacheMajorminor(self): + """ Cache the value of self.majorminor. + + Once a device node of this format's device disappears (for instance + after a teardown), it is no longer possible to figure out the value + of self.majorminor pseudo-unique string. Call this method before + that happens for caching this. + """ + self._majorminor = None + return self.majorminor # this does the caching def create(self, *args, **kwargs): log_method_call(self, device=self.device, @@ -405,22 +416,20 @@ class DeviceFormat(object): @property def majorminor(self): """A string suitable for using as a pseudo-unique ID in kickstart.""" - - # If this is a device-mapper device, we have to get the DM node and - # build the sysfs path from that. - try: - device = dm_node_from_name(self.device) - except DMError: - device = self.device - - sysfs_path = get_sysfs_path_by_name(device) - dev = udev_get_device(sysfs_path[4:]) - return "%03d%03d" % (udev_device_get_major(dev), udev_device_get_minor(dev)) + if not self._majorminor: + # If this is a device-mapper device, we have to get the DM node and + # build the sysfs path from that. + try: + device = dm_node_from_name(self.device) + except DMError: + device = self.device + sysfs_path = get_sysfs_path_by_name(device) + dev = udev_get_device(sysfs_path[4:]) + self._majorminor = "%03d%03d" %\ + (udev_device_get_major(dev), udev_device_get_minor(dev)) + return self._majorminor def writeKS(self, f): return - collect_device_format_classes() - - -- 1.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list