Skip to content

Commit 444eeb3

Browse files
committed
Lookup pool name without raising not found exception
If the pool object path is not on the D-Bus, stratisd will not even have a field for that item in the GetManagedObjects result and will raise an exception. Do not allow the exception to propagate in this case, but catch it and return the unknown string. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent ca0a8f3 commit 444eeb3

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/stratis_cli/_actions/_physical.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# isort: THIRDPARTY
2222
from justbytes import Range
2323

24+
# isort: FIRSTPARTY
25+
from dbus_client_gen import DbusClientMissingPropertyError
26+
2427
from .._stratisd_constants import BlockDevTiers
2528
from ._connection import get_object
2629
from ._constants import TOP_OBJECT
@@ -79,6 +82,16 @@ def list_devices(namespace: Namespace): # pylint: disable=too-many-locals
7982
).search(managed_objects)
8083
)
8184

85+
def pool_name_lookup(modev) -> str:
86+
"""
87+
Look up a name for a pool. Return place holder if the modev
88+
has no pool attribute.
89+
"""
90+
try:
91+
return path_to_name.get(modev.Pool(), TABLE_UNKNOWN_STRING)
92+
except DbusClientMissingPropertyError:
93+
return TABLE_UNKNOWN_STRING
94+
8295
def paths(modev):
8396
"""
8497
Return <physical_path> (<metadata_path>) if they are different,
@@ -126,7 +139,7 @@ def tier_str(value):
126139

127140
tables = [
128141
[
129-
path_to_name.get(modev.Pool(), TABLE_UNKNOWN_STRING),
142+
pool_name_lookup(modev),
130143
paths(modev),
131144
size(modev),
132145
tier_str(modev.Tier()),

0 commit comments

Comments
 (0)