diff options
| author | Adrian Likins <alikins@redhat.com> | 2008-10-20 10:52:05 -0400 |
|---|---|---|
| committer | Adrian Likins <alikins@redhat.com> | 2008-10-20 10:52:05 -0400 |
| commit | 6e17cdc205518bf6f4a4524622ea1c4eaff2d87d (patch) | |
| tree | 467fbe92a99e9a2589afaeda3ed133ce2eb47075 /func | |
| parent | d3848c9469ce32e4015095bd2b083e4a7b9560fa (diff) | |
| download | func-6e17cdc205518bf6f4a4524622ea1c4eaff2d87d.tar.gz func-6e17cdc205518bf6f4a4524622ea1c4eaff2d87d.tar.xz func-6e17cdc205518bf6f4a4524622ea1c4eaff2d87d.zip | |
Add some support for saving module config files. And corresponding test cases.
Diffstat (limited to 'func')
| -rw-r--r-- | func/minion/modules/func_module.py | 10 | ||||
| -rw-r--r-- | func/minion/modules/test.py | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/func/minion/modules/func_module.py b/func/minion/modules/func_module.py index a405198..6985164 100644 --- a/func/minion/modules/func_module.py +++ b/func/minion/modules/func_module.py @@ -11,6 +11,7 @@ ## import inspect +import os from func import logger from certmaster.config import read_config, BaseConfig @@ -48,10 +49,15 @@ class FuncModule(object): self.logger = log.logger def __init_options(self): - options_file = '/etc/func/modules/'+self.__class__.__name__+'.conf' - self.options = read_config(options_file, self.Config) + self.options_file = '/etc/func/modules/'+self.__class__.__name__+'.conf' + self.options = read_config(self.options_file, self.Config) return + def save_config(self): + fh = open(self.options_file, 'w') + self.options.write(fh) + return True + def register_rpc(self, handlers, module_name): # add the internal methods, note that this means they # can get clobbbered by subclass versions diff --git a/func/minion/modules/test.py b/func/minion/modules/test.py index 2103042..efcfde6 100644 --- a/func/minion/modules/test.py +++ b/func/minion/modules/test.py @@ -47,6 +47,17 @@ class Test(func_module.FuncModule): """ return self.options + def config_save(self): + """ + Saves the options config + """ + self.save_config() + return self.options + + def config_set(self, key_name, value): + setattr(self.options,key_name, value) + self.save_config() + return self.options def register_method_args(self): |
