[PATCH] Use minihal instead of isys.hardDriveDict in list-harddrives (#488122).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



list-harddrives was completely broken in the new storage world.  Incidentally,
this patch also fixes the referenced bug by removing all the unnecessary
imports that were dragging in zonetab.
---
 command-stubs/list-harddrives-stub |   42 ++++++++---------------------------
 1 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/command-stubs/list-harddrives-stub b/command-stubs/list-harddrives-stub
index a282984..ceb6036 100755
--- a/command-stubs/list-harddrives-stub
+++ b/command-stubs/list-harddrives-stub
@@ -2,7 +2,7 @@
 #
 # scan system for harddrives and output device name/size
 #
-# Copyright (C) 2007  Red Hat, Inc.  All rights reserved.
+# Copyright (C) 2007, 2009  Red Hat, Inc.  All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,42 +18,20 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import os
 import sys
 
-# for testing
-if (os.path.exists('isys')):
-    sys.path.append('isys')
-
 sys.path.append('/usr/lib/anaconda')
 
-import anaconda_log
-import parted
-import partedUtils
-import isys
-
-drives = isys.hardDriveDict()
-
-driveList = drives.keys()
-driveList.sort()
-
-for drive in driveList:
-    if not isys.mediaPresent(drive):
-	continue
-
-    # try to open and get size
-    skip = 0
-    deviceFile =  "/dev/%s" % (drive,)
+import minihal
 
-    try:
-	dev = parted.PedDevice.get(deviceFile)
-    except:
-	skip = 1
+lst = []
 
-    if skip:
-	continue
+for drive in minihal.get_devices_by_type("volume"):
+    if not drive.has_key("device") or not drive.has_key("volume.size"):
+        continue
 
-    sizeMB = (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024)
-		            * dev.sectorSize)
+    lst.append("%s %s" % (drive["device"], drive["volume_size"]/(1024*1024)))
 
-    print drive, sizeMB
+lst.sort()
+for entry in lst:
+    print lst
-- 
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux