On Thu, May 05, 2016 at 02:53:30PM +0100, 'Federico Morg Pareschi' via
ganeti-devel wrote:
> Signed-off-by: Federico Morg Pareschi <[email protected]>
LGTM!
Cheers,
Brian.
> ---
> lib/backend.py | 11 ++++++-----
> lib/storage/bdev.py | 11 +++--------
> 2 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index ba71fbe..f0ce380 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -3805,7 +3805,7 @@ def BlockdevGetmirrorstatusMulti(disks):
> """
> result = []
> lvs_cache = None
> - is_plain_disk = any([_CheckForPlainDisk(d) for d in disks])
> + is_plain_disk = compat.any([_CheckForPlainDisk(d) for d in disks])
> if is_plain_disk:
> lvs_cache = bdev.LogicalVolume._GetLvGlobalInfo()
> for disk in disks:
> @@ -3827,7 +3827,7 @@ def BlockdevGetmirrorstatusMulti(disks):
> return result
>
>
> -def _CheckForPlainDisk(disk, found=False):
> +def _CheckForPlainDisk(disk):
> """Check within a disk and its children if there is a plain disk type.
>
> @type disk: L{objects.Disk}
> @@ -3836,10 +3836,11 @@ def _CheckForPlainDisk(disk, found=False):
> @return: whether or not there is a plain disk type
>
> """
> - found |= disk.dev_type == constants.DT_PLAIN
> + if disk.dev_type == constants.DT_PLAIN:
> + return True
> if disk.children:
> - return any([_CheckForPlainDisk(d, found) for d in disk.children])
> - return found
> + return compat.any([_CheckForPlainDisk(d) for d in disk.children])
> + return False
>
>
> def _RecursiveFindBD(disk, lvs_cache=None):
> diff --git a/lib/storage/bdev.py b/lib/storage/bdev.py
> index 2d97284..b0e5c78 100644
> --- a/lib/storage/bdev.py
> +++ b/lib/storage/bdev.py
> @@ -510,10 +510,7 @@ class LogicalVolume(base.BlockDev):
> "be empty!")
> return {}
> info = {}
> - for line in out:
> - (key, value) = LogicalVolume._ParseLvInfoLine(line, sep)
> - info[key] = value
> - return info
> + return dict([LogicalVolume._ParseLvInfoLine(line, sep) for line in out])
>
> def Attach(self, lv_info=None):
> """Attach to an existing LV.
> @@ -525,10 +522,8 @@ class LogicalVolume(base.BlockDev):
> """
> self.attached = False
> if not lv_info:
> - (status, major, minor, pe_size, stripes, pv_names) = \
> - LogicalVolume._GetLvGlobalInfo()[self.dev_path]
> - else:
> - (status, major, minor, pe_size, stripes, pv_names) = lv_info
> + lv_info = LogicalVolume._GetLvGlobalInfo()[self.dev_path]
> + (status, major, minor, pe_size, stripes, pv_names) = lv_info
>
> self.major = major
> self.minor = minor
> --
> 2.8.0.rc3.226.g39d4020
>