Utility methods for working with WSGI servers
glance.common.wsgi.
APIMapper
(controller_scan=<function controller_scan>, directory=None, always_scan=False, register=True, explicit=True)[source]¶Bases: routes.mapper.Mapper
Handle route matching when url is ‘’ because routes.Mapper returns an error in this case.
glance.common.wsgi.
BaseServer
(threads=1000, initialize_glance_store=False)[source]¶Bases: object
Server class to manage multiple WSGI sockets and applications.
This class requires initialize_glance_store set to True if glance store needs to be initialized.
configure
(old_conf=None, has_changed=None)[source]¶Apply configuration settings
Parameters: |
|
---|
configure_socket
(old_conf=None, has_changed=None)[source]¶Ensure a socket exists and is appropriately configured.
This function is called on start up, and can also be called in the event of a configuration reload.
When called for the first time a new socket is created. If reloading and either bind_host or bind port have been changed the existing socket must be closed and a new socket opened (laws of physics).
In all other cases (bind_host/bind_port have not changed) the existing socket is reused.
Parameters: |
|
---|
glance.common.wsgi.
Debug
(application)[source]¶Bases: glance.common.wsgi.Middleware
Helper class that can be inserted into any WSGI application chain to get information about the request and response.
glance.common.wsgi.
JSONRequestDeserializer
[source]¶Bases: object
has_body
(request)[source]¶Returns whether a Webob.Request object will possess an entity body.
Parameters: | request – Webob.Request object |
---|
httpverb_may_have_body
= frozenset(['PUT', 'POST', 'PATCH'])¶valid_transfer_encoding
= frozenset(['gzip', 'chunked', 'compress', 'identity', 'deflate'])¶glance.common.wsgi.
Middleware
(application)[source]¶Bases: object
Base WSGI middleware wrapper. These classes require an application to be initialized that will be called next. By default the middleware will simply call its wrapped app, or you can override __call__ to customize its behavior.
glance.common.wsgi.
PosixServer
(*args, **kwargs)[source]¶glance.common.wsgi.
Request
(environ, *args, **kwargs)[source]¶Bases: webob.request.Request
Add some OpenStack API-specific logic to the base webob.Request.
best_match_language
()[source]¶Determines best available locale from the Accept-Language header.
Returns: | the best language match or None if the ‘Accept-Language’ header was not available in the request. |
---|
body_file
¶params
¶Override params property of webob.request.BaseRequest.
Added an ‘encoded_params’ attribute in case of PY2 to avoid encoding values in next subsequent calls to the params property.
glance.common.wsgi.
Resource
(controller, deserializer=None, serializer=None)[source]¶Bases: object
WSGI app that handles (de)serialization and controller dispatch.
Reads routing information supplied by RoutesMiddleware and calls the requested action method upon its deserializer, controller, and serializer. Those three objects may implement any of the basic controller action methods (create, update, show, index, delete) along with any that may be specified in the api router. A ‘default’ method may also be implemented to be used in place of any non-implemented actions. Deserializer methods must accept a request argument and return a dictionary. Controller methods must accept a request argument. Additionally, they must also accept keyword arguments that represent the keys returned by the Deserializer. They may raise a webob.exc exception or return a dict, which will be serialized by requested content type.
glance.common.wsgi.
Router
(mapper)[source]¶Bases: object
WSGI middleware that maps incoming requests to WSGI apps.
glance.common.wsgi.
Server
¶alias of glance.common.wsgi.PosixServer
glance.common.wsgi.
Win32Server
(*args, **kwargs)[source]¶Bases: glance.common.wsgi.BaseServer
configure_socket
(old_conf=None, has_changed=None)[source]¶Ensure a socket exists and is appropriately configured.
This function is called on start up, and can also be called in the event of a configuration reload.
When called for the first time a new socket is created. If reloading and either bind_host or bind port have been changed the existing socket must be closed and a new socket opened (laws of physics).
In all other cases (bind_host/bind_port have not changed) the existing socket is reused.
Parameters: |
|
---|
glance.common.wsgi.
get_asynchronous_eventlet_pool
(size=1000)[source]¶Return eventlet pool to caller.
Also store pools created in global list, to wait on it after getting signal for graceful shutdown.
Parameters: | size – eventlet pool size |
---|---|
Returns: | eventlet pool |
glance.common.wsgi.
get_socket
(default_port)[source]¶Bind socket to bind ip:port in conf
note: Mostly comes from Swift with a few small changes…
Parameters: | default_port – port to bind to if none is specified in conf |
---|---|
Returns: | a socket object as returned from socket.listen or ssl.wrap_socket if conf specifies cert_file |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.