diff --git a/confluent/consoleserver.py b/confluent/consoleserver.py index 88086b3e..25f0d56b 100644 --- a/confluent/consoleserver.py +++ b/confluent/consoleserver.py @@ -103,10 +103,16 @@ class _ConsoleHandler(object): def _got_connected(self): self.connectstate = 'connected' + self.logger.log( + logdata='console connected', ltype=log.DataTypes.event, + event=log.Events.consoleconnect) self._send_rcpts({'connectstate': self.connectstate}) def _got_disconnected(self): self.connecstate = 'unconnected' + self.logger.log( + logdata='console disconnected', ltype=log.DataTypes.event, + event=log.Events.consoledisconnect) self._send_rcpts({'connectstate': self.connectstate}) self._connect() @@ -216,7 +222,7 @@ class _ConsoleHandler(object): 'clientcount': self.clientcount, } retdata = '' - if self.shiftin is not None: #detected that terminal requested a + if self.shiftin is not None: # detected that terminal requested a #shiftin character set, relay that to the terminal that cannected retdata += '\x1b)' + self.shiftin if self.appmodedetected: @@ -254,6 +260,8 @@ def connect_node(node, configmanager): #holding the caller specific queue data, for example, when http api should be #sending data, but there is no outstanding POST request to hold it, # this object has the job of holding the data + + class ConsoleSession(object): """Create a new socket to converse with node console @@ -282,7 +290,7 @@ class ConsoleSession(object): self.databuffer.extend(_handled_consoles[consk].get_recent()) else: self.reghdl = _handled_consoles[consk].register_rcpt(datacallback) - for recdata in _handled_consoles[consk].get_recent(): + for recdata in _handled_consoles[consk].get_recent(): if recdata: datacallback(recdata) @@ -330,46 +338,3 @@ class ConsoleSession(object): # they are given up on self.reaper = eventlet.spawn_after(15, self.destroy) return retval - - -def handle_request(request=None, connection=None, releaseconnection=False): - """ - Process a request from confluent. - - :param request: For 'datagram' style console, this represents a wait for - data or input. - :param connection: For socket style console, this is a read/write socket - that the caller has released from it's control and - console plugin will do all IO - :param releaseconnection: A function for console to call to indicate - confluent should resume control over the connection - - """ - if request is not None: # This is indicative of http style - pass # TODO(jbjohnso): support AJAX style interaction. - # a web ui looking to actually take advantage will - # probably have to pull in the GPL javascript - # from shellinabox or something similar - # the way that works is URI encoded input with width, heiht, - # session or rooturl:opening - # opening session - # width=120&height=24&rooturl=/nodes/n1/console/session - # making a request to wait for data: - # width=120&height=24&session=blahblahblah - # : - # width=120&height=24&session=blahblahblah&keys=0D - # pasting 'rabbit' - # width=120&height=24&session=blahblah&keys=726162626974 - # if no client session indicated, it expects some session number - # in return. - # the responses: - # : (the session seems to be opaque - # {"session":"h5lrOKViIeQGp1nXjKWpAQ","data":""} - # - # {"session":"blah","data":"\r\n\u001B]0;bob@thor:~\u0007$ "} - # BBIHIBBH", - 16, ltype, offset, datalen, tstamp, evtdata, eventaux, 0) + binrecord = struct.pack( + ">BBIHIBBH", 16, ltype, offset, datalen, tstamp, evtdata, + eventaux, 0) if self.isconsole: if ltype == 2: textrecord = data @@ -175,8 +179,6 @@ class Logger(object): recbytes = binfile.read(16) (_, ltype, offset, datalen, tstamp, evtdata, eventaux, _) = \ struct.unpack(">BBIHIBBH", recbytes) - binrecord = struct.pack(">BBIHIBBH", - 16, ltype, offset, datalen, tstamp, evtdata, eventaux, 0) if ltype != 2: continue currsize += datalen @@ -218,7 +220,8 @@ class Logger(object): if eventdata is not None: self.logentries[-1][4] = eventdata else: - self.logentries.append([ltype, timestamp, logdata, event, eventdata]) + self.logentries.append( + [ltype, timestamp, logdata, event, eventdata]) if self.writer is None: self.writer = eventlet.spawn_after(2, self.writedata)