diff --git a/confluent/httpapi.py b/confluent/httpapi.py index 22e54e05..06fc3bfb 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -138,12 +138,14 @@ def resourcehandler(env, start_response): start_response('401 Authentication Required', [('Content-type', 'text/plain'), ('WWW-Authenticate', 'Basic realm="confluent"')]) - return 'authentication required' + yield 'authentication required' + return if authorized['code'] == 403: start_response('403 Forbidden', [('Content-type', 'text/plain'), ('WWW-Authenticate', 'Basic realm="confluent"')]) - return 'authorization failed' + yield 'authorization failed' + return if authorized['code'] != 200: raise Exception("Unrecognized code from auth engine") headers = [('Content-Type', 'application/json; charset=utf-8')] @@ -164,7 +166,8 @@ def resourcehandler(env, start_response): return sessid = _assign_consessionid(consession) start_response('200 OK', headers) - return ['{"session":"%s","data":""}' % sessid] + yield '{"session":"%s","data":""}' % sessid + return elif 'keys' in querydict.keys(): # client wishes to push some keys into the remote console input = "" @@ -174,7 +177,7 @@ def resourcehandler(env, start_response): consolesessions[sessid]['expiry'] = time.time() + 90 consolesessions[sessid]['session'].write(input) start_response('200 OK', headers) - 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'] consolesessions[sessid]['expiry'] = time.time() + 90 @@ -186,11 +189,12 @@ def resourcehandler(env, start_response): except UnicodeDecodeError: rsp = json.dumps({'session': querydict['session'], 'data': 'DECODEERROR'}) start_response('200 OK', headers) - return [rsp] + yield rsp + return else: - pluginapi.handle_path(env['PATH_INFO'], 'retrieve', cfgmgr) - start_response('404 Not Found', headers) - return ["404 Unrecognized resource"] + start_response('200 OK', headers) + for rsp in pluginapi.handle_path(env['PATH_INFO'], 'retrieve', cfgmgr): + yield json.dumps(rsp, separators=(',', ':')) def serve(): diff --git a/plugins/ipmi.py b/plugins/ipmi.py index 290b4b1f..bfddccab 100644 --- a/plugins/ipmi.py +++ b/plugins/ipmi.py @@ -174,20 +174,21 @@ class IpmiIterator(object): 'secret.managementuser', 'secret.managementpassphrase', 'hardwaremanagement.manager']) cfg.decrypt = crypt + self.gpile = greenpool.GreenPile() for node in nodes: - print IpmiHandler(operator, node, element, configdata).handle_request() - #eventlet.spawn(perform_request, - # (operator, node, element, configdata, self.resultqueue)) + self.gpile.spawn(perform_request, operator, node, element, configdata) def __iter__(self): return self def next(self): - pass + ndata = self.gpile.next() + # need to apply any translations between pyghmi and confluent + return ndata -def perform_request(operator, node, element, configdata, queue): - IpmiHandler(operator, node, element, configdata).handle_request() +def perform_request(operator, node, element, configdata): + return IpmiHandler(operator, node, element, configdata).handle_request() class IpmiHandler(object):