Do not emit raw binary data after unconfirmed open 57/36057/2
authorJozef Behran <jbehran@cisco.com>
Thu, 10 Mar 2016 15:56:10 +0000 (16:56 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Mar 2016 16:05:09 +0000 (16:05 +0000)
When the OPEN message generated by the player is rejected,
the original code emitted raw binary data in the resulting
exception. Change that so it emits the hexlified version of
the raw binary data. The fix was done by removing the
duplicated code that generates the two error messages (one
for the log file, the other for the exception), taking the
correct code only.

Change-Id: If1ac202ba0d3c8720c8c442da1d533143dcddb7c
Signed-off-by: Jozef Behran <jbehran@cisco.com>
tools/fastbgp/play.py

index f63155fcf25975d9a5da8c6527f7e64650bbd8bd..2342224a3ca76b0befbbeed771e5f6017c590583 100755 (executable)
@@ -1645,10 +1645,12 @@ def job(arguments):
     # Using exact keepalive length to not to see possible updates.
     msg_in = bgp_socket.recv(19)
     if msg_in != generator.keepalive_message():
-        logger.error("Open not confirmed by keepalive, instead got " +
-                     binascii.hexlify(msg_in))
-        raise MessageError("Open not confirmed by keepalive, instead got",
-                           msg_in)
+        error_msg = (
+            "Open not confirmed by keepalive, instead got " +
+            binascii.hexlify(msg_in)
+        )
+        logger.error(error_msg)
+        raise MessageError(error_msg)
     timer.reset_peer_hold_time()
     # Send the keepalive to indicate the connection is accepted.
     timer.snapshot()  # Remember this time.