diff options
author | Peter Jones <pjones@redhat.com> | 2010-02-05 11:59:29 -0500 |
---|---|---|
committer | Peter Jones <pjones@redhat.com> | 2010-02-26 12:58:35 -0500 |
commit | a24e722ebcb06c88f88605190caebdcf83236690 (patch) | |
tree | 29cb956c62227f9b813d7ccf72d2c957d3df92b1 /storage | |
parent | 8a4fdd59c1d0d613cb32778b7142da8ec0adbab1 (diff) | |
download | anaconda-a24e722ebcb06c88f88605190caebdcf83236690.tar.gz anaconda-a24e722ebcb06c88f88605190caebdcf83236690.tar.xz anaconda-a24e722ebcb06c88f88605190caebdcf83236690.zip |
working on this
Diffstat (limited to 'storage')
-rw-r--r-- | storage/devicelibs/mpath.py | 2 | ||||
-rw-r--r-- | storage/devices.py | 65 | ||||
-rw-r--r-- | storage/devicetree.py | 15 | ||||
-rw-r--r-- | storage/udev.py | 8 |
4 files changed, 70 insertions, 20 deletions
diff --git a/storage/devicelibs/mpath.py b/storage/devicelibs/mpath.py index 75911c9a1..1e2c2c821 100644 --- a/storage/devicelibs/mpath.py +++ b/storage/devicelibs/mpath.py @@ -137,7 +137,7 @@ def identifyMultipaths(devices): non_disk_serials[serial].append(device) for mpath in multipaths: - for serial in [d.get('ID_SERIAL_SHORT') for d in mpath]: + for serial in [d.get('ID_SERIAL') for d in mpath]: if non_disk_serials.has_key(serial): log.info("filtering out non disk devices [%s]" % [d['name'] for d in non_disk_serials[serial]]) for name in [d['name'] for d in non_disk_serials[serial]]: diff --git a/storage/devices.py b/storage/devices.py index 898273040..6f2e55c56 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -430,7 +430,8 @@ class StorageDevice(Device): def __init__(self, device, format=None, size=None, major=None, minor=None, - sysfsPath='', parents=None, exists=None, serial=None, + sysfsPath='', parents=None, exists=None, + serial=None, serial_short=None, vendor="", model="", bus=""): """ Create a StorageDevice instance. @@ -446,7 +447,8 @@ class StorageDevice(Device): sysfsPath -- sysfs device path format -- a DeviceFormat instance parents -- a list of required Device instances - serial -- the ID_SERIAL_SHORT for this device + serial -- the ID_SERIAL for this device + serial_short -- the ID_SERIAL_SHORT for this device vendor -- the manufacturer of this Device model -- manufacturer's device model string bus -- the interconnect this device uses @@ -466,6 +468,7 @@ class StorageDevice(Device): self.minor = numeric_type(minor) self.sysfsPath = sysfsPath self._serial = serial + self._serial_short = serial_short self._vendor = vendor self._model = model self.bus = bus @@ -754,8 +757,15 @@ class StorageDevice(Device): return self._serial @property + def serial_short(self): + return self._serial_short + + @property def serial_for_display(self): - return self.serial + try: + return self.serial_short + except NotImplementedError: + return self.serial @property def model(self): @@ -775,7 +785,8 @@ class DiskDevice(StorageDevice): def __init__(self, device, format=None, size=None, major=None, minor=None, sysfsPath='', - parents=None, serial=None, vendor="", model="", bus="", + parents=None, serial=None, serial_short=None, + vendor="", model="", bus="", exists=True): """ Create a DiskDevice instance. @@ -792,7 +803,8 @@ class DiskDevice(StorageDevice): format -- a DeviceFormat instance parents -- a list of required Device instances removable -- whether or not this is a removable device - serial -- the ID_SERIAL_SHORT for this device + serial -- the ID_SERIAL for this device + serial_short -- the ID_SERIAL_SHORT for this device vendor -- the manufacturer of this Device model -- manufacturer's device model string bus -- the interconnect this device uses @@ -803,8 +815,8 @@ class DiskDevice(StorageDevice): StorageDevice.__init__(self, device, format=format, size=size, major=major, minor=minor, exists=exists, sysfsPath=sysfsPath, parents=parents, - serial=serial, model=model, - vendor=vendor, bus=bus) + serial=serial, serial_short=serial_short, + model=model, vendor=vendor, bus=bus) def __str__(self): s = StorageDevice.__str__(self) @@ -1503,6 +1515,18 @@ class DMDevice(StorageDevice): return getattr(self, "_serial", "") @property + def serial_short(self): + if self._serial_short: + return self._serial_short + try: + serial_short = getattr(self, "_getSerialShort")() + except: + raise NotImplementedError("serial_short method not defined for Device") + + self._serial_short = serial_short + return getattr(self, "_serial_short", "") + + @property def fstabSpec(self): """ Return the device specifier for use in /etc/fstab. """ return self.path @@ -1581,7 +1605,7 @@ class DMCryptDevice(DMDevice): """ DMDevice.__init__(self, name, format=format, size=size, parents=parents, sysfsPath=sysfsPath, - exists=exists, target="crypt") + exists=exists, target="crypt", dmUuid=uuid) class LUKSDevice(DMCryptDevice): """ A mapped LUKS device. """ @@ -2999,8 +3023,9 @@ class MultipathDevice(DMDevice): _packages = ["device-mapper-multipath"] _partitionable = True _isDisk = True + _resizable = False - def __init__(self, name, info, format=None, size=None, + def __init__(self, name, info, format=None, parents=None, sysfsPath=''): """ Create a MultipathDevice instance. @@ -3017,8 +3042,12 @@ class MultipathDevice(DMDevice): parents -- a list of the backing devices (Device instances) """ - self._info = info dmUuid="mpath-%s" % info['ID_SERIAL'] + size=None + for parent in parents: + if parent.size: + size = parent.size + break DMDevice.__init__(self, name, format=format, size=size, parents=parents, sysfsPath=sysfsPath, exists=True, dmUuid=dmUuid) @@ -3031,6 +3060,10 @@ class MultipathDevice(DMDevice): 'gid' : '0', } + @property + def size(self): + return self._size + def _getWwidFromSerial(self, serial): wwid = [] while serial: @@ -3039,8 +3072,8 @@ class MultipathDevice(DMDevice): wwid = ":".join(wwid) return wwid - def _getSerial(self): - serial = DMDevice._getSerial(self) + def _getSerialShort(self): + serial = self._getSerial() if not serial: return None @@ -3052,11 +3085,11 @@ class MultipathDevice(DMDevice): @property def wwid(self): - if not self._serial: - self._serial = self._getSerial() - if not self._serial: + if not self._serial_short: + self._serial_short = self._getSerialShort() + if not self._serial_short: return "" - return self._getWwidFromSerial(self._serial) + return self._getWwidFromSerial(self._serial_short) @property def serial_for_display(self): diff --git a/storage/devicetree.py b/storage/devicetree.py index 386d23f82..586fc3383 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1117,16 +1117,26 @@ class DeviceTree(object): uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) serial = udev_device_get_serial(info) + serial_short = udev_device_get_serial_short(info) bus = udev_device_get_bus(info) # udev doesn't always provide a vendor. vendor = udev_device_get_vendor(info) if not vendor: vendor = "" + model = udev_device_get_model(info) + if not model: + model = "" device = None - kwargs = { "serial": serial, "vendor": vendor, "bus": bus } + kwargs = { + "serial": serial, + "serial_short": serial_short, + "vendor": vendor, + "model": model, + "bus": bus + } if udev_device_is_iscsi(info): diskType = iScsiDiskDevice kwargs["node"] = self.iscsi.getNode( @@ -1216,6 +1226,7 @@ class DeviceTree(object): minor=udev_device_get_minor(info), sysfsPath=sysfs_path, exists=True, serial=udev_device_get_serial(info), + serial_short=udev_device_get_serial_short(info), vendor=udev_device_get_vendor(info), model=udev_device_get_model(info)) self._addDevice(device) @@ -1681,6 +1692,7 @@ class DeviceTree(object): label = udev_device_get_label(info) format_type = udev_device_get_format(info) serial = udev_device_get_serial(info) + serial_short = udev_device_get_serial_short(info) # Now, if the device is a disk, see if there is a usable disklabel. # If not, see if the user would like to create one. @@ -1710,6 +1722,7 @@ class DeviceTree(object): "label": label, "device": device.path, "serial": serial, + "serial_short": serial_short, "exists": True} # set up type-specific arguments for the format constructor diff --git a/storage/udev.py b/storage/udev.py index 02a54e737..d7c5c930f 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -241,14 +241,18 @@ def udev_device_is_partition(info): has_start = os.path.exists("/sys/%s/start" % info['sysfs_path']) return info.get("DEVTYPE") == "partition" or has_start -def udev_device_get_serial(udev_info): +def udev_device_get_serial_short(udev_info): """ Get the serial number/UUID from the device as reported by udev. """ return udev_info.get("ID_SERIAL_SHORT", udev_info.get("ID_SERIAL")) +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") + 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) + serial = udev_device_get_serial_short(udev_info) if serial and len(serial) == 32: retval = "" |