Commit 7155829b authored by Helga Velroyen's avatar Helga Velroyen

Fix lint error in lvmstrap

This patch fixes the 'too many branches' lint error
in the lvmstrap tool.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarJose Lopes <jabolopes@google.com>
parent ba63131f
......@@ -823,6 +823,27 @@ def CreateVG(vgname, disks):
(vgname, " ".join(disks), result.output))
def _ComputeSysdFreeUsed(sysdisks):
sysd_free = []
sysd_used = []
for name, _, _, parts, used in sysdisks:
if used:
sysd_used.append(name)
for partname, _, _, partused in parts:
if partused:
sysd_used.append(partname)
else:
sysd_free.append(partname)
else:
sysd_free.append(name)
if not sysd_free:
raise PrereqError("no free disks found! (%d in-use disks)" %
len(sysd_used))
return (sysd_free, sysd_used)
def ValidateDiskList(options):
"""Validates or computes the disk list for create.
......@@ -840,22 +861,9 @@ def ValidateDiskList(options):
if not sysdisks:
raise PrereqError("no disks found (I looked for"
" non-removable block devices).")
sysd_free = []
sysd_used = []
for name, _, _, parts, used in sysdisks:
if used:
sysd_used.append(name)
for partname, _, _, partused in parts:
if partused:
sysd_used.append(partname)
else:
sysd_free.append(partname)
else:
sysd_free.append(name)
if not sysd_free:
raise PrereqError("no free disks found! (%d in-use disks)" %
len(sysd_used))
(sysd_free, sysd_used) = _ComputeSysdFreeUsed(sysdisks)
if options.alldisks:
disklist = sysd_free
elif options.disks:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment