[PATCH] NetTestController: handling of error messages

Jiri Pirko jpirko at redhat.com
Fri May 3 09:23:48 UTC 2013


Applied, thanks Ondrej.

Fri, Apr 26, 2013 at 01:44:31PM CEST, olichtne at redhat.com wrote:
>From: Ondrej Lichtner <olichtne at redhat.com>
>
>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 deletion(-)
>
>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()
>-- 
>1.7.11.7
>
>_______________________________________________
>LNST-developers mailing list
>LNST-developers at lists.fedorahosted.org
>https://lists.fedorahosted.org/mailman/listinfo/lnst-developers


More information about the LNST-developers mailing list