glance.api.middleware package

Submodules

glance.api.middleware.cache module

Transparent image file caching middleware, designed to live on Glance API nodes. When images are requested from the API node, this middleware caches the returned image file to local filesystem.

When subsequent requests for the same image file are received, the local cached copy of the image file is returned.

class glance.api.middleware.cache.CacheFilter(app)[source]

Bases: glance.common.wsgi.Middleware

get_from_cache(image_id)[source]

Called if cache hit

get_status_code(response)[source]

Returns the integer status code from the response, which can be either a Webob.Response (used in testing) or httplib.Response

process_request(request)[source]

For requests for an image file, we check the local image cache. If present, we return the image file, appending the image metadata in headers. If not present, we pass the request on to the next application in the pipeline.

process_response(resp)[source]

We intercept the response coming back from the main images Resource, removing image file from the cache if necessary

glance.api.middleware.cache_manage module

Image Cache Management API

class glance.api.middleware.cache_manage.CacheManageFilter(app)[source]

Bases: glance.common.wsgi.Middleware

process_request(request)[source]

glance.api.middleware.context module

class glance.api.middleware.context.BaseContextMiddleware(application)[source]

Bases: glance.common.wsgi.Middleware

process_response(resp)[source]
class glance.api.middleware.context.ContextMiddleware(app)[source]

Bases: glance.api.middleware.context.BaseContextMiddleware

process_request(req)[source]

Convert authentication information into a request context

Generate a glance.context.RequestContext object from the available authentication headers and store on the ‘context’ attribute of the req object.

Parameters:req – wsgi request object that will be given the context object
Raises:webob.exc.HTTPUnauthorized: when value of the X-Identity-Status header is not ‘Confirmed’ and anonymous access is disallowed
class glance.api.middleware.context.UnauthenticatedContextMiddleware(application)[source]

Bases: glance.api.middleware.context.BaseContextMiddleware

process_request(req)[source]

Create a context without an authorized user.

glance.api.middleware.gzip module

Use gzip compression if the client accepts it.

class glance.api.middleware.gzip.GzipMiddleware(app)[source]

Bases: glance.common.wsgi.Middleware

process_response(response)[source]
re_zip = <_sre.SRE_Pattern object at 0x7f9ec89a37b0>

glance.api.middleware.version_negotiation module

A filter middleware that inspects the requested URI for a version string and/or Accept headers and attempts to negotiate an API controller to return

class glance.api.middleware.version_negotiation.GlareVersionNegotiationFilter(app)[source]

Bases: glance.api.middleware.version_negotiation.VersionNegotiationFilter

class glance.api.middleware.version_negotiation.VersionNegotiationFilter(app)[source]

Bases: glance.common.wsgi.Middleware

process_request(req)[source]

Try to find a version first in the accept header, then the URL

Module contents