Revision 25942a6c

b/daemons/ganeti-masterd
147 147

  
148 148
class ClientRqHandler(SocketServer.BaseRequestHandler):
149 149
  """Client handler"""
150
  EOM = '\3'
151 150
  READ_SIZE = 4096
152 151

  
153 152
  def setup(self):
......
201 200
      data = self.request.recv(self.READ_SIZE)
202 201
      if not data:
203 202
        return None
204
      new_msgs = (self._buffer + data).split(self.EOM)
203
      new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
205 204
      self._buffer = new_msgs.pop()
206 205
      self._msgs.extend(new_msgs)
207 206
    return self._msgs.popleft()
......
209 208
  def send_message(self, msg):
210 209
    #print "sending", msg
211 210
    # TODO: sendall is not guaranteed to send everything
212
    self.request.sendall(msg + self.EOM)
211
    self.request.sendall(msg + constants.LUXI_EOM)
213 212

  
214 213

  
215 214
class ClientOps:
b/lib/constants.py
172 172

  
173 173
DEV_CONSOLE = "/dev/console"
174 174

  
175
# luxi related constants
176
LUXI_EOM = "\3"
177

  
175 178
# one of 'no', 'yes', 'only'
176 179
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
177 180
SYSLOG_NO = "no"
......
323 326
INISECT_BEP = "backend"
324 327

  
325 328
# dynamic device modification
326

  
327 329
DDM_ADD = 'add'
328 330
DDM_REMOVE = 'remove'
329 331

  
b/lib/luxi.py
122 122

  
123 123
  """
124 124

  
125
  def __init__(self, address, timeouts=None, eom=None):
125
  def __init__(self, address, timeouts=None):
126 126
    """Constructor for the Client class.
127 127

  
128 128
    Arguments:
129 129
      - address: a valid address the the used transport class
130 130
      - timeout: a list of timeouts, to be used on connect and read/write
131
      - eom: an identifier to be used as end-of-message which the
132
        upper-layer will guarantee that this identifier will not appear
133
        in any message
134 131

  
135 132
    There are two timeouts used since we might want to wait for a long
136 133
    time for a response, but the connect timeout should be lower.
......
153 150
    self._buffer = ""
154 151
    self._msgs = collections.deque()
155 152

  
156
    if eom is None:
157
      self.eom = '\3'
158
    else:
159
      self.eom = eom
160

  
161 153
    try:
162 154
      self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
163 155

  
......
203 195
    This just sends a message and doesn't wait for the response.
204 196

  
205 197
    """
206
    if self.eom in msg:
198
    if constants.LUXI_EOM in msg:
207 199
      raise EncodingError("Message terminator found in payload")
208 200
    self._CheckSocket()
209 201
    try:
210 202
      # TODO: sendall is not guaranteed to send everything
211
      self.socket.sendall(msg + self.eom)
203
      self.socket.sendall(msg + constants.LUXI_EOM)
212 204
    except socket.timeout, err:
213 205
      raise TimeoutError("Sending timeout: %s" % str(err))
214 206

  
......
238 230
        break
239 231
      if not data:
240 232
        raise ConnectionClosedError("Connection closed while reading")
241
      new_msgs = (self._buffer + data).split(self.eom)
233
      new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
242 234
      self._buffer = new_msgs.pop()
243 235
      self._msgs.extend(new_msgs)
244 236
    return self._msgs.popleft()

Also available in: Unified diff