diff options
Diffstat (limited to 'server/config_data.py')
-rwxr-xr-x | server/config_data.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/server/config_data.py b/server/config_data.py index 9ccca75..bda7635 100755 --- a/server/config_data.py +++ b/server/config_data.py @@ -16,19 +16,10 @@ from codes import * - import os -import yaml - -CONFIG_FILE = "/etc/virt-factory/settings" - -# from the comments in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 -#class Singleton(object): -# def __new__(type): -# if not '_the_instance' in type.__dict__: -# type._the_instance = object.__new__(type) -# return type._the_instance +import ConfigParser +CONFIG_FILE = "/etc/func/settings" class Config: @@ -40,16 +31,18 @@ class Config: self.__dict__ = self.__shared_state if not self.has_read: self.read() - print "***** CONFIG RELOAD *****" Config.has_read = True def read(self): + if not os.path.exists(CONFIG_FILE): - raise MisconfiguredException(comment="Missing %s" % CONFIG_FILE) - config_file = open(CONFIG_FILE) - data = config_file.read() - self.ds = yaml.load(data).next() - + raise FuncException(comment="Missing %s" % CONFIG_FILE) + + cp = ConfigParser.ConfigParser() + + self.ds["is_master"] = int(cp.get("general","is_master")) + self.ds["is_minion"] = int(cp.get("general","is_minion")) + self.ds["master_server"] = cp.get("general","master") def get(self): return self.ds |