commit 80a786dd3e3370bec8d33dacf7d6b531056717f6
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Tue Oct 23 15:55:39 2012 +0200
Config: change in hierarchy of config files
This patch changes the hierarchy by which we load configuration files to
the following:
1. We check for the existence of a configuration file located in the
same directory as the launched binary. This is for cases when the
application is launched from the git version. This configuration file
MUST NOT exist otherwise.
This configuration file has the HIGHEST priority and if it exists other
configuration files will not be loaded. This is to ensure that we can
run the git version and have the packaged version installed at the same
time without unnecessary conflicts.
2. We load the configuration file in /etc/ this should be the
system-wide configuration. We need this file mostly because of the slave
application which will be running as a daemon in the future. For
convention purposes and to not confuse the users this file will exist
even on the controller machines.
This file should be heavily documented and explain the available
options.
3. On the controller we load the configuration file located in the
~/.lnst directory. This can't be done on the slave machines as the slave
application will be running as a daemon and it would make sense to put
its configuration into the home directory of any user.
This patch also changes the names of the configuration files to:
lnst-ctl.conf
lnst-slave.conf
to distinguish the different schemes used in these files.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
nettestctl.py | 8 +++++++-
nettestslave.py | 10 ++++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/nettestctl.py b/nettestctl.py
index 6da53f2..e97733c 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -100,7 +100,13 @@ def main():
sys.exit()
config = Config("controller")
- config.load_config('~/.lnst/lnst.conf')
+ dirname = os.path.dirname(sys.argv[0])
+ gitcfg = os.path.join(dirname, "lnst-ctl.conf")
+ if os.path.isfile(gitcfg):
+ config.load_config(gitcfg)
+ else:
+ config.load_config('/etc/lnst-ctl.conf')
+ config.load_config('~/.lnst/lnst-ctl.conf')
debug = 0
recipe_path = None
diff --git a/nettestslave.py b/nettestslave.py
index 29528ff..c9cb0c9 100755
--- a/nettestslave.py
+++ b/nettestslave.py
@@ -13,10 +13,12 @@ jpirko(a)redhat.com (Jiri Pirko)
import getopt
import sys
+import os
import logging
from NetTest.NetTestSlave import NetTestSlave
from Common.Daemon import Daemon
from Common.Logs import Logs
+from Common.Config import Config
def usage():
"""
@@ -46,6 +48,14 @@ def main():
usage()
sys.exit()
+ config = Config("slave")
+ dirname = os.path.dirname(sys.argv[0])
+ gitcfg = os.path.join(dirname, "lnst-slave.conf")
+ if os.path.isfile(gitcfg):
+ config.load_config(gitcfg)
+ else:
+ config.load_config('/etc/lnst-slave.conf')
+
debug = False
daemon = False
pidfile = "nettestslave.pid"
Show replies by date