From 7f5f8a6eaa1f2c92a292dbfebfd20eec767e6539 Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 3 Aug 2023 16:15:18 -0400 Subject: [PATCH 01/12] Add stub function to stratis for pool report subcommand Signed-off-by: mulhern --- src/stratis_cli/_actions/_pool.py | 16 +++ src/stratis_cli/_actions/_report_pool.py | 158 +++++++++++++++++++++++ src/stratis_cli/_parser/_pool.py | 39 ++++++ 3 files changed, 213 insertions(+) create mode 100644 src/stratis_cli/_actions/_report_pool.py diff --git a/src/stratis_cli/_actions/_pool.py b/src/stratis_cli/_actions/_pool.py index 52637338e..8faf7b73f 100644 --- a/src/stratis_cli/_actions/_pool.py +++ b/src/stratis_cli/_actions/_pool.py @@ -46,6 +46,7 @@ from ._constants import TOP_OBJECT from ._formatting import get_property, get_uuid_formatter from ._list_pool import list_pools +from ._report_pool import report_pool from ._utils import ClevisInfo, PoolSelector @@ -710,3 +711,18 @@ def explain_code(namespace): Print an explanation of pool error code. """ print(PoolErrorCode.explain(namespace.code)) + + @staticmethod + def report_pool(namespace): + """ + Report information about a pool. + """ + uuid_formatter = get_uuid_formatter(namespace.unhyphenated_uuids) + + selection = ( + (PoolIdType.NAME, namespace.name) + if namespace.uuid is None + else (PoolIdType.UUID, namespace.uuid) + ) + + return report_pool(uuid_formatter, selection, stopped=namespace.stopped) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py new file mode 100644 index 000000000..0b9fd01b4 --- /dev/null +++ b/src/stratis_cli/_actions/_report_pool.py @@ -0,0 +1,158 @@ +# Copyright 2023 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Pool report. +""" + +# isort: STDLIB +from abc import ABC, abstractmethod + +from .._errors import StratisCliResourceNotFoundError +from .._stratisd_constants import PoolIdType +from ._connection import get_object +from ._constants import TOP_OBJECT + + +def _fetch_stopped_pools_property(proxy): + """ + Fetch the StoppedPools property from stratisd. + :param proxy: proxy to the top object in stratisd + :return: a representation of stopped devices + :rtype: dict + :raises StratisCliEngineError: + """ + + # pylint: disable=import-outside-toplevel + from ._data import Manager + + return Manager.Properties.StoppedPools.Get(proxy) + + +def report_pool(uuid_formatter, selection, *, stopped=False): + """ + List the specified information about pools. + """ + klass = ( + Stopped(uuid_formatter, selection) + if stopped + else Default(uuid_formatter, selection) + ) + klass.report_pool() + + +class Report(ABC): # pylint: disable=too-few-public-methods + """ + Handle reporting on a pool or pools. + """ + + def __init__(self, uuid_formatter, selection): + """ + Initialize a List object. + :param uuid_formatter: function to format a UUID str or UUID + :param uuid_formatter: str or UUID -> str + :param selection: how to select the pool to display + :type selection: pair of str * object + """ + self.uuid_formatter = uuid_formatter + self.selection = selection + + @abstractmethod + def report_pool(self): + """ + List the pools. + """ + + +class Default(Report): # pylint: disable=too-few-public-methods + """ + Report on pools that stratis list by default. + """ + + def report_pool(self): + """ + Do pool reports. + """ + # pylint: disable=import-outside-toplevel + from ._data import MODev, ObjectManager, devs, pools + + proxy = get_object(TOP_OBJECT) + + managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {}) + + (selection_type, selection_value) = self.selection + (selection_key, selection_value) = ( + ("Uuid", selection_value.hex) + if selection_type == PoolIdType.UUID + else ("Name", selection_value) + ) + + (pool_object_path, _) = next( + pools(props={selection_key: selection_value}) + .require_unique_match(True) + .search(managed_objects) + ) + + modevs = ( + MODev(info) + for objpath, info in devs(props={"Pool": pool_object_path}).search( + managed_objects + ) + ) + + # replace the lines below with the correct call to lsblk + for modev in modevs: + print(modev.Devnode()) + + +class Stopped(Report): # pylint: disable=too-few-public-methods + """ + Support for reporting on stopped pools. + """ + + def report_pool(self): + """ + Report on stopped pool. + """ + proxy = get_object(TOP_OBJECT) + + stopped_pools = _fetch_stopped_pools_property(proxy) + + (selection_type, selection_value) = self.selection + + if selection_type == PoolIdType.UUID: + selection_value = selection_value.hex + + def selection_func(uuid, _info): + return uuid == selection_value + + else: + + def selection_func(_uuid, info): + return info.get("name") == selection_value + + stopped_pool = next( + ( + info + for (uuid, info) in stopped_pools.items() + if selection_func(uuid, info) + ), + None, + ) + + if stopped_pool is None: + raise StratisCliResourceNotFoundError("list", selection_value) + + # Substitute lsblk call here + for dev in stopped_pool["devs"]: + print(dev) diff --git a/src/stratis_cli/_parser/_pool.py b/src/stratis_cli/_parser/_pool.py index 14a606440..94615ba00 100644 --- a/src/stratis_cli/_parser/_pool.py +++ b/src/stratis_cli/_parser/_pool.py @@ -441,4 +441,43 @@ def _ensure_nat(arg): "subcmds": POOL_DEBUG_SUBCMDS, }, ), + ( + "report", + { + "help": "Report information about pools", + "description": "Generate report for pools", + "mut_ex_args": [ + ( + True, + [ + ( + "--uuid", + { + "action": "store", + "type": UUID, + "help": "UUID of pool", + }, + ), + ( + "--name", + { + "action": "store", + "help": "name of pool", + }, + ), + ], + ), + ], + "args": [ + ( + "--stopped", + { + "action": "store_true", + "help": "Display information about stopped pools only.", + }, + ), + ], + "func": PoolActions.report_pool, + }, + ), ] From 1181978f5171e2556f01cbd6688a6cc716271219 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 14 Nov 2023 20:26:05 -0500 Subject: [PATCH 02/12] Use new classes to manage some shared abstractions There are some new classes introduced to handle unpacking the StoppedPools property and also to select a pool by UUID or name. Use them in the report functionality. Signed-off-by: mulhern --- src/stratis_cli/_actions/_pool.py | 4 +-- src/stratis_cli/_actions/_report_pool.py | 33 +++++------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/stratis_cli/_actions/_pool.py b/src/stratis_cli/_actions/_pool.py index 8faf7b73f..1ec990b90 100644 --- a/src/stratis_cli/_actions/_pool.py +++ b/src/stratis_cli/_actions/_pool.py @@ -720,9 +720,9 @@ def report_pool(namespace): uuid_formatter = get_uuid_formatter(namespace.unhyphenated_uuids) selection = ( - (PoolIdType.NAME, namespace.name) + PoolSelector(PoolIdType.NAME, namespace.name) if namespace.uuid is None - else (PoolIdType.UUID, namespace.uuid) + else PoolSelector(PoolIdType.UUID, namespace.uuid) ) return report_pool(uuid_formatter, selection, stopped=namespace.stopped) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index 0b9fd01b4..ced8da186 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -19,7 +19,6 @@ from abc import ABC, abstractmethod from .._errors import StratisCliResourceNotFoundError -from .._stratisd_constants import PoolIdType from ._connection import get_object from ._constants import TOP_OBJECT @@ -44,9 +43,9 @@ def report_pool(uuid_formatter, selection, *, stopped=False): List the specified information about pools. """ klass = ( - Stopped(uuid_formatter, selection) + Stopped(uuid_formatter, selection=selection) if stopped - else Default(uuid_formatter, selection) + else Default(uuid_formatter, selection=selection) ) klass.report_pool() @@ -70,7 +69,7 @@ def __init__(self, uuid_formatter, selection): @abstractmethod def report_pool(self): """ - List the pools. + Report the pools. """ @@ -90,15 +89,8 @@ def report_pool(self): managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {}) - (selection_type, selection_value) = self.selection - (selection_key, selection_value) = ( - ("Uuid", selection_value.hex) - if selection_type == PoolIdType.UUID - else ("Name", selection_value) - ) - (pool_object_path, _) = next( - pools(props={selection_key: selection_value}) + pools(props=self.selection.managed_objects_key()) .require_unique_match(True) .search(managed_objects) ) @@ -128,18 +120,7 @@ def report_pool(self): stopped_pools = _fetch_stopped_pools_property(proxy) - (selection_type, selection_value) = self.selection - - if selection_type == PoolIdType.UUID: - selection_value = selection_value.hex - - def selection_func(uuid, _info): - return uuid == selection_value - - else: - - def selection_func(_uuid, info): - return info.get("name") == selection_value + selection_func = self.selection.stopped_pools_func() stopped_pool = next( ( @@ -151,8 +132,8 @@ def selection_func(_uuid, info): ) if stopped_pool is None: - raise StratisCliResourceNotFoundError("list", selection_value) + raise StratisCliResourceNotFoundError("report", str(self.selection)) # Substitute lsblk call here - for dev in stopped_pool["devs"]: + for dev in stopped_pool.devs: print(dev) From 37330bab0c0a56a730c46ab6579e21ae052dee0d Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Mon, 7 Aug 2023 16:36:20 -0400 Subject: [PATCH 03/12] Add lsblk command Signed-off-by: Bryan Gurney --- src/stratis_cli/_actions/_report_pool.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index ced8da186..0714752fb 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -16,6 +16,7 @@ """ # isort: STDLIB +import subprocess from abc import ABC, abstractmethod from .._errors import StratisCliResourceNotFoundError @@ -103,8 +104,8 @@ def report_pool(self): ) # replace the lines below with the correct call to lsblk - for modev in modevs: - print(modev.Devnode()) + blkdevs = [dev.Devnode() for dev in modevs] + subprocess.run(["lsblk", "-i"] + blkdevs, check=True) class Stopped(Report): # pylint: disable=too-few-public-methods @@ -137,3 +138,4 @@ def report_pool(self): # Substitute lsblk call here for dev in stopped_pool.devs: print(dev) + subprocess.run(["lsblk", "-i", str(dev)], check=True) From f834f731b074150fc784a8247320b2d22b6742ae Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 14 Nov 2023 20:37:04 -0500 Subject: [PATCH 04/12] Now need to get the devnode explicitly Signed-off-by: mulhern --- src/stratis_cli/_actions/_report_pool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index 0714752fb..3e58c3fcb 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -138,4 +138,4 @@ def report_pool(self): # Substitute lsblk call here for dev in stopped_pool.devs: print(dev) - subprocess.run(["lsblk", "-i", str(dev)], check=True) + subprocess.run(["lsblk", "-i", str(dev.devnode)], check=True) From fe946da8f6d31f278876f9049a55963c464d4e9f Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Tue, 8 Aug 2023 13:18:48 -0400 Subject: [PATCH 05/12] Call lsblk from absolute path --- src/stratis_cli/_actions/_report_pool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index 3e58c3fcb..febd098e6 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -105,7 +105,7 @@ def report_pool(self): # replace the lines below with the correct call to lsblk blkdevs = [dev.Devnode() for dev in modevs] - subprocess.run(["lsblk", "-i"] + blkdevs, check=True) + subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) class Stopped(Report): # pylint: disable=too-few-public-methods @@ -138,4 +138,4 @@ def report_pool(self): # Substitute lsblk call here for dev in stopped_pool.devs: print(dev) - subprocess.run(["lsblk", "-i", str(dev.devnode)], check=True) + subprocess.run(["/usr/bin/lsblk", "-i", str(dev.devnode)], check=True) From 21e15a679c4a7e4fa68ca3f89743e25444959774 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Tue, 8 Aug 2023 15:01:14 -0400 Subject: [PATCH 06/12] Ignore bandit B603 errors for processed input --- src/stratis_cli/_actions/_report_pool.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index febd098e6..e1166954c 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -103,9 +103,10 @@ def report_pool(self): ) ) - # replace the lines below with the correct call to lsblk blkdevs = [dev.Devnode() for dev in modevs] - subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) + # Ignore bandit B603 errors. Input comes from D-Bus and has + # been processed. + subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 class Stopped(Report): # pylint: disable=too-few-public-methods @@ -135,7 +136,10 @@ def report_pool(self): if stopped_pool is None: raise StratisCliResourceNotFoundError("report", str(self.selection)) - # Substitute lsblk call here + # Ignore bandit B603 errors. Input comes from D-Bus and has + # been processed. for dev in stopped_pool.devs: print(dev) - subprocess.run(["/usr/bin/lsblk", "-i", str(dev.devnode)], check=True) + subprocess.run( + ["/usr/bin/lsblk", "-i", str(dev.devnode)], check=True + ) # nosec B603 From 8b8f0804045b7dd672a736acf8b3fa1afb756680 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Tue, 8 Aug 2023 15:22:51 -0400 Subject: [PATCH 07/12] Fix stopped pool report command --- src/stratis_cli/_actions/_report_pool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index e1166954c..35526e752 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -139,7 +139,7 @@ def report_pool(self): # Ignore bandit B603 errors. Input comes from D-Bus and has # been processed. for dev in stopped_pool.devs: - print(dev) + print(dev.devnode) subprocess.run( - ["/usr/bin/lsblk", "-i", str(dev.devnode)], check=True + ["/usr/bin/lsblk", "-i", dev.devnode], check=True ) # nosec B603 From 30e9bea0198cf00b76dd356340458977ad9ae47c Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Wed, 9 Aug 2023 14:18:58 -0400 Subject: [PATCH 08/12] Use list comprehension for stopped pool lsblk --- src/stratis_cli/_actions/_report_pool.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index 35526e752..0fed1ec4e 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -138,8 +138,7 @@ def report_pool(self): # Ignore bandit B603 errors. Input comes from D-Bus and has # been processed. + blkdevs = [dev.devnode for dev in stopped_pool.devs] for dev in stopped_pool.devs: print(dev.devnode) - subprocess.run( - ["/usr/bin/lsblk", "-i", dev.devnode], check=True - ) # nosec B603 + subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 From a3092a502aec908fc7255f7a2ff215f113605987 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 10 Aug 2023 09:12:32 -0400 Subject: [PATCH 09/12] Remove for loop from stopped pool lsblk --- src/stratis_cli/_actions/_report_pool.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index 0fed1ec4e..d285818ba 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -139,6 +139,4 @@ def report_pool(self): # Ignore bandit B603 errors. Input comes from D-Bus and has # been processed. blkdevs = [dev.devnode for dev in stopped_pool.devs] - for dev in stopped_pool.devs: - print(dev.devnode) - subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 + subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 From 1ac5d94d0290e34926526873eaa6831fdbea56e8 Mon Sep 17 00:00:00 2001 From: mulhern Date: Sun, 3 Dec 2023 22:36:58 -0500 Subject: [PATCH 10/12] Add some simple tests for coverage Signed-off-by: mulhern --- .github/workflows/main.yml | 1 + .../whitebox/integration/pool/test_report.py | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/whitebox/integration/pool/test_report.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05069f74e..d71e16b22 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,6 +125,7 @@ jobs: python3-psutil python3-wcwidth systemd-devel + util-linux - uses: dtolnay/rust-toolchain@master with: components: cargo diff --git a/tests/whitebox/integration/pool/test_report.py b/tests/whitebox/integration/pool/test_report.py new file mode 100644 index 000000000..3835219e8 --- /dev/null +++ b/tests/whitebox/integration/pool/test_report.py @@ -0,0 +1,60 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Test 'report'. +""" +# isort: STDLIB +from uuid import uuid4 + +# isort: FIRSTPARTY +from dbus_client_gen import DbusClientUniqueResultError + +# isort: LOCAL +from stratis_cli import StratisCliErrorCodes + +from .._misc import RUNNER, SimTestCase, device_name_list + +_ERROR = StratisCliErrorCodes.ERROR +_DEVICE_STRATEGY = device_name_list(1, 1) + + +class ReportTestCase(SimTestCase): + """ + Test 'report' on a sim pool. + """ + + _MENU = ["--propagate", "pool", "report"] + _POOLNAME = "poolname" + + def setUp(self): + super().setUp() + command_line = ["pool", "create", self._POOLNAME] + _DEVICE_STRATEGY() + RUNNER(command_line) + + def test_call_bad_uuid(self): + """ + Test bad uuid + """ + command_line = self._MENU + ["--uuid", str(uuid4())] + self.check_error(DbusClientUniqueResultError, command_line, _ERROR) + + def test_report_bad_name(self): + """ + Test bad name. + """ + command_line = self._MENU + [ + "--name", + "noone", + ] + self.check_error(DbusClientUniqueResultError, command_line, _ERROR) From b2bf57ffe787511fa4faff721053f1c1877f0f3c Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 5 Dec 2023 12:59:21 -0500 Subject: [PATCH 11/12] Add test for reporting on stopped pools Signed-off-by: mulhern --- .../whitebox/integration/pool/test_report.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/whitebox/integration/pool/test_report.py b/tests/whitebox/integration/pool/test_report.py index 3835219e8..9398f8b91 100644 --- a/tests/whitebox/integration/pool/test_report.py +++ b/tests/whitebox/integration/pool/test_report.py @@ -22,6 +22,7 @@ # isort: LOCAL from stratis_cli import StratisCliErrorCodes +from stratis_cli._errors import StratisCliResourceNotFoundError from .._misc import RUNNER, SimTestCase, device_name_list @@ -49,6 +50,13 @@ def test_call_bad_uuid(self): command_line = self._MENU + ["--uuid", str(uuid4())] self.check_error(DbusClientUniqueResultError, command_line, _ERROR) + def test_call_bad_uuid_stopped(self): + """ + Test bad uuid for stopped pools. + """ + command_line = self._MENU + ["--stopped", "--uuid", str(uuid4())] + self.check_error(StratisCliResourceNotFoundError, command_line, _ERROR) + def test_report_bad_name(self): """ Test bad name. @@ -58,3 +66,14 @@ def test_report_bad_name(self): "noone", ] self.check_error(DbusClientUniqueResultError, command_line, _ERROR) + + def test_report_bad_name_stopped(self): + """ + Test bad name for stopped pools. + """ + command_line = self._MENU + [ + "--stopped", + "--name", + "noone", + ] + self.check_error(StratisCliResourceNotFoundError, command_line, _ERROR) From 848b1dee748ecaa1edaa530cdcb725521edf736c Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 5 Dec 2023 13:30:51 -0500 Subject: [PATCH 12/12] Add no cover pragmas where appropriate Signed-off-by: mulhern --- src/stratis_cli/_actions/_report_pool.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/stratis_cli/_actions/_report_pool.py b/src/stratis_cli/_actions/_report_pool.py index d285818ba..c0f5e39a6 100644 --- a/src/stratis_cli/_actions/_report_pool.py +++ b/src/stratis_cli/_actions/_report_pool.py @@ -96,17 +96,21 @@ def report_pool(self): .search(managed_objects) ) + # For sim engine tests, actually running report commands will go wrong. + # Therefore, all tests exit at the previous line. modevs = ( MODev(info) for objpath, info in devs(props={"Pool": pool_object_path}).search( managed_objects ) - ) + ) # pragma: no cover - blkdevs = [dev.Devnode() for dev in modevs] + blkdevs = [dev.Devnode() for dev in modevs] # pragma: no cover # Ignore bandit B603 errors. Input comes from D-Bus and has # been processed. - subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 + subprocess.run( + ["/usr/bin/lsblk", "-i"] + blkdevs, check=True + ) # nosec B603 # pragma: no cover class Stopped(Report): # pylint: disable=too-few-public-methods @@ -136,7 +140,11 @@ def report_pool(self): if stopped_pool is None: raise StratisCliResourceNotFoundError("report", str(self.selection)) + # For sim engine tests, actually running report commands will go wrong. + # Therefore, all tests exit at the previous line. # Ignore bandit B603 errors. Input comes from D-Bus and has # been processed. - blkdevs = [dev.devnode for dev in stopped_pool.devs] - subprocess.run(["/usr/bin/lsblk", "-i"] + blkdevs, check=True) # nosec B603 + blkdevs = [dev.devnode for dev in stopped_pool.devs] # pragma: no cover + subprocess.run( + ["/usr/bin/lsblk", "-i"] + blkdevs, check=True + ) # nosec B603 # pragma: no cover