http.server: No longer enfore JSON encoding for body
The HTTP layer shouldn't care about the contents of the request data orresponses. This requires further changes in the RAPI code to handle clientrequests correctly.
Signed-off-by: Michael Hanselmann <hansmi@google.com>...
http.server: Refuse HTTP/1.1 request without Host header
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
http: Add two new exceptions, one constant
These will be useful in the future in case we don't enfore JSON encodinganymore in the http.server module. The HTTP 1.1 RFC recommends error 415(Unsupported Media Type) to be returned in case the client requests an...
Factorize LUXI parsing and handling code
Also fix a typo in http/__init__.py and add unittestsfor the LUXI parsing and formatting functions.
Merge remote branch 'devel-2.1'
Fix unused imports or add silences where needed
In some cases pylint doesn't parse the import correctly, so we addsilences; but there are also many cases of unused imports, which wesimply remove.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
Further pylint disables, mostly for Unused args
Many of our functions have to follow a given API, and thus we have tokeep a given signature, but pylint doesn't understand this. Therefore,we silence this warning.
The patch does a few other cleanups.
Signed-off-by: Iustin Pop <iustin@google.com>...
Convert to static methods (where appropriate)
Many methods are simple pure functions, and not depending on the objectstate. We convert these to staticmethods.
Add targeted pylint disables
This patch should have only:
- pylint disables- docstring changes- whitespace changes
Remove many 'Unused variable' warnings
Note there are some cases left which need extra cleanup.
Merge branch 'devel-2.0' into devel-2.1
Add targetted pylint disables
This patch adds targeted pylint disables, where it makes sense (eitherdue to limitations in pylint or due to historical usage), and also a fewblanket ones in rapi where all the names are… “different”.
A few style updates
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
Add check for OpenSSL entropy status
By checking for this explicitly, the errors (SSLEAY_RAND_BYTES, “PRNGnot seeded”) will happen in the start-up phase of the daemon and notonly when executing remote procedure calls.
Fix pylint 'E' (error) codes
This patch adds some silences and tweaks the code slightly so that“pylint --rcfile pylintrc -e ganeti” doesn't give any errors.
The biggest change is in jqueue.py, the move of _RequireOpenQueue out ofthe JobQueue class. Since that is actually a function and not a method...
Epydoc fixes
http.auth: Add new function to verify passwords
This new function supports two schemes for passwords:- Old-style cleartext passwords- Hashed passwords according to RFC2617 (H(A1))
Schemes are differentiated by their prefix, a concept alsoused in OpenLDAP. Cleartext passwords can no longer start...
ganeti-noded: Close listening socket in child
Convert the http server/mainloop to asyncore
We can avoid most of the Mainloop.Run() code if we use asyncorefor delivering I/O events, and just concentrate on what's missing inasyncore: singnal handling and timers. This way confd can be ported touse Mainloop as well....
Fix pylint warnings
Fix some typos
Fix HTTP server library handling of credentials
Currently the http library only checks credentials when authenticationis required. This means that any credentials are accepted on the rootresource, for example, which makes problems hard to diagnose - the...
Fix _NOQUOTE regexp
Allow expressions longer than one character to match.
Reviewed-by: imsnah
Fix some epydoc style issues
99% of the epydoc return tags are "@return:", but each of the modified fileshad one "@returns:" line. We fix this for consistency.
RAPI: format error messages as JSON
This patch changes the format of the HTTP error messages from text/html, whichis hard to parse from RAPI clients, to JSON which can be automatically parsed.
The error message is an object, which contains always three keys:...
Make RAPI return 502/504 errors for luxi errors
This changes the RAPI error codes for luxi errors; a timeout error isnow reported properly as 504, while any other luxi error is reported as502.
It would be good to convert even more errors into proper return codes in...
rapi: fix authentication and queries
For queries, we don't want to require authentication. We fix this by adding anoverride GetAuthRealm in the rapi daemon.
We also fix a method name.
Some docstring updates
This patch rewraps some comments to shorter lengths, changesdouble-quotes to single-quotes inside triple-quoted docstrings forbetter editor handling.
It also fixes some epydoc errors, namely invalid crossreferences (aftermethod rename), documentation for inexistent (removed) parameters, etc....
ganeti-noded: reduce log noise
The source port/addr is currently logged three times for eachconnection, and this is unnecessary. We change two log entries to debug,since they are useful for precise timing, and we keep only one at INFOlevel.
Fix some pylint-detected issues
Two bad indentation cases and a missing variable.
ganeti.http: Function to read password file
Lines in the password file are of the following format:
<username> <password> [options]
Fields are separated by whitespace. Username and password aremandatory, options are optional and separated by comma (",")....
ganeti.http: Add support for private data in HTTP requests
Reviewed-by: amishchenko
ganeti.http: Add support for basic HTTP authentication
As per RFC2617.
ganeti.http: Prepare authentication for HTTP server
The authentication class will override PreHandleRequest.
ganeti.http: Don't pass poller object around
They're cheap to instantiate and doing this changes makes the codea bit simpler.
Reviewed-by: ultrotter
Rename http.HttpInternalError to HttpInternalServerError
All other exceptions are named after the error name in RFC2616 (HTTP/1.1).
ganeti.http: Add more constants and errors
ganeti.http: Ignore ENOTCONN when shutting down the connection
Implement support for additional headers with HTTP errors
Add simple unittests for ganeti.http
More complex unittests will need some refactoring in the HTTP code.
ganeti.http: Add three TODOs for improvements
Reviewed-by: iustinp
ganeti.http: Explicitly initiate handshake
Otherwise it would be done on the first read/write operation, makingerror handling more difficult (such as EOF during handshake).
ganeti.http: Implement handshake socket operation
ganeti.http: Handle SSL_ERROR_ZERO_RETURN
Also add a comment next to the place where the SSL connection is shutdown.
cleanup: http server, line too long
cleanup: http client, line too long
ganeti.http: Rename HttpBase._using_ssl to HttpBase.using_ssl
It'll be queried from other classes.
ganeti.http: Rename HttpSocketBase to HttpBase
It's more appropriate.
Fix epydoc format warnings
This patch should fix all outstanding epydoc parsing errors; as such, weswitch epydoc into verbose mode so that any new errors will be visible.
ganeti.http: Docstring updates
ganeti.http: Remove _HttpClientError
This is a leftover from old code.
ganeti.http.server: Increase connection backlog to 1024
This solves a problem with many concurrent requests. By default, 1024is the maximum backlog on Linux kernels. We limit the number of clientsthrough MAX_CHILDREN, too. The idea of just increasing the backlog is...
http: use slicing instead of string modification
The combination of the current buffer splitting method and (4KB) buffersize is very inefficient when writing big amounts of data. Just walkingover a 16 megabyte string using a 4K buffer takes (on a random computer)...
ganeti.http: Add constant for DELETE
Remove old HTTP code
ganeti.http: Split HTTP server and client into separate files
This includes a large rewrite of the HTTP server code. The handling ofOpenSSL errors had some problems that were hard to fix with itsstructure. When preparing all of this, I realized that actually HTTP...
Rename all HTTP classes to camel case
It should be consistent.
ganeti.http: Remove underline from two classes
This is a preparation step for splitting the HTTP client and server codeinto two separate modules.
Move HTTP code to subpackage