[blivet][PATCH] Allow specifying thin pool profiles

Vratislav Podzimek vpodzime at redhat.com
Fri Sep 19 19:25:50 UTC 2014


On Fri, 2014-09-19 at 15:47 +0200, Vratislav Podzimek wrote:
> Related: rhbz#869456
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  blivet/devicelibs/lvm.py | 12 ++++++++++--
>  blivet/devices.py        | 10 ++++++++--
>  2 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
> index 426794f..e3b7ca9 100644
> --- a/blivet/devicelibs/lvm.py
> +++ b/blivet/devicelibs/lvm.py
> @@ -22,6 +22,7 @@
>  
>  import math
>  from decimal import Decimal
> +from collections import namedtuple
>  
>  import logging
>  log = logging.getLogger("blivet")
> @@ -31,7 +32,7 @@ from ..size import Size
>  from .. import util
>  from .. import arch
>  from ..errors import LVMError
> -from ..i18n import _
> +from ..i18n import _, N_
>  
>  MAX_LV_SLOTS = 256
>  
> @@ -47,6 +48,10 @@ LVM_THINP_MAX_CHUNK_SIZE = Size("1 GiB")
>  
>  RAID_levels = raid.RAIDLevels(["raid0", "raid1", "linear"])
>  
> +ThPoolProfile = namedtuple("ThPoolProfile", ["name", "desc"])
> +KNOWN_THPOOL_PROFILES = (ThPoolProfile("thin-generic", N_("Generic")),
> +                         ThPoolProfile("thin-performance", N_("Performance")))
> +
>  def has_lvm():
>      if util.find_program_in_path("lvm"):
>          for line in open("/proc/devices").readlines():
> @@ -559,7 +564,7 @@ def lvsnapshotcreate(vg_name, snap_name, size, origin_name):
>      except LVMError as msg:
>          raise LVMError("lvsnapshotcreate failed for %s/%s: %s" % (vg_name, snap_name, msg))
>  
> -def thinpoolcreate(vg_name, lv_name, size, metadatasize=None, chunksize=None):
> +def thinpoolcreate(vg_name, lv_name, size, metadatasize=None, chunksize=None, profile=None):
>      args = ["lvcreate", "--thinpool", "%s/%s" % (vg_name, lv_name),
>              "--size", "%dm" % size.convertTo(spec="mib")]
>  
> @@ -571,6 +576,9 @@ def thinpoolcreate(vg_name, lv_name, size, metadatasize=None, chunksize=None):
>          # default unit is KiB
>          args += ["--chunksize", "%d" % chunksize.convertTo(spec="kib")]
>  
> +    if profile:
> +        args += ["--profile=%s" % profile]
> +
>      args += _getConfigArgs()
>  
>      try:
> diff --git a/blivet/devices.py b/blivet/devices.py
> index 26dfff8..9cd6eb6 100644
> --- a/blivet/devices.py
> +++ b/blivet/devices.py
> @@ -3441,7 +3441,7 @@ class LVMThinPoolDevice(LVMLogicalVolumeDevice):
>      def __init__(self, name, parents=None, size=None, uuid=None,
>                   fmt=None, exists=False, sysfsPath='',
>                   grow=None, maxsize=None, percent=None,
> -                 metadatasize=None, chunksize=None, segType=None):
> +                 metadatasize=None, chunksize=None, segType=None, profile=None):
>          """
>              :param name: the device name (generally a device node's basename)
>              :type name: str
> @@ -3472,6 +3472,9 @@ class LVMThinPoolDevice(LVMLogicalVolumeDevice):
>              :type metadatasize: :class:`~.size.Size`
>              :keyword chunksize: chunk size for the pool
>              :type chunksize: :class:`~.size.Size`
> +            :keyword profile: (allocation) profile for the pool or None (unspecified)
> +            :type profile: :class:`~.devicelibs.lvm.ThPoolProfile` or NoneType
> +
>          """
>          if metadatasize is not None and \
>             not lvm.is_valid_thin_pool_metadata_size(metadatasize):
> @@ -3491,6 +3494,7 @@ class LVMThinPoolDevice(LVMLogicalVolumeDevice):
>  
>          self.metaDataSize = metadatasize or 0
>          self.chunkSize = chunksize or 0
> +        self.profile = profile
>          self._lvs = []
>  
>      def _addLogVol(self, lv):
> @@ -3536,7 +3540,8 @@ class LVMThinPoolDevice(LVMLogicalVolumeDevice):
>          # TODO: chunk size, data/metadata split --> profile
>          lvm.thinpoolcreate(self.vg.name, self.lvname, self.size,
>                             metadatasize=self.metaDataSize,
> -                           chunksize=self.chunkSize)
> +                           chunksize=self.chunkSize,
> +                           profile=self.profile)
This should be 'profile=self.profile.name'. Fixed locally.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list