diff options
| author | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-20 21:28:51 -0400 |
|---|---|---|
| committer | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-20 21:28:51 -0400 |
| commit | 8d168259f1cb0af25a7ee342bd1c32cd5bfdd424 (patch) | |
| tree | 9c1d80b6da18a902b03ba7b21ec6bd0a60aabbfa /server/config_data.py | |
| parent | a83c4bcc40aae7c8b8058d831667ee1e07a969dc (diff) | |
| parent | 98010f591948fb4bf297c1c0c32def42f766edca (diff) | |
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
* 'master' of ssh://git.fedoraproject.org/git/hosted/func: (27 commits)
just a friendly reminder
we are not vf_server, change I!*N domain
Add virt module.
Add test code for virt.
add a very simple, very dumb commandline client:
Remove messages.pot from po dir, since its automatically generated
Get rid of extra / in module loading error
pychecker cleanups
Add po dir to git
Prevent XMLRPC server from printing to console.
Catch FuncException when the config file is missing and exit gracefully
Implement a quickie service control module
Removing VF items + misc cleanup
Clean up some speclint warnings
Baseobj bites the dust.
remove all the --debug "try to run from the src tree" crap
debug spew cleanup to protect the unwashed masses from foo poisoning
fix up config_data to use ConfigParser correctly
attempt to let us run with --debug flag to run from src checkout
attempts at letting us run from a installed, or local modules
...
Diffstat (limited to 'server/config_data.py')
| -rwxr-xr-x | server/config_data.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/server/config_data.py b/server/config_data.py index 9ccca75..7ace8ca 100755 --- a/server/config_data.py +++ b/server/config_data.py @@ -1,11 +1,9 @@ #!/usr/bin/python -# Virt-factory backend code. +# func # # Copyright 2006, Red Hat, Inc -# Michael DeHaan <mdehaan@redhat.com> -# Scott Seago <sseago@redhat.com> -# Adrian Likins <alikins@redhat.com> +# see AUTHORS # # This software may be freely redistributed under the terms of the GNU # general public license. @@ -16,19 +14,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: @@ -38,18 +27,23 @@ class Config: def __init__(self): self.__dict__ = self.__shared_state + self.ds = {} 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("Missing %s" % CONFIG_FILE) + + cp = ConfigParser.ConfigParser() + + cp.read([CONFIG_FILE]) + + 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_server") def get(self): return self.ds |
