2323from dbus_python_client_gen import DPClientGenerationError , make_class
2424
2525from .._errors import StratisCliGenerationError
26- from ._constants import MANAGER_INTERFACE , REPORT_INTERFACE
26+ from ._constants import (
27+ FILESYSTEM_INTERFACE ,
28+ MANAGER_INTERFACE ,
29+ POOL_INTERFACE ,
30+ REPORT_INTERFACE ,
31+ )
2732from ._environment import get_timeout
2833from ._introspect import SPECS
2934
@@ -39,22 +44,36 @@ class ClassInfo: # pylint: disable=too-few-public-methods
3944 Information used to construct the dynamically generated class.
4045 """
4146
42- def __init__ (self , name , interface_name ):
47+ def __init__ (self , interface_name , * , invoke_name = None ):
4348 """
4449 Initializer.
4550 """
46- self .name = name
4751 self .interface_name = interface_name
52+ self .invoke_name = invoke_name
4853
4954
5055class ClassKey (Enum ):
5156 """
5257 Keys for dynamically generated classes.
5358 """
5459
55- MANAGER = ClassInfo ("Manager" , MANAGER_INTERFACE )
56- OBJECT_MANAGER = ClassInfo ("ObjectManager" , "org.freedesktop.DBus.ObjectManager" )
57- REPORT = ClassInfo ("Report" , REPORT_INTERFACE )
60+ FILESYSTEM = ClassInfo (FILESYSTEM_INTERFACE , invoke_name = "Filesystem" )
61+ MANAGER = ClassInfo (MANAGER_INTERFACE , invoke_name = "Manager" )
62+ OBJECT_MANAGER = ClassInfo (
63+ "org.freedesktop.DBus.ObjectManager" , invoke_name = "ObjectManager"
64+ )
65+ POOL = ClassInfo (POOL_INTERFACE , invoke_name = "Pool" )
66+ REPORT = ClassInfo (REPORT_INTERFACE , invoke_name = "Report" )
67+
68+
69+ class PurposeKey (Enum ):
70+ """
71+ Purpose of class to be created.
72+ """
73+
74+ INVOKE = 0 # invoke D-Bus methods
75+ OBJECT = 1 # represent object in GetManagedObjects result
76+ SEARCH = 2 # search for object in GEtManagedObjects result
5877
5978
6079def _add_abs_path_assertion (klass , method_name , key ):
@@ -90,14 +109,18 @@ def make_dyn_class(key):
90109 """
91110 try :
92111 klass = make_class (
93- key .value .name ,
112+ key .value .invoke_name ,
94113 ET .fromstring (SPECS [key .value .interface_name ]), # nosec B314
95114 TIMEOUT ,
96115 )
97116
98117 try :
99118 if key == ClassKey .MANAGER :
100119 _add_abs_path_assertion (klass , "CreatePool" , "devices" )
120+ if key == ClassKey .POOL :
121+ _add_abs_path_assertion (klass , "InitCache" , "devices" )
122+ _add_abs_path_assertion (klass , "AddCacheDevs" , "devices" )
123+ _add_abs_path_assertion (klass , "AddDataDevs" , "devices" )
101124 except AttributeError as err : # pragma: no cover
102125 # This can only happen if the expected method is missing from
103126 # the XML spec or code generation has a bug, we will never
@@ -111,6 +134,6 @@ def make_dyn_class(key):
111134
112135 except DPClientGenerationError as err : # pragma: no cover
113136 raise StratisCliGenerationError (
114- f"Failed to generate class { key .value .name } needed for invoking "
137+ f"Failed to generate class { key .value .invoke_name } needed for invoking "
115138 "dbus-python methods"
116139 ) from err
0 commit comments