commit ab32ea9906ee8ab4752b8c661969c1a26c088b4e
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Tue Mar 11 18:41:56 2014 +0100
fix incorrect handling of config command failure
The patch fixes an unhandled exception in case a config command fails.
Instead of overwriting res_data we have to append to it since other keys
are expected to be there, even empty. Further, NetTestSlave expects that
run() method returns a result that's referenced later. I've also changed
"msg" key to "err_msg" since the latter is used in NetTestSlave.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 10 ++++------
lnst/Slave/NetTestSlave.py | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 5b12221..abfa71a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -411,18 +411,16 @@ class NetTestCommandConfig(NetTestCommandGeneric):
option_abspath[0:6] != "/proc/":
err = "Wrong config option %s. Only /proc or /sys paths are "
\
"allowed." % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
try:
prev_val = self._retrive_option(option)
self._set_option(option, value)
except ExecCmdFail:
err = "Unable to set %s config option!" % option
- res_data = {"msg": err}
- self.set_fail(res_data)
- return
+ res_data["err_msg"] = err
+ return self.set_fail(res_data)
if "persistent" in self._command:
res_data["persistent"] = self._command["persistent"]
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index dca0a59..ef9e6ad 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -239,7 +239,7 @@ class SlaveMethods:
command["persistent"])
else:
err = "Error occured while setting system "\
- "configuration (%s)" % res["err_msg"]
+ "configuration (%s)" %
res["res_data"]["err_msg"]
logging.error(err)
return res