commit 0e0900ea014ce48f7fad1a4c8f84e2443526c62b
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Mar 8 16:24:41 2013 +0100
lnst-{ctl, slave}: changes to reflect the Logs change
This commit updates the lnst-ctl and lnst-slave applications to reflect
the change in how we use logging. The created LoggingCtl instance will
be propagated to other modules as a parameter.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst-ctl | 29 ++++++++++++++---------------
lnst-slave | 9 +++++----
2 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index c15e9af..17ce6cd 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -16,7 +16,8 @@ import sys
import logging
import os
import re
-from lnst.Common.Logs import Logs
+import datetime
+from lnst.Common.Logs import LoggingCtl
from lnst.Common.Config import Config
from lnst.Controller.NetTestController import NetTestController, NetTestError
from lnst.Controller.NetTestResultSerializer import NetTestResultSerializer
@@ -41,8 +42,8 @@ def usage():
sys.exit()
def process_recipe(action, file_path, cleanup, res_serializer,
- packet_capture, config):
- nettestctl = NetTestController(file_path, cleanup=cleanup,
+ packet_capture, config, log_ctl):
+ nettestctl = NetTestController(file_path, log_ctl, cleanup=cleanup,
res_serializer=res_serializer, config=config)
if action == "run":
return nettestctl.run_recipe(packet_capture)
@@ -65,14 +66,14 @@ def print_summary(summary):
logging.info("=====================================================")
def get_recipe_result(args, file_path, cleanup,
- res_serializer, packet_capture, config):
+ res_serializer, packet_capture, config, log_ctl):
res_serializer.add_recipe(file_path)
- Logs.set_logging_root_path(file_path)
+ log_ctl.set_recipe(file_path)
res = None
try:
res = process_recipe(args, file_path, cleanup,
- res_serializer, packet_capture, config)
+ res_serializer, packet_capture, config, log_ctl)
except NetTestError as err:
logging.error(err)
@@ -130,7 +131,10 @@ def main():
packet_capture = True
- Logs(debug, log_folder=config.get_option('environment', 'log_dir'))
+ date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
+ log_ctl = LoggingCtl(debug,
+ log_dir=config.get_option('environment',
'log_dir'),
+ log_subdir=date)
if not args:
logging.error("No action command passed")
@@ -141,7 +145,6 @@ def main():
summary = []
res_serializer = NetTestResultSerializer()
- Logs.save_state()
for recipe_path in args:
if os.path.isdir(recipe_path):
all_files = []
@@ -153,23 +156,19 @@ def main():
for f in all_files:
recipe_file = os.path.join(recipe_path, f)
if re.match(r'^.*\.xml$', recipe_file):
- Logs.reset_state()
logging.info("Processing recipe file \"%s\"" %
recipe_file)
summary.append(get_recipe_result(action, recipe_file,
cleanup,
res_serializer,
packet_capture,
- config))
- Logs.set_logging_root_path(clean=False)
+ config, log_ctl))
else:
- Logs.reset_state()
summary.append(get_recipe_result(action, recipe_path,
cleanup, res_serializer,
packet_capture,
- config))
+ config, log_ctl))
- Logs.reset_state()
- Logs.set_logging_root_path(clean=False)
+ log_ctl.set_recipe("", clean=False)
print_summary(summary)
diff --git a/lnst-slave b/lnst-slave
index 2181e42..91f257c 100755
--- a/lnst-slave
+++ b/lnst-slave
@@ -16,7 +16,7 @@ import sys
import os
import logging
from lnst.Common.Daemon import Daemon
-from lnst.Common.Logs import Logs
+from lnst.Common.Logs import LoggingCtl
from lnst.Common.Config import Config
from lnst.Slave.NetTestSlave import NetTestSlave
@@ -72,13 +72,14 @@ def main():
elif opt in ("-p", "--port"):
port = int(arg)
- Logs(debug, True, log_folder=config.get_option('environment',
'log_dir'))
+ log_ctl = LoggingCtl(debug,
+ log_dir=config.get_option('environment',
'log_dir'))
logging.info("Started")
if port:
- nettestslave = NetTestSlave(config, port=port)
+ nettestslave = NetTestSlave(config, log_ctl, port=port)
else:
- nettestslave = NetTestSlave(config)
+ nettestslave = NetTestSlave(config, log_ctl)
if daemon:
daemon = Daemon(pidfile)