Commit 9ae49f27 authored by Guido Trotter's avatar Guido Trotter
Browse files

ganeti-noded: quit on QuitGanetiException

Accoring to the usage documented in the QuitGanetiException docstring,
if we receive such an exception we'll set the global _EXIT_GANETI_NODED
variable to True, and then return either a valid value or an error
message to the user. This will be the last request we serve, though,
because the main loop will be interrupted and the daemon will terminate.

Reviewed-by: iustinp
parent e50bdd68
......@@ -77,6 +77,17 @@ class ServerObject(BaseHTTPServer.BaseHTTPRequestHandler):
params = simplejson.loads(body)
result = method(params)
payload = simplejson.dumps(result)
except errors.QuitGanetiException, err:
if isinstance(err, tuple) and len(err) == 2:
if err[0]:
self.send_error(500, "Error: %s" % str(err[1]))
payload = simplejson.dumps(err[1])
self.log_message('GanetiQuitException Usage Error')
self.send_error(500, "Error: %s" % str(err))
except Exception, err:
self.send_error(500, "Error: %s" % str(err))
return False
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