Skip to content

Commit

Permalink
Run blockdev report commands after _make_loopbacked_devices()
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Gurney <[email protected]>
  • Loading branch information
bgurney-rh committed Sep 28, 2023
1 parent 3601819 commit 86c9b5e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,22 @@ def _make_loopbacked_devices(num):
return devices


def _run_command(num_devices, command):
def _run_command(namespace, num_devices, command):
"""
Prepare devices and run command on devices.
:param int num_devices: number of loopbacked devices
:param list command: the command to be run
"""
devices = _make_loopbacked_devices(num_devices)
if namespace.log_level > 0:
for device in devices:
for option in ["--getss", "--getpbsz", "--getiomin", "--getioopt"]:
diagcmd = ["blockdev", option, device]
with subprocess.Popen(diagcmd, stdout=subprocess.PIPE) as proc:
blockdevoutput = proc.stdout.readline().strip().decode("utf-8")
print(f"output of {diagcmd}: {blockdevoutput}")

command = command + list(itertools.chain(*[["--disk", dev] for dev in devices]))
subprocess.run(command, check=True)

Expand All @@ -77,7 +85,7 @@ def _run_stratisd_cert(namespace):
)
+ ["-v"]
)
_run_command(3, command)
_run_command(namespace, 3, command)


def _run_stratis_cli_cert(namespace):
Expand All @@ -92,7 +100,7 @@ def _run_stratis_cli_cert(namespace):
)
+ ["-v"]
)
_run_command(3, command)
_run_command(namespace, 3, command)


def _gen_parser():
Expand All @@ -119,6 +127,9 @@ def _gen_parser():
stratisd_cert_parser.add_argument(
"--verify-devices", help="Verify /dev/disk/by-id devices", action="store_true"
)
stratisd_cert_parser.add_argument(
"--log-level", help="Log level", action="store", type=int
)

stratisd_cert_parser.add_argument(
"--highest-revision-number",
Expand Down

0 comments on commit 86c9b5e

Please sign in to comment.