Commit 25942a6c authored by Guido Trotter's avatar Guido Trotter
Browse files

Abstract the LUXI eom into a constant

Currently the EOM terminator is hardcoded on the server side, and is
customizable in the Transport object (with the default being the same as
the value found in the server), but not in the luxi client.

With this patch we move the value to constants, and remove the "fake"
customizability, which would just break client/server communication. If
we ever need to have a luxi transport with a different terminator it's
easy enough to add it back.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarIustin Pop <>
parent fbe27e2b
......@@ -147,7 +147,6 @@ class IOServer(SocketServer.UnixStreamServer):
class ClientRqHandler(SocketServer.BaseRequestHandler):
"""Client handler"""
EOM = '\3'
READ_SIZE = 4096
def setup(self):
......@@ -201,7 +200,7 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
data = self.request.recv(self.READ_SIZE)
if not data:
return None
new_msgs = (self._buffer + data).split(self.EOM)
new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
self._buffer = new_msgs.pop()
return self._msgs.popleft()
......@@ -209,7 +208,7 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
def send_message(self, msg):
#print "sending", msg
# TODO: sendall is not guaranteed to send everything
self.request.sendall(msg + self.EOM)
self.request.sendall(msg + constants.LUXI_EOM)
class ClientOps:
......@@ -172,6 +172,9 @@ LOG_BURNIN = LOG_DIR + "burnin.log"
DEV_CONSOLE = "/dev/console"
# luxi related constants
LUXI_EOM = "\3"
# one of 'no', 'yes', 'only'
SYSLOG_NO = "no"
......@@ -323,7 +326,6 @@ INISECT_HYP = "hypervisor"
INISECT_BEP = "backend"
# dynamic device modification
DDM_ADD = 'add'
DDM_REMOVE = 'remove'
......@@ -122,15 +122,12 @@ class Transport:
def __init__(self, address, timeouts=None, eom=None):
def __init__(self, address, timeouts=None):
"""Constructor for the Client class.
- address: a valid address the the used transport class
- timeout: a list of timeouts, to be used on connect and read/write
- eom: an identifier to be used as end-of-message which the
upper-layer will guarantee that this identifier will not appear
in any message
There are two timeouts used since we might want to wait for a long
time for a response, but the connect timeout should be lower.
......@@ -153,11 +150,6 @@ class Transport:
self._buffer = ""
self._msgs = collections.deque()
if eom is None:
self.eom = '\3'
self.eom = eom
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
......@@ -203,12 +195,12 @@ class Transport:
This just sends a message and doesn't wait for the response.
if self.eom in msg:
if constants.LUXI_EOM in msg:
raise EncodingError("Message terminator found in payload")
# TODO: sendall is not guaranteed to send everything
self.socket.sendall(msg + self.eom)
self.socket.sendall(msg + constants.LUXI_EOM)
except socket.timeout, err:
raise TimeoutError("Sending timeout: %s" % str(err))
......@@ -238,7 +230,7 @@ class Transport:
if not data:
raise ConnectionClosedError("Connection closed while reading")
new_msgs = (self._buffer + data).split(self.eom)
new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
self._buffer = new_msgs.pop()
return self._msgs.popleft()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment