FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Development

 
 
LinkBack Thread Tools
 
Old 01-14-2012, 07:06 PM
David Lehman
 
Default Smooth out calculation of free space for fake and real disks.

---
pyanaconda/ui/gui/spokes/storage.py | 48 +++++++++++------------------------
1 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 41e40f6..960a3c1 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -50,8 +50,6 @@ from pyanaconda.storage.size import Size
# these are all temporary
from pyanaconda.storage.partitioning import getFreeRegions
from pyanaconda.storage.partitioning import sectorsToSize
-from pyanaconda.storage.devices import DiskDevice
-from pyanaconda.storage.formats import getFormat

from pyanaconda.product import productName

@@ -63,12 +61,16 @@ P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)

__all__ = ["StorageSpoke"]

+class FakeDiskLabel(object):
+ def __init__(self, free=0):
+ self.free = free
+
class FakeDisk(object):
def __init__(self, name, size=0, free=0, partitioned=True, vendor=None,
model=None, serial=None, removable=False):
self.name = name
self.size = size
- self.free = free
+ self.format = FakeDiskLabel(free=free)
self.partitioned = partitioned
self.vendor = vendor
self.model = model
@@ -95,40 +97,20 @@ def getDisks(devicetree, fake=False):

return disks

-# XXX move these into storage
-def fsFreeSpace(device):
- free = 0
- if device.format.exists:
- current_size = getattr(device.format, "currentSize", None)
- min_size = getattr(device.format, "minSize", None)
- if current_size and min_size and current_size != min_size:
- free = int(current_size - min_size) # truncate
-
- return free
-
-def diskFreeSpace(disk):
- free = 0
- if disk.partitioned:
- parted_disk = disk.format.partedDisk
- sector_size = disk.partedDevice.sectorSize
-
- free_geoms = getFreeRegions([parted_disk])
- free_sizes = [sectorsToSize(f.length, sector_size) for f in free_geoms]
- free = sum(free_sizes)
-
- return free
-
def get_free_space_info(disks, devicetree):
disk_free = 0
fs_free = 0
for disk in disks:
- if hasattr(disk, "free"):
- disk_free += disk.free
+ if not disk.partitioned:
continue

- disk_free += diskFreeSpace(disk)
+ disk_free += disk.format.free
+
for partition in devicetree.getChildren(disk):
- fs_free += fsFreeSpace(partition)
+ # only check actual filesystems since lvm &c require a bunch of
+ # operations to translate free filesystem space into free disk space
+ if hasattr(partition.format, "free"):
+ fs_free += partition.format.free

print("disks %s have %d free, plus %s in filesystems"
% ([d.name for d in disks], disk_free, fs_free))
@@ -147,7 +129,7 @@ class SelectedDisksDialog(UIObject):

self._store.append(["%s-%s" % (disk.vendor, disk.model),
Size(spec="%s mb" % disk.size).humanReadable().upper(),
- Size(spec="%s mb" % disk.free).humanReadable().upper(),
+ Size(spec="%s mb" % disk.format.free).humanReadable().upper(),
str(disks.index(disk))])
self.disks = disks[:]
self._update_summary()
@@ -396,7 +378,7 @@ class StorageSpoke(NormalSpoke):
#specialized_disks_box = self.builder.get_object("specialized_disks_box")

print self.data.ignoredisk.onlyuse
- self.disks = getDisks(self.devicetree, fake=True)
+ self.disks = getDisks(self.devicetree)#, fake=True)

# properties: kind, description, capacity, os, popup-info
for disk in self.disks:
@@ -445,7 +427,7 @@ class StorageSpoke(NormalSpoke):
break

capacity += disk.size
- free += disk.free
+ free += disk.format.free
count += 1

summary = (P_(("%d disk selected; %s capacity; %s free ..."),
--
1.7.6

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

Thread Tools




All times are GMT. The time now is 02:47 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org