[lnst] NetTestResultSerializer: add error messages to recipe results
by Jiří Pírko
commit 164711a6e5a92d40b6f0e43cc0ad3b9b96d08c7d
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 14 09:50:06 2013 +0200
NetTestResultSerializer: add error messages to recipe results
This commit extends result reporting of the run_recipe method in
NetTestController to report not only the result of the command but also
add an error message if the recipe failed. To reflect this
NetTestResultSerializer now uses that information to create an
additional xml node and the error message will appear in the result
summary.
The reason is that when the recipe failed during configuration there
would be no information in the result summary indicating what happend
only a that the recipe failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 4 +++-
lnst/Controller/NetTestController.py | 23 +++++++++++++++--------
lnst/Controller/NetTestResultSerializer.py | 17 ++++++++++++++++-
3 files changed, 34 insertions(+), 10 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 7dcace6..39bb5cf 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -67,13 +67,15 @@ def get_recipe_result(args, file_path, cleanup, res_serializer, packet_capture,
res_serializer.add_recipe(file_path)
log_ctl.set_recipe(file_path)
- res = None
+ res = {}
try:
res = process_recipe(args, file_path, cleanup, res_serializer,
packet_capture, log_ctl, pool_checks)
except Exception as err:
log_exc_traceback()
logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
res_serializer.set_recipe_result(res)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 27d2368..a90a3dc 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -395,22 +395,27 @@ class NetTestController:
self._prepare_network()
pprint(self._recipe)
self._cleanup_slaves()
- return True
+ return {"passed": True}
def match_setup(self):
mreq = self._get_machine_requirements()
self._prepare_provisioning(mreq)
- return True
+ return {"passed": True}
def config_only_recipe(self):
self._prepare_network()
self._cleanup_slaves(deconfigure=False)
- return True
+ return {"passed": True}
def run_recipe(self, packet_capture=False):
- self._prepare_network()
- self._prepare_tasks()
+ try:
+ self._prepare_network()
+ self._prepare_tasks()
+ except Exception as exc:
+ msg = "Exception raised during configuration."
+ logging.error(msg)
+ raise
if packet_capture:
self._start_packet_capture()
@@ -430,7 +435,7 @@ class NetTestController:
return res
def _run_recipe(self):
- overall_res = True
+ overall_res = {"passed": True}
for task in self._tasks:
try:
@@ -442,7 +447,8 @@ class NetTestController:
except CommandException as exc:
logging.debug(exc)
- overall_res = False
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "Command exception raised."
break
for machine in self._machines.itervalues():
@@ -450,7 +456,8 @@ class NetTestController:
# task failed, check if we should quit_on_fail
if not res:
- overall_res = False
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "At least one command failed."
if task["quit_on_fail"]:
break
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index b260bf0..ffb5ab4 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -62,10 +62,15 @@ class NetTestResultSerializer:
self._cur_cmd_seq_el = None
def set_recipe_result(self, result):
- if result:
+ if result and result["passed"]:
self._cur_recipe_el.setAttribute("result", "PASS")
else:
self._cur_recipe_el.setAttribute("result", "FAIL")
+ if "err_msg" in result:
+ err_el = self._dom.createElement("error_message")
+ err_text = self._dom.createTextNode(result["err_msg"])
+ err_el.appendChild(err_text)
+ self._cur_recipe_el.appendChild(err_el)
def add_task(self):
cmd_seq_el = self._dom.createElement("command_sequence")
@@ -109,6 +114,16 @@ class NetTestResultSerializer:
recipe_res = recipe.getAttribute("result")
output_pairs.append((recipe_name, recipe_res))
+ if recipe_res == "FAIL":
+ err_node = None
+ for child in recipe.childNodes:
+ if child.nodeName == "error_message":
+ err_node = child
+ break
+ if err_node:
+ text = get_node_val(err_node)
+ output_pairs.append((4*" "+"error message: "+text, ""))
+
seq_num = 1
for cmd_seq in recipe.getElementsByTagName("command_sequence"):
command_sequence = 4*" "+"cmd_seq: %s" % seq_num
10 years, 7 months
[lnst] TestIcmpPing: add option to specify source interface
by Jiří Pírko
commit 53f0364a141a6a95ddd279ac36c9025fe89f7987
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 14 09:50:05 2013 +0200
TestIcmpPing: add option to specify source interface
This commit adds a test option 'iface' to the IcmpPing test module, that
translates to the -I argument of the ping utility. This option was
already present for the Icmp6Ping module, so I added it here as well.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_modules/TestIcmpPing.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/test_modules/TestIcmpPing.py b/test_modules/TestIcmpPing.py
index 73a9bd5..e2c239a 100644
--- a/test_modules/TestIcmpPing.py
+++ b/test_modules/TestIcmpPing.py
@@ -25,6 +25,9 @@ class TestIcmpPing(TestGeneric):
interval = self.get_opt("interval")
if interval:
cmd += " -i %s" % interval
+ iface = self.get_opt("iface")
+ if iface:
+ cmd += " -I %s" % iface
return cmd
def run(self):
10 years, 7 months
[lnst] tcp_conn: add initialization of sigaction variables
by Jiří Pírko
commit ae96cc03dc035ed9e4af77b29d5ec0f51c71c729
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 14 09:50:04 2013 +0200
tcp_conn: add initialization of sigaction variables
Without the initialization these variables sometimes contain garbage
data in the .sa_flags field, that makes the signal handling be reset
after recieving the specified signal once. This results in the parent
process being killed by a child process.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
test_tools/tcp_conn/tcp_connect.c | 2 ++
test_tools/tcp_conn/tcp_listen.c | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/test_tools/tcp_conn/tcp_connect.c b/test_tools/tcp_conn/tcp_connect.c
index 598ac80..cb6b8c4 100644
--- a/test_tools/tcp_conn/tcp_connect.c
+++ b/test_tools/tcp_conn/tcp_connect.c
@@ -127,6 +127,8 @@ int main(int argc, char **argv)
char *delimiter;
struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+
sa.sa_handler = &terminate_connections;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
diff --git a/test_tools/tcp_conn/tcp_listen.c b/test_tools/tcp_conn/tcp_listen.c
index df07f69..ef5eeb2 100644
--- a/test_tools/tcp_conn/tcp_listen.c
+++ b/test_tools/tcp_conn/tcp_listen.c
@@ -145,6 +145,9 @@ int main(int argc, char **argv)
struct sigaction sa;
struct sigaction sa2;
+ memset(&sa, 0, sizeof(sa));
+ memset(&sa2, 0, sizeof(sa2));
+
sa.sa_handler = &terminate_connections;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
10 years, 7 months
[PATCH 0/6] mixed patch series
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The first 5 patches were already sent to the mailing list before, as individual
patches. I'm resending this as a patchset now because I changed a single commit
in the middle of the series, and I think it would look weird to send a v2 for
just that one.
Additionaly the last commit fixes the config_only bug that I've introduced.
Ondrej Lichtner (6):
tcp_conn: add initialization of sigaction variables
TestIcmpPing: add option to specify source interface
NetTestResultSerializer: add error messages to recipe results
NetTestSlave: update of slave cleanup
NetTestController: add detection of slave disconnect
NetTestSlave: ctl disconnect cleanup fix
lnst-ctl | 4 +++-
lnst/Common/NetTestCommand.py | 1 +
lnst/Controller/Machine.py | 4 ++++
lnst/Controller/NetTestController.py | 35 ++++++++++++++++++++-------
lnst/Controller/NetTestResultSerializer.py | 17 ++++++++++++-
lnst/Slave/NetConfig.py | 1 +
lnst/Slave/NetConfigDevice.py | 1 +
lnst/Slave/NetTestSlave.py | 38 +++++++++++++++---------------
test_modules/TestIcmpPing.py | 3 +++
test_tools/tcp_conn/tcp_connect.c | 2 ++
test_tools/tcp_conn/tcp_listen.c | 3 +++
11 files changed, 80 insertions(+), 29 deletions(-)
--
1.8.3.1
10 years, 7 months
[PATCH] NetTestController: add detection of slave disconnect
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds detection of slaves being disconnected while the
controller is waiting for a response.
When this happens an Exception is raised resulting in the recipe failing
and remaining slaves being deconfigured.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 4 ++++
lnst/Controller/NetTestController.py | 12 ++++++++++++
2 files changed, 16 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 76e35b5..5876347 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -148,6 +148,10 @@ class Machine(object):
if not self._configured:
return
+ #connection to the slave was closed
+ if not self._msg_dispatcher.get_connection(self._id):
+ return
+
self._rpc_call("kill_cmds")
if deconfigure:
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index cd00081..cd80e8b 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -612,7 +612,12 @@ class MessageDispatcher(ConnectionHandler):
def wait_for_result(self, machine_id):
wait = True
while wait:
+ connected_slaves = self._connections.keys()
+
messages = self.check_connections()
+
+ remaining_slaves = self._connections.keys()
+
for msg in messages:
if msg[1]["type"] == "result" and msg[0] == machine_id:
wait = False
@@ -620,6 +625,13 @@ class MessageDispatcher(ConnectionHandler):
else:
self._process_message(msg)
+ if connected_slaves != remaining_slaves:
+ disconnected_slaves = set(connected_slaves) -\
+ set(remaining_slaves)
+ msg = "Slaves " + str(list(disconnected_slaves)) + \
+ " disconnected from the controller."
+ raise NetTestError(msg)
+
return result
def _process_message(self, message):
--
1.8.3.1
10 years, 7 months
[PATCH] NetTestSlave: update of slave cleanup
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
I didn't notice this before but we already had a method that did slave
cleanup. This commit makes a slight modification to the function and
makes use of it instead of calling the individual cleanup methods
themselves.
The cleanup process is now logged in DEBUG level, and I added detection
of server startup so that no cleanup happens when we didn't do anything
yet.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 1 +
lnst/Slave/NetConfig.py | 1 +
lnst/Slave/NetConfigDevice.py | 1 +
lnst/Slave/NetTestSlave.py | 33 ++++++++++++++-------------------
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index d246795..0c663dc 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -220,6 +220,7 @@ class NetTestCommandContext:
self._dict[id].kill()
def cleanup(self):
+ logging.debug("Cleaning up leftover processes.")
self._kill_all_cmds()
self._dict = {}
diff --git a/lnst/Slave/NetConfig.py b/lnst/Slave/NetConfig.py
index cbb8487..f622848 100644
--- a/lnst/Slave/NetConfig.py
+++ b/lnst/Slave/NetConfig.py
@@ -104,6 +104,7 @@ class NetConfig:
device.deconfigure()
def deconfigure_all(self):
+ logging.debug("Deconfiguring interfaces.")
dev_order = self._get_dev_order()
for dev_id in reversed(dev_order):
self.deconfigure(dev_id)
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index 91dce5e..53e89b2 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -313,6 +313,7 @@ def NetConfigDeviceType(netdev, config):
return type_class_mapping[netdev["type"]]
def NetConfigDeviceAllCleanup():
+ logging.debug("Performing interface type cleanup.")
if check_process_running("NetworkManager") and \
lnst_config.get_option("environment", "use_nm"):
for dev_type in nm_type_class_mapping:
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index a3d7e66..629ed88 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -45,9 +45,9 @@ class SlaveMethods:
'''
Exported xmlrpc methods
'''
- def __init__(self, command_context, netconfig, log_ctl):
+ def __init__(self, command_context, log_ctl):
self._packet_captures = {}
- self._netconfig = netconfig
+ self._netconfig = NetConfig()
self._command_context = command_context
self._log_ctl = log_ctl
@@ -263,9 +263,11 @@ class SlaveMethods:
return True
def machine_cleanup(self):
- NetConfigDeviceAllCleanup()
- self._netconfig.cleanup()
+ logging.info("Performing machine cleanup.")
self._command_context.cleanup()
+ self._netconfig.deconfigure_all()
+ self._netconfig.cleanup()
+ NetConfigDeviceAllCleanup()
self._cache.del_old_entries()
self.restore_system_config()
return True
@@ -415,9 +417,7 @@ class NetTestSlave:
die_when_parent_die()
self._cmd_context = NetTestCommandContext()
- self._netconfig = NetConfig()
- self._methods = SlaveMethods(self._cmd_context, self._netconfig,
- log_ctl)
+ self._methods = SlaveMethods(self._cmd_context, log_ctl)
self.register_die_signal(signal.SIGHUP)
self.register_die_signal(signal.SIGINT)
@@ -429,21 +429,20 @@ class NetTestSlave:
self._log_ctl = log_ctl
+ self._start = True
+
def run(self):
while not self._finished:
if self._server_handler.get_ctl_sock() == None:
self._log_ctl.cancel_connection()
- logging.info("Waiting for connection, performing cleanup.")
- logging.info("Cleaning up leftover commands.")
- self._cmd_context.cleanup()
- logging.info("Cleaning up configured interfaces.")
- self._netconfig.deconfigure_all()
- self._netconfig.cleanup()
+ if not self._start:
+ self._methods.machine_cleanup()
try:
+ logging.info("Waiting for connection.")
self._server_handler.accept_connection()
+ self._start = False
except socket.error:
continue
- self._cmd_context.cleanup()
self._log_ctl.set_connection(
self._server_handler.get_ctl_sock())
@@ -452,11 +451,7 @@ class NetTestSlave:
for msg in msgs:
self._process_msg(msg[1])
- logging.info("Cleaning up leftover commands.")
- self._cmd_context.cleanup()
- logging.info("Cleaning up configured interfaces.")
- self._netconfig.deconfigure_all()
- self._netconfig.cleanup()
+ self._methods.machine_cleanup()
def _process_msg(self, msg):
if msg["type"] == "command":
--
1.8.3.1
10 years, 7 months
[PATCH] NetTestResultSerializer: add error messages to recipe results
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit extends result reporting of the run_recipe method in
NetTestController to report not only the result of the command but also
add an error message if the recipe failed. To reflect this
NetTestResultSerializer now uses that information to create an
additional xml node and the error message will appear in the result
summary.
The reason is that when the recipe failed during configuration there
would be no information in the result summary indicating what happend
only a that the recipe failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 4 +++-
lnst/Controller/NetTestController.py | 17 ++++++++++++-----
lnst/Controller/NetTestResultSerializer.py | 17 ++++++++++++++++-
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 97039ed..7705f9c 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -67,13 +67,15 @@ def get_recipe_result(args, file_path, cleanup, res_serializer, packet_capture,
res_serializer.add_recipe(file_path)
log_ctl.set_recipe(file_path)
- res = None
+ res = {}
try:
res = process_recipe(args, file_path, cleanup, res_serializer,
packet_capture, log_ctl, pool_checks)
except Exception as err:
log_exc_traceback()
logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
res_serializer.set_recipe_result(res)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 27d2368..cd00081 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -409,8 +409,13 @@ class NetTestController:
return True
def run_recipe(self, packet_capture=False):
- self._prepare_network()
- self._prepare_tasks()
+ try:
+ self._prepare_network()
+ self._prepare_tasks()
+ except Exception as exc:
+ msg = "Exception raised during configuration."
+ logging.error(msg)
+ raise
if packet_capture:
self._start_packet_capture()
@@ -430,7 +435,7 @@ class NetTestController:
return res
def _run_recipe(self):
- overall_res = True
+ overall_res = {"passed": True}
for task in self._tasks:
try:
@@ -442,7 +447,8 @@ class NetTestController:
except CommandException as exc:
logging.debug(exc)
- overall_res = False
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "Command exception raised."
break
for machine in self._machines.itervalues():
@@ -450,7 +456,8 @@ class NetTestController:
# task failed, check if we should quit_on_fail
if not res:
- overall_res = False
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "At least one command failed."
if task["quit_on_fail"]:
break
diff --git a/lnst/Controller/NetTestResultSerializer.py b/lnst/Controller/NetTestResultSerializer.py
index b260bf0..ffb5ab4 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -62,10 +62,15 @@ class NetTestResultSerializer:
self._cur_cmd_seq_el = None
def set_recipe_result(self, result):
- if result:
+ if result and result["passed"]:
self._cur_recipe_el.setAttribute("result", "PASS")
else:
self._cur_recipe_el.setAttribute("result", "FAIL")
+ if "err_msg" in result:
+ err_el = self._dom.createElement("error_message")
+ err_text = self._dom.createTextNode(result["err_msg"])
+ err_el.appendChild(err_text)
+ self._cur_recipe_el.appendChild(err_el)
def add_task(self):
cmd_seq_el = self._dom.createElement("command_sequence")
@@ -109,6 +114,16 @@ class NetTestResultSerializer:
recipe_res = recipe.getAttribute("result")
output_pairs.append((recipe_name, recipe_res))
+ if recipe_res == "FAIL":
+ err_node = None
+ for child in recipe.childNodes:
+ if child.nodeName == "error_message":
+ err_node = child
+ break
+ if err_node:
+ text = get_node_val(err_node)
+ output_pairs.append((4*" "+"error message: "+text, ""))
+
seq_num = 1
for cmd_seq in recipe.getElementsByTagName("command_sequence"):
command_sequence = 4*" "+"cmd_seq: %s" % seq_num
--
1.8.3.1
10 years, 7 months
[PATCH] TestIcmpPing: add option to specify source interface
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds a test option 'iface' to the IcmpPing test module, that
translates to the -I argument of the ping utility. This option was
already present for the Icmp6Ping module, so I added it here as well.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
test_modules/TestIcmpPing.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test_modules/TestIcmpPing.py b/test_modules/TestIcmpPing.py
index 73a9bd5..e2c239a 100644
--- a/test_modules/TestIcmpPing.py
+++ b/test_modules/TestIcmpPing.py
@@ -25,6 +25,9 @@ class TestIcmpPing(TestGeneric):
interval = self.get_opt("interval")
if interval:
cmd += " -i %s" % interval
+ iface = self.get_opt("iface")
+ if iface:
+ cmd += " -I %s" % iface
return cmd
def run(self):
--
1.8.3.1
10 years, 7 months
[PATCH] tcp_conn: add initialization of sigaction variables
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Without the initialization these variables sometimes contain garbage
data in the .sa_flags field, that makes the signal handling be reset
after recieving the specified signal once. This results in the parent
process being killed by a child process.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
test_tools/tcp_conn/tcp_connect.c | 2 ++
test_tools/tcp_conn/tcp_listen.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/test_tools/tcp_conn/tcp_connect.c b/test_tools/tcp_conn/tcp_connect.c
index 598ac80..cb6b8c4 100644
--- a/test_tools/tcp_conn/tcp_connect.c
+++ b/test_tools/tcp_conn/tcp_connect.c
@@ -127,6 +127,8 @@ int main(int argc, char **argv)
char *delimiter;
struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+
sa.sa_handler = &terminate_connections;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
diff --git a/test_tools/tcp_conn/tcp_listen.c b/test_tools/tcp_conn/tcp_listen.c
index df07f69..ef5eeb2 100644
--- a/test_tools/tcp_conn/tcp_listen.c
+++ b/test_tools/tcp_conn/tcp_listen.c
@@ -145,6 +145,9 @@ int main(int argc, char **argv)
struct sigaction sa;
struct sigaction sa2;
+ memset(&sa, 0, sizeof(sa));
+ memset(&sa2, 0, sizeof(sa2));
+
sa.sa_handler = &terminate_connections;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
--
1.8.3.1
10 years, 7 months
[lnst] colours: Fixing multiple bugs with colours
by Jiří Pírko
commit d8b00223ce17cc4ebd507be2ba56a9673e7b9f87
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Thu Aug 8 11:04:01 2013 +0200
colours: Fixing multiple bugs with colours
The default values written to the config were wrong and made the
controller crash on the next invocation.
Another problem was in lnst-slave. The slave script didn't load the
colour configuration from the conf file properly.
Both of them should be fixed now.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 2 +-
lnst-slave | 3 +++
lnst/Common/Colours.py | 7 +++++--
lnst/Common/Config.py | 18 +++++++++---------
4 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 97039ed..7dcace6 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -135,7 +135,7 @@ def main():
elif opt in ("-m", "--no-colours"):
coloured_output = False
- load_presets_from_config()
+ load_presets_from_config(lnst_config)
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
log_ctl = LoggingCtl(debug,
diff --git a/lnst-slave b/lnst-slave
index 1e7dee8..ce6c390 100755
--- a/lnst-slave
+++ b/lnst-slave
@@ -18,6 +18,7 @@ import logging
from lnst.Common.Daemon import Daemon
from lnst.Common.Logs import LoggingCtl
from lnst.Common.Config import lnst_config
+from lnst.Common.Colours import load_presets_from_config
from lnst.Slave.NetTestSlave import NetTestSlave
def usage():
@@ -76,6 +77,8 @@ def main():
elif opt in ("-m", "--no-colours"):
coloured_output = False
+ load_presets_from_config(lnst_config)
+
log_ctl = LoggingCtl(debug,
log_dir=lnst_config.get_option('environment', 'log_dir'),
colours=coloured_output)
diff --git a/lnst/Common/Colours.py b/lnst/Common/Colours.py
index c88bf5d..1b72d58 100644
--- a/lnst/Common/Colours.py
+++ b/lnst/Common/Colours.py
@@ -14,7 +14,6 @@ import logging
import os
import re
from lnst.Common.Utils import bool_it
-from lnst.Common.Config import lnst_config
COLOURS = {
"black": 30,
@@ -166,7 +165,11 @@ def decorate_with_preset(string, preset):
def strip_colours(text):
return re.sub("\033\[[0-9]+(;[0-9]+){0,2}m", "", text)
-def load_presets_from_config():
+def get_preset_conf(preset_name):
+ preset = PRESETS[preset_name]
+ return map(lambda s: "default" if s == None else str(s), preset)
+
+def load_presets_from_config(lnst_config):
for preset_name in PRESETS:
preset = lnst_config.get_option("colours", preset_name)
if preset == None:
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 2a74c25..67921d4 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -17,6 +17,7 @@ import re
from ConfigParser import ConfigParser
from lnst.Common.Utils import bool_it
from lnst.Common.NetUtils import verify_ip_address, verify_mac_address
+from lnst.Common.Colours import get_preset_conf
DefaultRPCPort = 9999
@@ -98,16 +99,15 @@ class Config():
def colours_scheme(self):
self.options['colours'] = dict()
- for preset in ["default", "faded", "alert", "highlight",
- "pass", "fail", "error", "info", "debug", "warning",
- "log_header"]:
- self.options['colours'][preset] = {\
- "value" : None, "additive" : False,
- "action" : self.optionColour, "name" : preset}
-
self.options['colours']["disable_colours"] = {\
- "value" : False, "additive" : False,
- "action" : self.optionBool, "name" : "disable_colours"}
+ "value": False, "additive": False,
+ "action": self.optionBool, "name": "disable_colours"}
+
+ for preset in ["faded", "alert", "highlight", "pass", "fail", "error",
+ "info", "debug", "warning", "log_header"]:
+ self.options['colours'][preset] = {\
+ "value": get_preset_conf(preset), "additive": False,
+ "action": self.optionColour, "name": preset}
def get_config(self):
return self.options
10 years, 7 months