commit cdb7baecbbe9435b8689d39e681a22db9a169e8a
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Tue Sep 11 17:41:53 2012 +0200
Logs: integration with config module
Logs are now saved to location specified in the config files by option
'path' in section 'log'.
The port on which the logging server is listening on can now be changed
by option 'port' in the same section.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/Logs.py | 7 +++++--
NetTest/NetTestController.py | 5 +++--
nettestctl.py | 7 ++++---
3 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/Common/Logs.py b/Common/Logs.py
index 0772f1f..bf20e80 100644
--- a/Common/Logs.py
+++ b/Common/Logs.py
@@ -187,7 +187,7 @@ class Logs:
@classmethod
def __init__(cls,debug=0, waitForNet=False, logger=logging.getLogger(),
recipe_path=None, log_root="Logs", to_display=True, date=None,
- nameExtend=None):
+ nameExtend=None, log_folder=None):
logging.addLevelName(5, "DEBUG2")
logging.DEBUG2 = 5
if nameExtend is None:
@@ -200,7 +200,10 @@ class Logs:
':%(lineno)4.4d| %(levelname)s: '
'%(message)s', '%d/%m %H:%M:%S', " "*4)
cls.log_root = log_root
- cls.logFolder = os.path.dirname(sys.argv[0])
+ if log_folder != None:
+ cls.logFolder = log_folder
+ else:
+ cls.logFolder = os.path.dirname(sys.argv[0])
cls.logger = logger
cls.debug = debug
if date is None:
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 01a5f9b..4d04e9c 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -38,11 +38,12 @@ def ignore_event(**kwarg):
class NetTestController:
def __init__(self, recipe_path, remoteexec=False, cleanup=False,
- res_serializer=None):
+ res_serializer=None, config=None):
self._remoteexec = remoteexec
self._docleanup = cleanup
self._res_serializer = res_serializer
self._remote_capture_files = {}
+ self._config = config
self._command_context = NetTestCommandContext()
self._machine_pool = MachinePool([])
@@ -259,7 +260,7 @@ class NetTestController:
logging.info("Setting logging server on machine %s", hostname)
rpc = self._get_machinerpc(machine_id)
ip_addr = get_corespond_local_ip(hostname)
- rpc.set_logging(ip_addr, LoggingServer.DEFAULT_PORT)
+ rpc.set_logging(ip_addr, self._config.get_option('log', 'port'))
def _deconfigure_slaves(self):
for machine_id in self._recipe["machines"]:
diff --git a/nettestctl.py b/nettestctl.py
index 2fab067..bc79398 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -49,7 +49,8 @@ def process_recipe(action, file_path, remoteexec, cleanup,
res_serializer, packet_capture, config):
nettestctl = NetTestController(os.path.realpath(file_path),
remoteexec=remoteexec, cleanup=cleanup,
- res_serializer=res_serializer)
+ res_serializer=res_serializer,
+ config=config)
if action == "run":
return nettestctl.run_recipe(packet_capture)
elif action == "dump":
@@ -74,7 +75,7 @@ def get_recipe_result(args, file_path, remoteexec, cleanup,
res_serializer, packet_capture, config):
res_serializer.add_recipe(file_path)
Logs.set_logging_root_path(file_path)
- loggingServer = LoggingServer(LoggingServer.DEFAULT_PORT,
+ loggingServer = LoggingServer(config.get_option('log', 'port'),
Logs.root_path, Logs.debug)
loggingServer.start()
res = process_recipe(args, file_path, remoteexec, cleanup,
@@ -122,7 +123,7 @@ def main():
packet_capture = True
- Logs(debug)
+ Logs(debug, log_folder=config.get_option('log', 'path'))
if not args:
logging.error("No action command passed")