pyblock is one of the last users of nash / mkinitrd functionality in the form of libbdevid-python. There are remainig 2 uses of it: 1) __init__.py: getMPaths(), which anaconda no longer uses (and anaconda is the only pyblock user) -> remove it 2) devices.py BlockDev.get_scsi_id() / BlockDev.id, nothing uses this, which is also proven by the lack of an "import bdevid" in device.py, meaning that BlockDev.get_scsi_id() does not even work -> remove it Removing these 2 uses means that we are one step closer to completely retiring mkinitrd (and nash, etc). --- __init__.py | 106 --------------------------------------------------- device.py | 15 ------- python-pyblock.spec | 5 +-- 3 files changed, 1 insertions(+), 125 deletions(-) diff --git a/__init__.py b/__init__.py index c8f2d3f..a3ea35b 100644 --- a/__init__.py +++ b/__init__.py @@ -23,8 +23,6 @@ from maps import * from device import MultiPath, RaidDev, RaidSet, BlockDev, DeviceMaps, \ removeDeviceMap -_probesLoaded = False - _log_ignore = False _verbose = dm.log_warn @@ -47,19 +45,6 @@ dm.set_logger(dm_log) del dm_log import dmraid -from bdevid import bdevid as _bdevid -_bd = _bdevid() - -def setBdevidPath(path): - _bd.path = path - -def getBdevidPath(): - return _bd.path - -def load(name): - _bd.load(name) - global _probesLoaded - _probesLoaded = True def getDevice(name): """Retrieve a major and minor number for a specific path/name. @@ -72,97 +57,6 @@ def getDevice(name): if name == map.name: return (map.dev.major, map.dev.minor) -def getMPaths(disks, logger=None): - """Retrieve all the Multi path devices in the system. - - Returns a list of Multi path objects. - """ - old = disks - disks = [] - for disk in old: - if isinstance(disk, [].__class__) or isinstance(disk,().__class__): - disks += list(disk) - else: - disks.append(disk) - - global _probesLoaded - if not _probesLoaded: - _bd.loadAll() - _probesLoaded = True - prefix = "/dev/mapper/" - - newdisks = [] - import os as _os - for x in range(len(disks)): - if not disks[x].startswith('/'): - devdisk = '/dev/' + disks[x] - tmpdisk = '/tmp/' + disks[x] - - if _os.access(devdisk, _os.F_OK): - disks[x] = devdisk - elif _os.access(tmpdisk, _os.F_OK): - disks[x] = tmpdisk - del _os - disks = disks + newdisks - - uuids = {} - for disk in disks: - try: - results = _bd.probe(disk) - except: - continue - - for result in results: - key = [result['vendor'], result['model'], result['unique_id']] - if logger: - logger("key for disk %s is [%s,%s,%s]" % (disk, \ - result['vendor'], result['model'], result['unique_id'])) - if None in key: - continue; - uuids.setdefault(tuple(key), []) - uuids[tuple(key)].append(disk) - - def uuidSort(uuidDict): - def uuidCmp(left, right): - for x in range(2,-1,-1): - ret = cmp(left[0][x], right[0][x]) - if ret != 0: - return ret - return 0 - - uuidItems = uuidDict.items() - uuidItems.sort(uuidCmp) - retList = [] - for k,v in uuidItems: - if len(v) > 1: - try: - retList.append(apply(MultiPath, v, {})) - except SystemError, x: - if not x[0] in [2,]: - raise - return retList - - mpList = uuidSort(uuids) - names = reduce(lambda x,y: x + [y.name,], mpList, []) - names.sort() - def swap_names(left_name, right_name): - left = None - right = None - for x in xrange(len(mpList)): - if mpList[x].name == left_name: - left = mpList[x] - elif mpList[x].name == right_name: - right = mpList[x] - left.set_name(left_name + ".tmp") - right.set_name(left_name) - left.set_name(right_name) - - for x in xrange(len(names)): - if mpList[x].name != names[x]: - swap_names(mpList[x].name, names[x]) - - return mpList - def getRaidSets(*disks): """Retrieve all the raid sets in the system. diff --git a/device.py b/device.py index 92a7aeb..0ad8aa5 100644 --- a/device.py +++ b/device.py @@ -145,23 +145,8 @@ class BlockDev: self._BlockDev__device.mode = int(mode) mode = property(get_mode, set_mode, None, "mode for device node") - def get_scsi_id(self): - if self._BlockDev__scsi_id: - return self._BlockDev__scsi_id - - if not self.path: - raise RuntimeError, "path not set" - - try: - self._BlockDev__scsi_id = bdevid.scsi_id(self.path) - except ValueError: - self._BlockDev__scsi_id = None - return self._BlockDev__scsi_id - id = property(get_scsi_id, None, None, "unique id for device") - def __init__(self, path=None, major=None, minor=None, dev=None): self._BlockDev__context = None - self._BlockDev__scsi_id = None self._BlockDev__path = None if not path is None: diff --git a/python-pyblock.spec b/python-pyblock.spec index e9d2666..d5c0a61 100644 --- a/python-pyblock.spec +++ b/python-pyblock.spec @@ -14,10 +14,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRequires: python-devel, gettext BuildRequires: device-mapper-libs >= %{dmver}, device-mapper-devel >= %{dmver} BuildRequires: dmraid-devel >= %{dmrver}, libselinux-devel, libsepol-devel -BuildRequires: zlib-devel, libbdevid >= 5.1.0 -Requires: python, device-mapper-libs >= %{dmver}, libselinux -Requires: libbdevid, libbdevid-python -Requires: pyparted +Requires: device-mapper-libs >= %{dmver}, pyparted %description The pyblock contains Python modules for dealing with block devices. -- 1.6.5.2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list