[blivet:master 20/20] Use tuples to construct Sizes() wherever units are known.
mulhern
amulhern at redhat.com
Tue Dec 23 23:42:33 UTC 2014
---
blivet/devicefactory.py | 6 +++---
blivet/devicelibs/btrfs.py | 4 ++--
blivet/devicelibs/crypto.py | 4 ++--
blivet/devicelibs/lvm.py | 18 +++++++++---------
blivet/devicelibs/mdraid.py | 10 +++++-----
blivet/devicelibs/swap.py | 10 +++++-----
blivet/devices/partition.py | 4 ++--
blivet/formats/biosboot.py | 6 +++---
blivet/formats/fs.py | 44 ++++++++++++++++++++++----------------------
blivet/formats/prepboot.py | 6 +++---
blivet/formats/swap.py | 4 ++--
blivet/partitioning.py | 6 +++---
blivet/platform.py | 22 +++++++++++-----------
blivet/udev.py | 12 ++++++------
blivet/util.py | 6 +++---
15 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
index c383b4d..3fc5c6b 100644
--- a/blivet/devicefactory.py
+++ b/blivet/devicefactory.py
@@ -31,7 +31,7 @@ from .devicelibs import raid
from .partitioning import SameSizeSet
from .partitioning import TotalSizeSet
from .partitioning import doPartitioning
-from .size import Size
+from .size import Size, MiB
import logging
log = logging.getLogger("blivet")
@@ -844,7 +844,7 @@ class PartitionFactory(DeviceFactory):
if self.encrypted:
min_format_size += getFormat("luks").minSize
- return max(Size("1MiB"), min_format_size)
+ return max(Size((1, MiB)), min_format_size)
def _get_device_size(self):
""" Return the factory device size including container limitations. """
@@ -982,7 +982,7 @@ class PartitionSetFactory(PartitionFactory):
add_disks = self.disks
# drop any new disks that don't have free space
- min_free = min(Size("500MiB"), self.parent_factory.size)
+ min_free = min(Size((500, MiB)), self.parent_factory.size)
add_disks = [d for d in add_disks if d.partitioned and
d.format.free >= min_free]
diff --git a/blivet/devicelibs/btrfs.py b/blivet/devicelibs/btrfs.py
index a0a4ec8..21fb75d 100644
--- a/blivet/devicelibs/btrfs.py
+++ b/blivet/devicelibs/btrfs.py
@@ -26,7 +26,7 @@ import re
from . import raid
from .. import util
from ..errors import BTRFSError, BTRFSValueError
-from ..size import Size
+from ..size import Size, MiB
import logging
log = logging.getLogger("blivet")
@@ -35,7 +35,7 @@ log = logging.getLogger("blivet")
MAIN_VOLUME_ID = 5
# if any component device is less than this size, mkfs.btrfs will fail
-MIN_MEMBER_SIZE = Size("16 MiB")
+MIN_MEMBER_SIZE = Size((16, MiB))
RAID_levels = raid.RAIDLevels(["raid0", "raid1", "raid10", "single"])
diff --git a/blivet/devicelibs/crypto.py b/blivet/devicelibs/crypto.py
index 13a6282..a3588c8 100644
--- a/blivet/devicelibs/crypto.py
+++ b/blivet/devicelibs/crypto.py
@@ -25,10 +25,10 @@ import time
from pycryptsetup import CryptSetup
from ..errors import CryptoError
-from ..size import Size
+from ..size import Size, MiB
from ..util import get_current_entropy
-LUKS_METADATA_SIZE = Size("2 MiB")
+LUKS_METADATA_SIZE = Size((2, MiB))
MIN_CREATE_ENTROPY = 256 # bits
# Keep the character set size a power of two to make sure all characters are
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index ce576e2..91edee7 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -27,7 +27,7 @@ import logging
log = logging.getLogger("blivet")
from . import raid
-from ..size import Size, KiB, MiB
+from ..size import Size, EiB, GiB, KiB, MiB, TiB
from .. import util
from .. import arch
from ..errors import LVMError
@@ -37,14 +37,14 @@ from ..flags import flags
MAX_LV_SLOTS = 256
# some of lvm's defaults that we have no way to ask it for
-LVM_PE_START = Size("1 MiB")
-LVM_PE_SIZE = Size("4 MiB")
+LVM_PE_START = Size((1, MiB))
+LVM_PE_SIZE = Size((4, MiB))
# thinp constants
-LVM_THINP_MIN_METADATA_SIZE = Size("2 MiB")
-LVM_THINP_MAX_METADATA_SIZE = Size("16 GiB")
-LVM_THINP_MIN_CHUNK_SIZE = Size("64 KiB")
-LVM_THINP_MAX_CHUNK_SIZE = Size("1 GiB")
+LVM_THINP_MIN_METADATA_SIZE = Size((2, MiB))
+LVM_THINP_MAX_METADATA_SIZE = Size((16, GiB))
+LVM_THINP_MIN_CHUNK_SIZE = Size((64, KiB))
+LVM_THINP_MAX_CHUNK_SIZE = Size((1, GiB))
RAID_levels = raid.RAIDLevels(["raid0", "raid1", "linear"])
@@ -134,9 +134,9 @@ def getPossiblePhysicalExtents():
def getMaxLVSize():
""" Return the maximum size of a logical volume. """
if arch.getArch() in ("x86_64", "ppc64", "ppc64le", "alpha", "ia64", "s390"): #64bit architectures
- return Size("8 EiB")
+ return Size((8, EiB))
else:
- return Size("16 TiB")
+ return Size((16, TiB))
def clampSize(size, pesize, roundup=None):
delta = size % pesize
diff --git a/blivet/devicelibs/mdraid.py b/blivet/devicelibs/mdraid.py
index 5479a03..d159dde 100644
--- a/blivet/devicelibs/mdraid.py
+++ b/blivet/devicelibs/mdraid.py
@@ -26,15 +26,15 @@ import string
from .. import util
from ..errors import MDRaidError
-from ..size import Size
+from ..size import Size, KiB, MiB
from . import raid
import logging
log = logging.getLogger("blivet")
# these defaults were determined empirically
-MD_SUPERBLOCK_SIZE = Size("2 MiB")
-MD_CHUNK_SIZE = Size("512 KiB")
+MD_SUPERBLOCK_SIZE = Size((2, MiB))
+MD_CHUNK_SIZE = Size((512, KiB))
class MDRaidLevels(raid.RAIDLevels):
@classmethod
@@ -70,8 +70,8 @@ def get_raid_superblock_size(size, version=None):
# MDADM: operations, but limit this to 128Meg (0.1% of 10Gig)
# MDADM: which is plenty for efficient reshapes
# NOTE: In the mdadm code this is in 512b sectors. Converted to use MiB
- MIN_HEADROOM = Size("1 MiB")
- headroom = int(Size("128 MiB"))
+ MIN_HEADROOM = Size((1, MiB))
+ headroom = int(Size((128, MiB)))
while Size(headroom << 10) > size and Size(headroom) > MIN_HEADROOM:
headroom >>= 1
diff --git a/blivet/devicelibs/swap.py b/blivet/devicelibs/swap.py
index 28c8d2a..e6d6a6b 100644
--- a/blivet/devicelibs/swap.py
+++ b/blivet/devicelibs/swap.py
@@ -27,7 +27,7 @@ from decimal import Decimal
from ..errors import DMError, OldSwapError, SuspendError, SwapError, UnknownSwapError
from .. import util
from . import dm
-from ..size import Size
+from ..size import Size, GiB
import logging
log = logging.getLogger("blivet")
@@ -137,20 +137,20 @@ def swapSuggestion(quiet=False, hibernation=False, disk_space=None):
if not quiet:
log.info("Detected %s of memory", mem)
- sixtyfour_GiB = Size("64 GiB")
+ sixtyfour_GiB = Size((64, GiB))
#chart suggested in the discussion with other teams
- if mem < Size("2 GiB"):
+ if mem < Size((2, GiB)):
swap = 2 * mem
- elif mem < Size("8 GiB"):
+ elif mem < Size((8, GiB)):
swap = mem
elif mem < sixtyfour_GiB:
swap = mem / 2
else:
- swap = Size("4 GiB")
+ swap = Size((4, GiB))
if hibernation:
if mem <= sixtyfour_GiB:
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
index be42de5..699210d 100644
--- a/blivet/devices/partition.py
+++ b/blivet/devices/partition.py
@@ -54,7 +54,7 @@ class PartitionDevice(StorageDevice):
"""
_type = "partition"
_resizable = True
- defaultSize = Size("500MiB")
+ defaultSize = Size((500, MiB))
def __init__(self, name, fmt=None,
size=None, grow=False, maxsize=None, start=None, end=None,
@@ -537,7 +537,7 @@ class PartitionDevice(StorageDevice):
device = self.partedPartition.geometry.device.path
# Erase 1MiB or to end of partition
- count = min(int(Size("1 MiB") // bs), part_len)
+ count = min(int(Size((1, MiB)) // bs), part_len)
cmd = ["dd", "if=/dev/zero", "of=%s" % device, "bs=%s" % bs,
"seek=%s" % start, "count=%s" % count]
diff --git a/blivet/formats/biosboot.py b/blivet/formats/biosboot.py
index 0c6c251..c635bec 100644
--- a/blivet/formats/biosboot.py
+++ b/blivet/formats/biosboot.py
@@ -22,7 +22,7 @@
from parted import PARTITION_BIOS_GRUB
-from ..size import Size
+from ..size import Size, KiB, MiB
from .. import platform
from ..i18n import N_
from . import DeviceFormat, register_device_format
@@ -34,8 +34,8 @@ class BIOSBoot(DeviceFormat):
partedFlag = PARTITION_BIOS_GRUB
_formattable = True # can be formatted
_linuxNative = True # for clearpart
- _maxSize = Size("2 MiB")
- _minSize = Size("512 KiB")
+ _maxSize = Size((2, MiB))
+ _minSize = Size((512, KiB))
def __init__(self, **kwargs):
"""
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 908364f..5a8a4a6 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -35,7 +35,7 @@ from ..flags import flags
from parted import fileSystemType
from ..storage_log import log_exception_info, log_method_call
from .. import arch
-from ..size import Size, ROUND_UP, ROUND_DOWN, MiB, B, unitStr
+from ..size import Size, ROUND_UP, ROUND_DOWN, EiB, KiB, MiB, MB, TiB, B, unitStr
from ..i18n import _, N_
from .. import udev
@@ -941,7 +941,7 @@ class Ext2FS(FS):
_supported = True
_resizable = True
_linuxNative = True
- _maxSize = Size("8 TiB")
+ _maxSize = Size((8, TiB))
_defaultCheckOptions = ["-f", "-p", "-C", "0"]
_dump = True
_check = True
@@ -1024,7 +1024,7 @@ class Ext2FS(FS):
log.debug("size=%s, current=%s", size, self.currentSize)
# add some padding
size = min(size * Decimal('1.1'),
- size + Size("500 MiB"))
+ size + Size((500, MiB)))
# make sure that the padded and rounded min size is not larger
# than the current size
size = min(size.roundToNearest(self._resizefsUnit,
@@ -1064,7 +1064,7 @@ class Ext3FS(Ext2FS):
# smaller than the default of 4096 bytes and therefore to make liars of us
# with regard to this maximum filesystem size, but if they're doing such
# things they should know the implications of their chosen block size.
- _maxSize = Size("16 TiB")
+ _maxSize = Size((16, TiB))
@property
def needsFSCheck(self):
@@ -1095,7 +1095,7 @@ class FATFS(FS):
2: N_("Usage error.")}
_supported = True
_formattable = True
- _maxSize = Size("1 TiB")
+ _maxSize = Size((1, TiB))
_packages = [ "dosfstools" ]
_defaultMountOptions = ["umask=0077", "shortname=winnt"]
_defaultCheckOptions = ["-n"]
@@ -1117,7 +1117,7 @@ class EFIFS(FATFS):
_type = "efi"
_mountType = "vfat"
_name = N_("EFI System Partition")
- _minSize = Size("50 MiB")
+ _minSize = Size((50, MiB))
@property
def supported(self):
@@ -1136,8 +1136,8 @@ class BTRFS(FS):
_linuxNative = True
_supported = True
_packages = ["btrfs-progs"]
- _minSize = Size("256 MiB")
- _maxSize = Size("16 EiB")
+ _minSize = Size((256, MiB))
+ _maxSize = Size((16, EiB))
# FIXME parted needs to be taught about btrfs so that we can set the
# partition table type correctly for btrfs partitions
# partedSystem = fileSystemType["btrfs"]
@@ -1218,7 +1218,7 @@ class JFS(FS):
_modules = ["jfs"]
_labelfs = fslabeling.JFSLabeling()
_defaultFormatOptions = ["-q"]
- _maxSize = Size("8 TiB")
+ _maxSize = Size((8, TiB))
_formattable = True
_linuxNative = True
_dump = True
@@ -1247,7 +1247,7 @@ class ReiserFS(FS):
_labelfs = fslabeling.ReiserFSLabeling()
_modules = ["reiserfs"]
_defaultFormatOptions = ["-f", "-f"]
- _maxSize = Size("16 TiB")
+ _maxSize = Size((16, TiB))
_formattable = True
_linuxNative = True
_dump = True
@@ -1276,7 +1276,7 @@ class XFS(FS):
_modules = ["xfs"]
_labelfs = fslabeling.XFSLabeling()
_defaultFormatOptions = ["-f"]
- _maxSize = Size("16 EiB")
+ _maxSize = Size((16, EiB))
_formattable = True
_linuxNative = True
_supported = True
@@ -1324,8 +1324,8 @@ class AppleBootstrapFS(HFS):
_type = "appleboot"
_mountType = "hfs"
_name = N_("Apple Bootstrap")
- _minSize = Size("768 KiB")
- _maxSize = Size("1 MiB")
+ _minSize = Size((768, KiB))
+ _maxSize = Size((1, MiB))
@property
def supported(self):
@@ -1345,8 +1345,8 @@ class HFSPlus(FS):
_labelfs = fslabeling.HFSPlusLabeling()
_formattable = True
_mountType = "hfsplus"
- _minSize = Size("1 MiB")
- _maxSize = Size("2 TiB")
+ _minSize = Size((1, MiB))
+ _maxSize = Size((2, TiB))
_check = True
partedSystem = fileSystemType["hfs+"]
@@ -1358,7 +1358,7 @@ class MacEFIFS(HFSPlus):
_name = N_("Linux HFS+ ESP")
_labelfs = fslabeling.HFSPlusLabeling()
_udevTypes = []
- _minSize = Size("50 MiB")
+ _minSize = Size((50, MiB))
@property
def supported(self):
@@ -1381,8 +1381,8 @@ class NTFS(FS):
_labelfs = fslabeling.NTFSLabeling()
_fsck = "ntfsresize"
_resizable = True
- _minSize = Size("1 MiB")
- _maxSize = Size("16 TiB")
+ _minSize = Size((1, MiB))
+ _maxSize = Size((16, TiB))
_defaultMountOptions = ["defaults", "ro"]
_defaultCheckOptions = ["-c"]
_packages = ["ntfsprogs"]
@@ -1414,7 +1414,7 @@ class NTFS(FS):
continue
try:
# ntfsresize uses SI unit prefixes
- minSize = Size("%d mb" % int(l.split(":")[1].strip()))
+ minSize = Size((int(l.split(":")[1].strip()), MB))
except (IndexError, ValueError) as e:
minSize = None
log.warning("Unable to parse output for minimum size on %s: %s", self.device, e)
@@ -1425,7 +1425,7 @@ class NTFS(FS):
else:
# add some padding to the min size
size = min(minSize * Decimal('1.1'),
- minSize + Size("500 MiB"))
+ minSize + Size((500, MiB)))
# make sure the padded and rounded min size is not larger than
# the current size
size = min(size.roundToNearest(self._resizefsUnit,
@@ -1576,9 +1576,9 @@ class TmpFS(NoDevFS):
# and 16EB on 64 bit systems
bits = arch.numBits()
if bits == 32:
- self._maxSize = Size("16TiB")
+ self._maxSize = Size((16, TiB))
elif bits == 64:
- self._maxSize = Size("16EiB")
+ self._maxSize = Size((16, EiB))
# if the architecture is other than 32 or 64 bit or unknown
# just use the default maxsize, which is 0, this disables
# resizing but other operations such as mounting should work fine
diff --git a/blivet/formats/prepboot.py b/blivet/formats/prepboot.py
index e44967a..3b5c29f 100644
--- a/blivet/formats/prepboot.py
+++ b/blivet/formats/prepboot.py
@@ -21,7 +21,7 @@
#
from ..errors import FormatCreateError
-from ..size import Size
+from ..size import Size, MiB
from .. import platform
from ..i18n import N_
from . import DeviceFormat, register_device_format
@@ -37,8 +37,8 @@ class PPCPRePBoot(DeviceFormat):
partedFlag = PARTITION_PREP
_formattable = True # can be formatted
_linuxNative = True # for clearpart
- _maxSize = Size("10 MiB")
- _minSize = Size("4 MiB")
+ _maxSize = Size((10, MiB))
+ _minSize = Size((4, MiB))
def __init__(self, **kwargs):
"""
diff --git a/blivet/formats/swap.py b/blivet/formats/swap.py
index ce85a6a..1bc4a81 100644
--- a/blivet/formats/swap.py
+++ b/blivet/formats/swap.py
@@ -25,7 +25,7 @@ from ..storage_log import log_method_call
from ..errors import SwapSpaceError
from ..devicelibs import swap
from . import DeviceFormat, register_device_format
-from ..size import Size
+from ..size import Size, GiB
import logging
log = logging.getLogger("blivet")
@@ -43,7 +43,7 @@ class SwapSpace(DeviceFormat):
_linuxNative = True # for clearpart
#see rhbz#744129 for details
- _maxSize = Size("128 GiB")
+ _maxSize = Size((128, GiB))
def __init__(self, **kwargs):
"""
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index ef4d328..5b05389 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -31,7 +31,7 @@ from .flags import flags
from .devices import PartitionDevice, LUKSDevice, devicePathToName
from .formats import getFormat
from .devicelibs.lvm import get_pool_padding
-from .size import Size
+from .size import Size, TiB
from .i18n import _
from .util import stringize, unicodeize
@@ -611,7 +611,7 @@ def getBestFreeSpaceRegion(disk, part_type, req_size, start=None,
continue
if boot:
- max_boot = Size("2 TiB")
+ max_boot = Size((2, TiB))
free_start = Size(free_geom.start * disk.device.sectorSize)
req_end = free_start + req_size
if req_end > max_boot:
@@ -1666,7 +1666,7 @@ class DiskChunk(Chunk):
# 2TB limit on bootable partitions, regardless of disklabel
if req.device.req_bootable:
- max_boot = sizeToSectors(Size("2 TiB"), self.sectorSize)
+ max_boot = sizeToSectors(Size((2, TiB)), self.sectorSize)
limits.append(max_boot - req_end)
# request-specific maximum (see Request.__init__, above, for details)
diff --git a/blivet/platform.py b/blivet/platform.py
index dc349b2..6e30c74 100644
--- a/blivet/platform.py
+++ b/blivet/platform.py
@@ -28,7 +28,7 @@ from . import arch
from . import devicelibs
from .flags import flags
from .partspec import PartSpec
-from .size import Size
+from .size import Size, GiB, MiB
from .i18n import _, N_
class Platform(object):
@@ -154,7 +154,7 @@ class Platform(object):
def setDefaultPartitioning(self):
"""Return the default platform-specific partitioning information."""
- return [PartSpec(mountpoint="/boot", size=Size("500MiB"),
+ return [PartSpec(mountpoint="/boot", size=Size((500, MiB)),
weight=self.weight(mountpoint="/boot"))]
def weight(self, fstype=None, mountpoint=None):
@@ -193,7 +193,7 @@ class X86(Platform):
def setDefaultPartitioning(self):
"""Return the default platform-specific partitioning information."""
ret = Platform.setDefaultPartitioning(self)
- ret.append(PartSpec(fstype="biosboot", size=Size("1MiB"),
+ ret.append(PartSpec(fstype="biosboot", size=Size((1, MiB)),
weight=self.weight(fstype="biosboot")))
return ret
@@ -227,7 +227,7 @@ class EFI(Platform):
def setDefaultPartitioning(self):
ret = Platform.setDefaultPartitioning(self)
ret.append(PartSpec(mountpoint="/boot/efi", fstype="efi",
- size=Size("20MiB"), maxSize=Size("200MiB"),
+ size=Size((20, MiB)), maxSize=Size((200, MiB)),
grow=True, weight=self.weight(fstype="efi")))
return ret
@@ -249,7 +249,7 @@ class MacEFI(EFI):
def setDefaultPartitioning(self):
ret = Platform.setDefaultPartitioning(self)
ret.append(PartSpec(mountpoint="/boot/efi", fstype="macefi",
- size=Size("20MiB"), maxSize=Size("200MiB"),
+ size=Size((20, MiB)), maxSize=Size((200, MiB)),
grow=True, weight=self.weight(mountpoint="/boot/efi")))
return ret
@@ -266,7 +266,7 @@ class PPC(Platform):
class IPSeriesPPC(PPC):
_boot_stage1_format_types = ["prepboot"]
- _boot_stage1_max_end = Size("4 GiB")
+ _boot_stage1_max_end = Size((4, GiB))
_boot_prep_description = N_("PReP Boot Partition")
_boot_descriptions = {"partition": _boot_prep_description}
_disklabel_types = ["msdos", "gpt"]
@@ -276,7 +276,7 @@ class IPSeriesPPC(PPC):
def setDefaultPartitioning(self):
ret = PPC.setDefaultPartitioning(self)
- ret.append(PartSpec(fstype="prepboot", size=Size("4MiB"),
+ ret.append(PartSpec(fstype="prepboot", size=Size((4, MiB)),
weight=self.weight(fstype="prepboot")))
return ret
@@ -301,7 +301,7 @@ class NewWorldPPC(PPC):
def setDefaultPartitioning(self):
ret = Platform.setDefaultPartitioning(self)
- ret.append(PartSpec(fstype="appleboot", size=Size("1MiB"),
+ ret.append(PartSpec(fstype="appleboot", size=Size((1, MiB)),
weight=self.weight(fstype="appleboot")))
return ret
@@ -336,7 +336,7 @@ class S390(Platform):
def setDefaultPartitioning(self):
"""Return the default platform-specific partitioning information."""
- return [PartSpec(mountpoint="/boot", size=Size("500MiB"),
+ return [PartSpec(mountpoint="/boot", size=Size((500, MiB)),
weight=self.weight(mountpoint="/boot"), lv=False)]
def requiredDiskLabelType(self, device_type):
"""The required disklabel type for the specified device type."""
@@ -383,11 +383,11 @@ class omapARM(ARM):
def setDefaultPartitioning(self):
"""Return the ARM-OMAP platform-specific partitioning information."""
ret = [PartSpec(mountpoint="/boot/uboot", fstype="vfat",
- size=Size("20MiB"), maxSize=Size("200MiB"),
+ size=Size((20, MiB)), maxSize=Size((200, MiB)),
grow=True,
weight=self.weight(fstype="vfat", mountpoint="/boot/uboot"))]
ret.append(PartSpec(mountpoint="/", fstype="ext4",
- size=Size("2GiB"), maxSize=Size("3GiB"),
+ size=Size((2, GiB)), maxSize=Size((3, GiB)),
weight=self.weight(mountpoint="/")))
return ret
diff --git a/blivet/udev.py b/blivet/udev.py
index 1ca9890..b8bb9d7 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -25,7 +25,7 @@ import os
import re
from . import util
-from .size import Size
+from .size import Size, KiB
from .flags import flags
import pyudev
@@ -419,15 +419,15 @@ def device_get_vg_uuid(info):
def device_get_vg_size(info):
# lvm's decmial precision is not configurable, so we tell it to use
# KB.
- return Size("%s KiB" % info['LVM2_VG_SIZE'])
+ return Size((float(info['LVM2_VG_SIZE']), KiB))
def device_get_vg_free(info):
# lvm's decmial precision is not configurable, so we tell it to use
# KB.
- return Size("%s KiB" % info['LVM2_VG_FREE'])
+ return Size((float(info['LVM2_VG_FREE']), KiB))
def device_get_vg_extent_size(info):
- return Size("%s KiB" % info['LVM2_VG_EXTENT_SIZE'])
+ return Size((float(info['LVM2_VG_EXTENT_SIZE']), KiB))
def device_get_vg_extent_count(info):
return int(info['LVM2_VG_EXTENT_COUNT'])
@@ -439,7 +439,7 @@ def device_get_vg_pv_count(info):
return int(info['LVM2_PV_COUNT'])
def device_get_pv_pe_start(info):
- return Size("%s KiB" % info['LVM2_PE_START'])
+ return Size((float(info['LVM2_PE_START']), KiB))
def device_get_lv_name(info):
return info['LVM2_LV_NAME']
@@ -448,7 +448,7 @@ def device_get_lv_uuid(info):
return info['LVM2_LV_UUID']
def device_get_lv_size(info):
- return Size("%s KiB" % info['LVM2_LV_SIZE'])
+ return Size((float(info['LVM2_LV_SIZE']), KiB))
def device_get_lv_attr(info):
return info['LVM2_LV_ATTR']
diff --git a/blivet/util.py b/blivet/util.py
index e3670a9..f941e6d 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -143,17 +143,17 @@ def total_memory():
:rtype: :class:`~.size.Size`
"""
# import locally to avoid a cycle with size importing util
- from .size import Size
+ from .size import Size, KiB, MiB
lines = open("/proc/meminfo").readlines()
for line in lines:
if line.startswith("MemTotal:"):
- mem = Size("%s KiB" % line.split()[1])
+ mem = Size((float(line.split()[1]), KiB))
# Because /proc/meminfo only gives us the MemTotal (total physical RAM
# minus the kernel binary code), we need to round this up. Assuming
# every machine has the total RAM MiB number divisible by 128. */
- bs = Size("128MiB")
+ bs = Size((128, MiB))
mem = (mem / bs + 1) * bs
return mem
--
1.9.3
More information about the anaconda-patches
mailing list