From: Ondrej Lichtner olichtne@redhat.com
nettestctl now reads the users configuration file ~/.lnst/lnst.conf
As we agreed, the loaded configs will be distributed as function parameters, therefore I made the necessary changes to functions process_recipe and get_recipe_result.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- Common/Config.py | 5 ----- nettestctl.py | 16 +++++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/Common/Config.py b/Common/Config.py index 8a1ad56..8ef2452 100644 --- a/Common/Config.py +++ b/Common/Config.py @@ -24,12 +24,7 @@ class Config():
def __init__(self): self._parser = ConfigParser(dict_type=dict) - - # defaults.conf should contain all possible sections and options - # sections and options not listed there will be undefined which - # can cause problems self.options = dict() - self.load_config("default.conf")
def get_config(self): return self.options diff --git a/nettestctl.py b/nettestctl.py index de07911..2fab067 100755 --- a/nettestctl.py +++ b/nettestctl.py @@ -21,6 +21,7 @@ from NetTest.NetTestResultSerializer import NetTestResultSerializer from Common.Logs import Logs from Common.LoggingServer import LoggingServer import Common.ProcessManager +from Common.Config import Config
def usage(): """ @@ -45,7 +46,7 @@ def usage(): sys.exit()
def process_recipe(action, file_path, remoteexec, cleanup, - res_serializer, packet_capture): + res_serializer, packet_capture, config): nettestctl = NetTestController(os.path.realpath(file_path), remoteexec=remoteexec, cleanup=cleanup, res_serializer=res_serializer) @@ -70,14 +71,14 @@ def print_summary(summary): logging.info("=====================================================")
def get_recipe_result(args, file_path, remoteexec, cleanup, - res_serializer, packet_capture): + res_serializer, packet_capture, config): res_serializer.add_recipe(file_path) Logs.set_logging_root_path(file_path) loggingServer = LoggingServer(LoggingServer.DEFAULT_PORT, Logs.root_path, Logs.debug) loggingServer.start() res = process_recipe(args, file_path, remoteexec, cleanup, - res_serializer, packet_capture) + res_serializer, packet_capture, config) loggingServer.stop() return ((file_path, res))
@@ -97,6 +98,9 @@ def main(): usage() sys.exit()
+ config = Config() + config.load_config('~/.lnst/lnst.conf') + debug = 0 recipe_path = None remoteexec = False @@ -144,12 +148,14 @@ def main(): summary.append(get_recipe_result(action, recipe_file, remoteexec, cleanup, res_serializer, - packet_capture)) + packet_capture, + config)) Logs.set_logging_root_path(clean=False) else: summary.append(get_recipe_result(action, recipe_path, remoteexec, cleanup, res_serializer, - packet_capture)) + packet_capture, + config))
Logs.set_logging_root_path(clean=False)