5959)
6060
6161
62- def _metadata_version (mopool : Any ) -> MetadataVersion | None :
63- try :
64- return MetadataVersion (int (mopool .MetadataVersion ()))
65- except ValueError : # pragma: no cover
66- return None
67-
68-
69- def _volume_key_loaded (mopool : Any ) -> tuple [bool , bool ] | tuple [bool , str ]:
70- """
71- The string result is an error message indicating that the volume key
72- state is unknown.
73- """
74- result = mopool .VolumeKeyLoaded ()
75- if isinstance (result , int ):
76- return (True , bool (result ))
77- return (False , str (result )) # pragma: no cover
78-
79-
8062# This method is only used with legacy pools
8163def _non_existent_or_inconsistent_to_str (
8264 value : EncryptionInfo | None ,
@@ -254,6 +236,28 @@ class Default(ListPool): # pylint: disable=too-few-public-methods
254236 Handle listing the pools that are listed by default.
255237 """
256238
239+ @staticmethod
240+ def metadata_version (mopool : Any ) -> MetadataVersion | None :
241+ """
242+ Return the metadata version, dealing with the possibility that it
243+ might be an error string.
244+ """
245+ try :
246+ return MetadataVersion (int (mopool .MetadataVersion ()))
247+ except ValueError : # pragma: no cover
248+ return None
249+
250+ @staticmethod
251+ def _volume_key_loaded (mopool : Any ) -> tuple [bool , bool ] | tuple [bool , str ]:
252+ """
253+ The string result is an error message indicating that the volume key
254+ state is unknown.
255+ """
256+ result = mopool .VolumeKeyLoaded ()
257+ if isinstance (result , int ):
258+ return (True , bool (result ))
259+ return (False , str (result )) # pragma: no cover
260+
257261 @staticmethod
258262 def alert_codes (
259263 mopool : Any ,
@@ -272,9 +276,9 @@ def alert_codes(
272276 [PoolAllocSpaceAlert .NO_ALLOC_SPACE ] if mopool .NoAllocSpace () else []
273277 )
274278
275- metadata_version = _metadata_version (mopool )
279+ metadata_version = Default . metadata_version (mopool )
276280
277- (vkl_is_bool , volume_key_loaded ) = _volume_key_loaded (mopool )
281+ (vkl_is_bool , volume_key_loaded ) = Default . _volume_key_loaded (mopool )
278282
279283 pool_encryption_alerts = (
280284 [PoolEncryptionAlert .VOLUME_KEY_NOT_LOADED ]
@@ -334,7 +338,7 @@ def _print_detail_view(
334338 for line in alert_summary : # pragma: no cover
335339 print (f" { line } " )
336340
337- metadata_version = _metadata_version (mopool )
341+ metadata_version = Default . metadata_version (mopool )
338342
339343 print (f"Metadata Version: { metadata_version } " )
340344
@@ -500,7 +504,7 @@ def gen_string(has_property: bool, code: str) -> str:
500504 """
501505 return (" " if has_property else "~" ) + code
502506
503- metadata_version = _metadata_version (mopool )
507+ metadata_version = Default . metadata_version (mopool )
504508
505509 props_list = [
506510 (metadata_version in (MetadataVersion .V1 , None ), "Le" ),
0 commit comments