summaryrefslogtreecommitdiffstats
path: root/func/minion/modules/func_module.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-01-17 11:55:12 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-01-17 11:55:12 -0500
commiteb67b305060e9e962d6a90766e8a39ca80065af2 (patch)
treee5c0821bdf499de192d31821d0311049444cb2ce /func/minion/modules/func_module.py
parent3c11b8cd0d91e0c4cd5aa007eddc330452b3ace7 (diff)
parentaee6076dd78dfb1b88ab4d369e24fb1bbf710816 (diff)
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
Diffstat (limited to 'func/minion/modules/func_module.py')
-rw-r--r--func/minion/modules/func_module.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/func/minion/modules/func_module.py b/func/minion/modules/func_module.py
index 5965e24..7d476dc 100644
--- a/func/minion/modules/func_module.py
+++ b/func/minion/modules/func_module.py
@@ -10,6 +10,7 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
+import inspect
from func import logger
from func.config import read_config
@@ -34,7 +35,7 @@ class FuncModule(object):
"module_api_version" : self.__module_api_version,
"module_description" : self.__module_description,
"list_methods" : self.__list_methods
- }
+ }
def __init_log(self):
log = logger.Logger()
@@ -45,11 +46,25 @@ class FuncModule(object):
# can get clobbbered by subclass versions
for meth in self.__base_methods:
handlers["%s.%s" % (module_name, meth)] = self.__base_methods[meth]
- for meth in self.methods:
- handlers["%s.%s" % (module_name,meth)] = self.methods[meth]
+
+ # register our module's handlers
+ for name, handler in self.__list_handlers().items():
+ handlers["%s.%s" % (module_name, name)] = handler
+
+ def __list_handlers(self):
+ """ Return a dict of { handler_name, method, ... }.
+ All methods that do not being with an underscore will be exposed.
+ We also make sure to not expose our register_rpc method.
+ """
+ handlers = {}
+ for attr in dir(self):
+ if inspect.ismethod(getattr(self, attr)) and attr[0] != '_' and \
+ attr != 'register_rpc':
+ handlers[attr] = getattr(self, attr)
+ return handlers
def __list_methods(self):
- return self.methods.keys() + self.__base_methods.keys()
+ return self.__list_handlers().keys() + self.__base_methods.keys()
def __module_version(self):
return self.version
@@ -59,7 +74,3 @@ class FuncModule(object):
def __module_description(self):
return self.description
-
-
-methods = FuncModule()
-register_rpc = methods.register_rpc