Skip to content

Commit

Permalink
block.py: Check for thin pool @ startup
Browse files Browse the repository at this point in the history
Resolves: #17

Signed-off-by: Tony Asleson <tasleson@redhat.com>
  • Loading branch information
tasleson committed Jul 5, 2019
1 parent bad8895 commit 68131b1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions targetd/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,26 @@ def initialize(config_dict):

# fail early if can't access any vg
for pool in pools:
thinp = None
error = ""
vg_name, thin_pool = get_vg_lv(pool)
test_vg = bd.lvm.vginfo(vg_name)

if test_vg is None:
raise TargetdError(TargetdError.VOLUME_GROUP_NOT_FOUND, "VG pool {} not found".format(vg_name))
if vg_name and thin_pool:
# We have VG name and LV name, check for it!
try:
thinp = bd.lvm.lvinfo(vg_name, thin_pool)
except gi.overrides.BlockDev.LVMError as lve:
error = str(lve).strip()

if thinp is None:
raise TargetdError(TargetdError.VOLUME_GROUP_NOT_FOUND,
"VG with thin LV {} not found, "
"nested error: {}".format(pool, error))
else:
test_vg = bd.lvm.vginfo(vg_name)
if test_vg is None:
raise TargetdError(TargetdError.VOLUME_GROUP_NOT_FOUND,
"VG pool {} not found".format(vg_name))

# Allowed multi-pool configs:
# two thinpools from a single vg: ok
Expand Down

0 comments on commit 68131b1

Please sign in to comment.