2 ## Copyright 2007, Red Hat, Inc
5 ## This software may be freely redistributed under the terms of the GNU
6 ## general public license.
8 ## You should have received a copy of the GNU General Public License
9 ## along with this program; if not, write to the Free Software
10 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 from func import logger
16 from func.config import read_config
17 from func.commonconfig import FuncdConfig
20 class FuncModule(object):
22 # the version is meant to
25 description = "No Description provided"
29 config_file = '/etc/func/minion.conf'
30 self.config = read_config(config_file, FuncdConfig)
32 self.__base_methods = {
33 # __'s so we don't clobber useful names
34 "module_version" : self.__module_version,
35 "module_api_version" : self.__module_api_version,
36 "module_description" : self.__module_description,
37 "list_methods" : self.__list_methods
42 self.logger = log.logger
44 def register_rpc(self, handlers, module_name):
45 # add the internal methods, note that this means they
46 # can get clobbbered by subclass versions
47 for meth in self.__base_methods:
48 handlers["%s.%s" % (module_name, meth)] = self.__base_methods[meth]
50 # register all methods that don't start with an underscore
51 for attr in dir(self):
52 if inspect.ismethod(getattr(self, attr)) and attr[0] != '_':
53 handlers["%s.%s" % (module_name, attr)] = getattr(self, attr)
55 def __list_methods(self):
56 return self.methods.keys() + self.__base_methods.keys()
58 def __module_version(self):
61 def __module_api_version(self):
62 return self.api_version
64 def __module_description(self):
65 return self.description