[lnst] NetTestController: handling of error messages

Jiří Pírko jirka at fedoraproject.org
Fri May 3 09:24:40 UTC 2013


commit 22fe53d1e75c41f39220c0282b1ba71accae291e
Author: Ondrej Lichtner <olichtne at redhat.com>
Date:   Fri Apr 26 13:44:31 2013 +0200

    NetTestController: handling of error messages
    
    The communication protocol that was implemented can also send error
    messages, however the Controller wasn't handling them and instead raised
    an Unknown message exception. This patch fixes that by raising an
    exception with the correct message.
    
    I also modified the message that Slave sends when an unsupported method
    call is recieved.
    
    Signed-off-by: Ondrej Lichtner <olichtne at redhat.com>

 lnst/Controller/NetTestController.py |    4 ++++
 lnst/Slave/NetTestSlave.py           |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 62600ca..169f0af 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -394,6 +394,10 @@ class MessageDispatcher(ConnectionHandler):
         elif message[1]["type"] == "exception":
             msg = "Recieved an exception from slave: %s" % message[0]
             raise CommandException(msg)
+        elif message[1]["type"] == "error":
+            msg = "Recieved an error message from slave %s: %s" %\
+                    (message[0], message[1]["err"])
+            raise CommandException(msg)
         else:
             msg = "Unknown message type: %s" % message[1]["type"]
             raise NetTestError(msg)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 2b0def5..9b39c0a 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -437,7 +437,7 @@ class NetTestSlave:
                         self._cmd_context.cleanup()
                         self._log_ctl.cancel_connection()
             else:
-                err = "Method not found: %s" % msg["method_name"]
+                err = "Method '%s' not supported." % msg["method_name"]
                 response = {"type": "error", "err": err}
                 if not self._server_handler.send_data_to_ctl(response):
                     self._cmd_context.cleanup()


More information about the LNST-developers mailing list