mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-15 12:17:47 +00:00
Changes to get SOL console kind of working
This commit is contained in:
parent
fb8d042f48
commit
d7db7041b2
@ -35,7 +35,7 @@ class _ConsoleHandler(object):
|
||||
|
||||
#this represents some api view of a console handler. This handles things like
|
||||
#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,
|
||||
#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
|
||||
@ -68,7 +68,7 @@ class ConsoleSession(object):
|
||||
deadline = currtime + 45
|
||||
while len(self.databuffer) == 0 and currtime < deadline:
|
||||
timeo = deadline - currtime
|
||||
self.conshdl.wait_for_data(timeout=timeo)
|
||||
self.conshdl._console.wait_for_data(timeout=timeo)
|
||||
currtime = util.monotonic_time()
|
||||
retval = self.databuffer
|
||||
self.databuffer = ""
|
||||
|
@ -8,6 +8,7 @@ import confluent.console as console
|
||||
import confluent.auth as auth
|
||||
import confluent.util as util
|
||||
import eventlet
|
||||
import json
|
||||
import os
|
||||
import string
|
||||
import urlparse
|
||||
@ -124,19 +125,20 @@ def resourcehandler(env, start_response):
|
||||
elif 'keys' in querydict.keys():
|
||||
# client wishes to push some keys into the remote console
|
||||
input = ""
|
||||
for idx in xrange(0, len(querydict['keys'])):
|
||||
input += chr(int(querydict['keys'][idx:idx+2]))
|
||||
print "taking in "+input
|
||||
for idx in xrange(0, len(querydict['keys']), 2):
|
||||
input += chr(int(querydict['keys'][idx:idx+2],16))
|
||||
sessid = querydict['session']
|
||||
consolesessions[sessid].write(input)
|
||||
start_response('200 OK', [('Content-Type',
|
||||
'application/json; charset=utf-8')])
|
||||
return # client has requests to send or receive, not both...
|
||||
return [] # client has requests to send or receive, not both...
|
||||
else: #no keys, but a session, means it's hooking to receive data
|
||||
sessid = querydict['session']
|
||||
outdata = consolesessions[sessid].get_next_output(timeout=45)
|
||||
json = '{"session":"%s","data":"%s"}'%(querydict['session'],
|
||||
outdata)
|
||||
rsp = json.dumps({'session': querydict['session'], 'data': outdata})
|
||||
start_response('200 OK', [('Content-Type',
|
||||
'application/json; charset=utf-8')])
|
||||
return [rsp]
|
||||
start_response('404 Not Found', [])
|
||||
return ["Unrecognized directive (404)"]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user