Skip to content

Commit

Permalink
fix: correct calls to lvm_is_snapshot
Browse files Browse the repository at this point in the history
it returns rc, is_snapshot and should not be called as a boolean
function.

Signed-off-by: Todd Gill <[email protected]>
  • Loading branch information
trgill committed Jun 12, 2024
1 parent f7b6691 commit 0fb96f2
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions library/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,13 @@ def revert_lv(vg_name, snapshot_name, check_mode):
raise LvmBug("'lvs' failed '%d'" % rc)

if lv_exists:
if not lvm_is_snapshot(vg_name, snapshot_name):
rc, is_snapshot = lvm_is_snapshot(vg_name, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
return (
SnapshotStatus.ERROR_VERIFY_COMMAND_FAILED,
"revert_lv: command failed for LV lvm_is_snapshot()",
)
if not is_snapshot:
return (
SnapshotStatus.ERROR_REVERT_FAILED,
"LV with name: " + vg_name + "/" + snapshot_name + " is not a snapshot",
Expand Down Expand Up @@ -829,7 +835,14 @@ def extend_lv_snapshot(vg_name, lv_name, suffix, percent_space_required, check_m

changed = False
if lv_exists:
if not lvm_is_snapshot(vg_name, snapshot_name):
rc, is_snapshot = lvm_is_snapshot(vg_name, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
return (
SnapshotStatus.ERROR_VERIFY_COMMAND_FAILED,
"extend_lv_snapshot: command failed for LV lvm_is_snapshot()",
changed,
)
if not is_snapshot:
return (
SnapshotStatus.ERROR_EXTEND_NOT_SNAPSHOT,
"LV with name: " + vg_name + "/" + snapshot_name + " is not a snapshot",
Expand Down Expand Up @@ -970,7 +983,13 @@ def snapshot_lv(vg_name, lv_name, suffix, snap_size, check_mode):
rc, _vg_exists, lv_exists = lvm_lv_exists(vg_name, snapshot_name)

if lv_exists:
if lvm_is_snapshot(vg_name, snapshot_name):
rc, is_snapshot = lvm_is_snapshot(vg_name, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
return (
SnapshotStatus.ERROR_VERIFY_COMMAND_FAILED,
"snapshot_lv: command failed for LV lvm_is_snapshot()",
)
if is_snapshot:
return (
SnapshotStatus.ERROR_ALREADY_EXISTS,
"Snapshot of :" + vg_name + "/" + lv_name + " already exists",
Expand Down

0 comments on commit 0fb96f2

Please sign in to comment.