Revision 441e7cfd daemons/ganeti-rapi
b/daemons/ganeti-rapi | ||
---|---|---|
22 | 22 |
""" |
23 | 23 |
|
24 | 24 |
import glob |
25 |
import logging |
|
25 | 26 |
import optparse |
26 | 27 |
import sys |
27 | 28 |
import os |
28 | 29 |
import signal |
29 | 30 |
|
31 |
from ganeti import logger |
|
30 | 32 |
from ganeti import constants |
31 | 33 |
from ganeti import errors |
32 | 34 |
from ganeti import http |
33 |
from ganeti import rpc |
|
34 | 35 |
from ganeti import ssconf |
35 | 36 |
from ganeti import utils |
36 | 37 |
from ganeti.rapi import connector |
... | ... | |
49 | 50 |
|
50 | 51 |
""" |
51 | 52 |
(HandlerClass, items, args) = self._resmap.getController(self.path) |
52 |
handler = HandlerClass(self, items, args) |
|
53 |
handler = HandlerClass(self, items, args, self.post_data)
|
|
53 | 54 |
|
54 | 55 |
command = self.command.upper() |
55 | 56 |
try: |
... | ... | |
58 | 59 |
raise http.HTTPBadRequest() |
59 | 60 |
|
60 | 61 |
try: |
61 |
result = fn() |
|
62 |
try: |
|
63 |
result = fn() |
|
64 |
except: |
|
65 |
logging.exception("Error while handling the %s request", command) |
|
66 |
raise |
|
62 | 67 |
|
63 | 68 |
except errors.OpPrereqError, err: |
64 | 69 |
# TODO: "Not found" is not always the correct error. Ganeti's core must |
... | ... | |
135 | 140 |
if options.fork: |
136 | 141 |
utils.Daemonize(logfile=constants.LOG_RAPISERVER) |
137 | 142 |
|
143 |
logger.SetupLogging(constants.LOG_RAPISERVER, debug=options.debug, |
|
144 |
stderr_logging=not options.fork) |
|
145 |
|
|
138 | 146 |
utils.WritePidFile(constants.RAPI_PID) |
139 | 147 |
|
140 | 148 |
log_fd = open(constants.LOG_RAPIACCESS, 'a') |
... | ... | |
155 | 163 |
|
156 | 164 |
|
157 | 165 |
if __name__ == '__main__': |
166 |
|
|
158 | 167 |
main() |
Also available in: Unified diff