Skip to content

Commit

Permalink
fix: reformat to conform to standard
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Gill <[email protected]>
  • Loading branch information
trgill committed Jan 25, 2024
1 parent db1fa8d commit 9641e4b
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions tasks/files/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def check_positive(value):
)
except ValueError:
raise Exception(
"{0:04x} is not an integer, it is type {1}".format(
value, value.__class__)
"{0:04x} is not an integer, it is type {1}".format(value, value.__class__)
)
return value

Expand Down Expand Up @@ -252,8 +251,7 @@ def lvm_is_owned(lv_name, prefix, suffix):


def lvm_is_snapshot(vg_name, snapshot_name):
lvs_command = ["lvs", "--reportformat",
"json", vg_name + "/" + snapshot_name]
lvs_command = ["lvs", "--reportformat", "json", vg_name + "/" + snapshot_name]

rc, output = run_command(lvs_command)

Expand Down Expand Up @@ -488,8 +486,7 @@ def check_lvs(required_space, vg_name, lv_name, prefix, suffix):
if lv_name and lvs["lv_name"] != lv_name:
continue

rc, message = check_name_for_snapshot(
lvs["lv_name"], prefix, suffix)
rc, message = check_name_for_snapshot(lvs["lv_name"], prefix, suffix)
if rc != SnapshotStatus.SNAPSHOT_OK:
return rc, message

Expand Down Expand Up @@ -521,8 +518,7 @@ def check_verify_lvs_set(snapset_json):
vg = list_item["vg"]
lv = list_item["lv"]

snapshot_name = get_snapshot_name(
lv, None, get_snapset_suffix(snapset_name))
snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name))

rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
Expand Down Expand Up @@ -590,17 +586,15 @@ def check_verify_lvs_completed(snapshot_all, vg_name, lv_name, prefix, suffix):

snapshot_name = get_snapshot_name(lvs["lv_name"], prefix, suffix)

rc, _vg_exists, lv_exists = lvm_lv_exists(
verify_vg_name, snapshot_name)
rc, _vg_exists, lv_exists = lvm_lv_exists(verify_vg_name, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
return (
SnapshotStatus.ERROR_VERIFY_COMMAND_FAILED,
"check verify: command failed for LV exists",
)

if lv_exists:
rc, is_snapshot = lvm_is_snapshot(
verify_vg_name, snapshot_name)
rc, is_snapshot = lvm_is_snapshot(verify_vg_name, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
return (
SnapshotStatus.ERROR_VERIFY_COMMAND_FAILED,
Expand Down Expand Up @@ -659,8 +653,7 @@ def clean_snapshot_set(snapset_json):
vg = list_item["vg"]
lv = list_item["lv"]

snapshot_name = get_snapshot_name(
lv, None, get_snapset_suffix(snapset_name))
snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name))

rc, vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name)

Expand Down Expand Up @@ -688,8 +681,7 @@ def clean_verify_snapshot_set(snapset_json):
vg = list_item["vg"]
lv = list_item["lv"]

snapshot_name = get_snapshot_name(
lv, None, get_snapset_suffix(snapset_name))
snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name))

rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
Expand Down Expand Up @@ -795,8 +787,7 @@ def clean_verify_snapshots(vg_name, lv_name, prefix, suffix):

snapshot_name = get_snapshot_name(lvs["lv_name"], prefix, suffix)

rc, _vg_exists, lv_exists = lvm_lv_exists(
verify_vg_name, snapshot_name)
rc, _vg_exists, lv_exists = lvm_lv_exists(verify_vg_name, snapshot_name)

if lv_exists:
return (
Expand Down Expand Up @@ -892,8 +883,7 @@ def verify_snapset_target_no_existing(snapset_json):
vg = list_item["vg"]
lv = list_item["lv"]

snapshot_name = get_snapshot_name(
lv, None, get_snapset_suffix(snapset_name))
snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name))

rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name)
if rc != SnapshotStatus.SNAPSHOT_OK:
Expand Down Expand Up @@ -1349,8 +1339,7 @@ def check_cmd(args):
if args.verify:
rc, message = check_verify_lvs_set(snapset_json)
else:
rc, message, _current_space_dict = snapshot_precheck_lv_set(
snapset_json)
rc, message, _current_space_dict = snapshot_precheck_lv_set(snapset_json)

return rc, message

Expand Down Expand Up @@ -1450,12 +1439,10 @@ def revert_cmd(args):
parser = argparse.ArgumentParser(description="Snapshot Operations")

# sub-parsers
subparsers = parser.add_subparsers(
dest="operation", help="Available operations")
subparsers = parser.add_subparsers(dest="operation", help="Available operations")

# sub-parser for 'snapshot'
snapshot_parser = subparsers.add_parser(
"snapshot", help="Snapshot given VG/LVs")
snapshot_parser = subparsers.add_parser("snapshot", help="Snapshot given VG/LVs")
snapshot_parser.set_defaults(func=snapshot_cmd)
snapshot_parser.add_argument(
"-g",
Expand Down Expand Up @@ -1518,8 +1505,7 @@ def revert_cmd(args):
)

# sub-parser for 'check'
check_parser = subparsers.add_parser(
"check", help="Check space for given VG/LV")
check_parser = subparsers.add_parser("check", help="Check space for given VG/LV")
check_parser.add_argument(
"-g",
"--group",
Expand Down

0 comments on commit 9641e4b

Please sign in to comment.