## Clear the drive dict cache.
@@ -388,32 +383,42 @@ def driveDict(klassArg):
import parted
global cachedDrives
if cachedDrives is None:
- # FIXME: need to add dasd probing to kudzu
- devs = kudzu.probe(kudzu.CLASS_HD | kudzu.CLASS_CDROM |
- kudzu.CLASS_FLOPPY | kudzu.CLASS_TAPE,
- kudzu.BUS_UNSPEC, kudzu.PROBE_SAFE)
+ import dbus
+
+ bus = dbus.SystemBus()
+
+ halobj = bus.get_object("org.freedesktop.Hal","/org/freedesktop/Hal/Manager")
+ hal = dbus.Interface(halobj, "org.freedesktop.Hal.Manager")
+
new = {}
- for dev in devs:
- device = dev.device
- if device is None: # none devices make no sense
- # kudzu is unable to determine the device for tape drives w/ 2.6
- if dev.deviceclass == classMap["tape"]:
- tapedevs = filter(lambda d: d.startswith("st"), new.keys())
- device = "st%d" % (len(tapedevs),)
- else:
+ for udi in halobj.FindDeviceByCapability("storage"):
+ haldev = dbus.Interface(bus.get_object("org.freedesktop.Hal ", udi), 'org.freedesktop.Hal.Device')
+ try:
+ device = haldev.GetProperty('block.device')
+ device = device.replace('/dev/',')
+ except:
+ try:
+ device = haldev.GetProperty('linux.device_file')
+ device = device.replace('/dev/',')
+ except:
continue
+ dev = {}
+ dev['device'] = device
+ dev['class'] = haldev.GetProperty('storage.drive_type')
+ dev['removable'] = haldev.GetProperty('storage.removable')
+ dev['desc'] = '%s %s' % (haldev.GetProperty('storage.vendor'), haldev.GetProperty('storage.model'))
+
# we can't actually use the sg devices, so ignore them
if device.startswith("sg"):
log.info("ignoring sg device %s" %(device,))
continue
- if dev.deviceclass != classMap["disk"]:
+ if dev['class'] != "disk":
new[device] = dev
continue
try:
devName = "/dev/%s" % (device,)
- makeDevInode(device, devName)
if not mediaPresent (device):
new[device] = dev
@@ -477,8 +482,8 @@ def driveDict(klassArg):
if isinstance(dev, block.MultiPath) or isinstance(dev, block.RaidSet):
if klassArg == "disk":
ret[key] = dev
- elif dev.deviceclass == classMap[klassArg]:
- ret[key] = dev.desc
+ elif dev['class'] == klassArg:
+ ret[key] = dev
return ret
## Get all the hard drives attached to the system.
@@ -490,18 +495,27 @@ def driveDict(klassArg):
# @see driveDict
# @return A dict of all the hard drive descriptions, keyed on device name.
def hardDriveDict():
- return driveDict("disk")
+ ret = {}
+ dict = driveDict("disk")
+ for item in dict.keys():
+ ret[item] = dict[item]['desc']
+ return ret
-## Get all the floppy drives attached to the system.
-# This method queries the drive dict cache for all floppy drives. If the cache
+## Get all the removable drives attached to the system.
+# This method queries the drive dict cache for all removable drives. If the cache
# is empty, this will cause all disk devices to be probed. If the status of
# the devices has changed, flushDriveDict must be run called first.
#
# @see flushDriveDict
# @see driveDict
-# @return A dict of all the floppy drive descriptions, keyed on device name.
-def floppyDriveDict():
- return driveDict("floppy")
+# @return A dict of all the removable drive descriptions, keyed on device name.
+def removableDriveDict():
+ ret = {}
+ dict = driveDict("disk")
+ for item in dict.keys():
+ if dict[item]['removable'] != 0:
+ ret[item] = dict[item]['desc']
+ return ret
## Get all CD/DVD drives attached to the system.
# This method queries the drive dict cache for all hard drives. If the cache
--
1.5.3.4
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list