2828from ._constants import TOP_OBJECT
2929from ._formatting import (
3030 TABLE_FAILURE_STRING ,
31+ TABLE_UNKNOWN_STRING ,
3132 TOTAL_USED_FREE ,
33+ catch_missing_property ,
3234 get_property ,
3335 print_table ,
3436)
@@ -158,16 +160,36 @@ def filesystem_size_quartet(
158160 )
159161 return f"{ triple_str } / { limit } "
160162
163+ pool_name_func = catch_missing_property (
164+ lambda mo : self .pool_object_path_to_pool_name .get (
165+ mo .Pool (), TABLE_UNKNOWN_STRING
166+ ),
167+ TABLE_UNKNOWN_STRING ,
168+ )
169+ name_func = catch_missing_property (
170+ lambda mofs : mofs .Name (), TABLE_UNKNOWN_STRING
171+ )
172+ size_func = catch_missing_property (
173+ lambda mofs : filesystem_size_quartet (
174+ ListFilesystem .size_triple (mofs ),
175+ get_property (mofs .SizeLimit (), Range , None ),
176+ ),
177+ TABLE_UNKNOWN_STRING ,
178+ )
179+ devnode_func = catch_missing_property (
180+ lambda mofs : mofs .Devnode (), TABLE_UNKNOWN_STRING
181+ )
182+ uuid_func = catch_missing_property (
183+ lambda mofs : self .uuid_formatter (mofs .Uuid ()), TABLE_UNKNOWN_STRING
184+ )
185+
161186 tables = [
162187 (
163- self .pool_object_path_to_pool_name [mofilesystem .Pool ()],
164- mofilesystem .Name (),
165- filesystem_size_quartet (
166- ListFilesystem .size_triple (mofilesystem ),
167- get_property (mofilesystem .SizeLimit (), Range , None ),
168- ),
169- mofilesystem .Devnode (),
170- self .uuid_formatter (mofilesystem .Uuid ()),
188+ pool_name_func (mofilesystem ),
189+ name_func (mofilesystem ),
190+ size_func (mofilesystem ),
191+ devnode_func (mofilesystem ),
192+ uuid_func (mofilesystem ),
171193 )
172194 for mofilesystem in self .filesystems_with_props
173195 ]
@@ -198,26 +220,50 @@ def display(self):
198220
199221 fs = self .filesystems_with_props [0 ]
200222
201- size_triple = ListFilesystem .size_triple (fs )
202- limit = get_property (fs .SizeLimit (), Range , None )
203- created = (
204- date_parser .isoparse (fs .Created ()).astimezone ().strftime ("%b %d %Y %H:%M" )
205- )
223+ uuid = catch_missing_property (
224+ lambda mo : self .uuid_formatter (mo .Uuid ()), TABLE_UNKNOWN_STRING
225+ )(fs )
226+ print (f"UUID: { uuid } " )
206227
207- origin = get_property (fs .Origin (), self .uuid_formatter , None )
228+ name = catch_missing_property (lambda mo : mo .Name (), TABLE_UNKNOWN_STRING )(fs )
229+ print (f"Name: { name } " )
208230
209- print (f"UUID: { self .uuid_formatter (fs .Uuid ())} " )
210- print (f"Name: { fs .Name ()} " )
211- print (f"Pool: { self .pool_object_path_to_pool_name [fs .Pool ()]} " )
231+ pool = catch_missing_property (
232+ lambda mo : self .pool_object_path_to_pool_name .get (
233+ fs .Pool (), TABLE_UNKNOWN_STRING
234+ ),
235+ TABLE_UNKNOWN_STRING ,
236+ )
237+ print (f"Pool: { pool } " )
238+
239+ devnode = catch_missing_property (lambda mo : mo .Devnode (), TABLE_UNKNOWN_STRING )
212240 print ()
213- print (f"Device: { fs .Devnode ()} " )
241+ print (f"Device: { devnode } " )
242+
243+ created = catch_missing_property (
244+ lambda mo : date_parser .isoparse (mo .Created ())
245+ .astimezone ()
246+ .strftime ("%b %d %Y %H:%M" ),
247+ TABLE_UNKNOWN_STRING ,
248+ )(fs )
214249 print ()
215250 print (f"Created: { created } " )
251+
252+ origin = catch_missing_property (
253+ lambda mo : get_property (mo .Origin (), self .uuid_formatter , None ),
254+ TABLE_UNKNOWN_STRING ,
255+ )(fs )
216256 print ()
217257 print (f"Snapshot origin: { origin } " )
218258 if origin is not None :
219- scheduled = "Yes" if fs .MergeScheduled () else "No"
259+ scheduled = catch_missing_property (
260+ lambda mo : "Yes" if fs .MergeScheduled () else "No" , TABLE_UNKNOWN_STRING
261+ )(fs )
220262 print (f" Revert scheduled: { scheduled } " )
263+
264+ size_triple = catch_missing_property (
265+ ListFilesystem .size_triple , TABLE_UNKNOWN_STRING
266+ )(fs )
221267 print ()
222268 print ("Sizes:" )
223269 print (f" Logical size of thin device: { size_triple .total ()} " )
@@ -229,5 +275,9 @@ def display(self):
229275 " Free: "
230276 f"{ TABLE_FAILURE_STRING if size_triple .free () is None else size_triple .free ()} "
231277 )
278+
279+ limit = catch_missing_property (
280+ lambda mo : get_property (mo .SizeLimit (), Range , None ), TABLE_UNKNOWN_STRING
281+ )(fs )
232282 print ()
233283 print (f" Size Limit: { limit } " )
0 commit comments