[lnst] NetTestSlave: fix restoration of system configuration

Jiří Pírko jirka at fedoraproject.org
Fri May 31 11:33:49 UTC 2013


commit 16534640eaca8133cb6201672049cf9d040fb7d1
Author: Ondrej Lichtner <olichtne at redhat.com>
Date:   Fri May 31 13:15:41 2013 +0200

    NetTestSlave: fix restoration of system configuration
    
    When the NetTestController code was refactored and several methods were
    moved to the new class Machine, part of the code of run_command was
    forgotten.
    
    The system configuration data was moved to be stored in the slave
    application, however for that the method _update_system_config has to be
    called and that wasn't happening.
    
    This commit fixes that. The fix also changes the behaviour of the
    system_config command- it will not be running in the background anymore,
    instead it is run in the main lnst-slave application, just like the
    wait/intr/kill commands.
    
    Signed-off-by: Ondrej Lichtner <olichtne at redhat.com>
    Signed-off-by: Jiri Pirko <jiri at resnulli.us>

 lnst/Common/NetTestCommand.py |    5 +++--
 lnst/Slave/NetTestSlave.py    |   11 +++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 527764e..8dc9562 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -80,7 +80,8 @@ class NetTestCommand:
         return self._finished
 
     def run(self):
-        if isinstance(self._cmd_cls, NetTestCommandControl):
+        if isinstance(self._cmd_cls, NetTestCommandControl) or \
+           isinstance(self._cmd_cls, NetTestCommandSystemConfig):
             return self._cmd_cls.run()
 
         self._read_pipe, self._write_pipe = multiprocessing.Pipe()
@@ -321,7 +322,7 @@ class NetTestCommandSystemConfig(NetTestCommandGeneric):
 
         res = {"passed": True}
         res["res_data"] = res_data
-        self.set_result(res)
+        return res
 
 class NetTestCommandControl(NetTestCommandGeneric):
     def __init__(self, command_context, command):
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 9b39c0a..d2dd484 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -207,6 +207,7 @@ class SlaveMethods:
                 logging.warn("Unable to restore '%s' config option!", option)
                 return False
 
+        self._system_config = {}
         return True
 
     def run_command(self, command):
@@ -218,6 +219,16 @@ class SlaveMethods:
             res = cmd.run()
             if not cmd.forked():
                 self._command_context.del_cmd(cmd)
+
+            if command["type"] == "system_config":
+                if res["passed"]:
+                    self._update_system_config(res["res_data"]["options"],
+                                               command["persistent"])
+                else:
+                    err = "Error occured while setting system "\
+                          "configuration (%s)" % res["err_msg"]
+                    logging.error(err)
+
             return res
         except:
             log_exc_traceback()


More information about the LNST-developers mailing list