Table Of Contents

Previous topic

Partitioned Consistent Hash Ring

Next topic

Account

This Page

Psst... hey. Did you know you can read Swift 1.3 docs or Swift 1.2 docs also?

Proxy

Proxy Server

class swift.proxy.server.AccountController(app, account_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for account requests

DELETE(*a, **kw)

HTTP DELETE request handler.

GETorHEAD(req)

Handler for HTTP GET/HEAD requests.

POST(*a, **kw)

HTTP POST request handler.

PUT(*a, **kw)

HTTP PUT request handler.

class swift.proxy.server.Application(conf, memcache=None, logger=None, account_ring=None, container_ring=None, object_ring=None)

Bases: swift.proxy.server.BaseApplication

WSGI application for the proxy server.

handle_request(req)

Wraps the BaseApplication.handle_request and logs the request.

posthooklogger(env, req)
class swift.proxy.server.BaseApplication(conf, memcache=None, logger=None, account_ring=None, container_ring=None, object_ring=None)

Bases: object

Base WSGI application for the proxy server

get_controller(path)

Get the controller to handle a request.

Parameters:path – path from request
Returns:tuple of (controller class, path dictionary)
Raises :ValueError (thrown by split_path) id given invalid path
handle_request(req)

Entry point for proxy server. Should return a WSGI-style callable (such as webob.Response).

Parameters:req – webob.Request object
posthooklogger(env, req)
update_request(req)
class swift.proxy.server.ContainerController(app, account_name, container_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for container requests

DELETE(*a, **kw)

HTTP DELETE request handler.

GET(*a, **kw)

Handler for HTTP GET requests.

GETorHEAD(req)

Handler for HTTP GET/HEAD requests.

HEAD(*a, **kw)

Handler for HTTP HEAD requests.

POST(*a, **kw)

HTTP POST request handler.

PUT(*a, **kw)

HTTP PUT request handler.

clean_acls(req)
class swift.proxy.server.Controller(app)

Bases: object

Base WSGI controller class for the proxy

GET(*a, **kw)

Handler for HTTP GET requests.

GETorHEAD_base(req, server_type, partition, nodes, path, attempts)

Base handler for HTTP GET or HEAD requests.

Parameters:
  • req – webob.Request object
  • server_type – server type
  • partition – partition
  • nodes – nodes
  • path – path for the request
  • attempts – number of attempts to try
Returns:

webob.Response object

HEAD(*a, **kw)

Handler for HTTP HEAD requests.

account_info(account)

Get account information, and also verify that the account exists.

Parameters:account – name of the account to get the info for
Returns:tuple of (account partition, account nodes) or (None, None) if it does not exist
best_response(req, statuses, reasons, bodies, server_type, etag=None)

Given a list of responses from several servers, choose the best to return to the API.

Parameters:
  • req – webob.Request object
  • statuses – list of statuses returned
  • reasons – list of reasons for each status
  • bodies – bodies of each response
  • server_type – type of server the responses came from
  • etag – etag
Returns:

webob.Response object with the correct status, body, etc. set

container_info(account, container)

Get container information and thusly verify container existance. This will also make a call to account_info to verify that the account exists.

Parameters:
  • account – account name for the container
  • container – container name to look up
Returns:

tuple of (container partition, container nodes, container read acl, container write acl) or (None, None, None, None) if the container does not exist

error_increment(node)

Handles incrementing error counts when talking to nodes.

Parameters:node – dictionary of node to increment the error count for
error_limit(node)

Mark a node as error limited.

Parameters:node – dictionary of node to error limit
error_limited(node)

Check if the node is currently error limited.

Parameters:node – dictionary of node to check
Returns:True if error limited, False otherwise
error_occurred(node, msg)

Handle logging, and handling of errors.

Parameters:
  • node – dictionary of node to handle errors for
  • msg – error message
exception_occurred(node, typ, additional_info)

Handle logging of generic exceptions.

Parameters:
  • node – dictionary of node to log the error for
  • typ – server type
  • additional_info – additional information to log
iter_nodes(partition, nodes, ring)

Node iterator that will first iterate over the normal nodes for a partition and then the handoff partitions for the node.

Parameters:
  • partition – partition to iterate nodes for
  • nodes – list of node dicts from the ring
  • ring – ring to get handoff nodes from
make_requests(req, ring, part, method, path, headers, query_string='')

Sends an HTTP request to multiple nodes and aggregates the results. It attempts the primary nodes concurrently, then iterates over the handoff nodes as needed.

Parameters:headers – a list of dicts, where each dict represents one backend request that should be made.
Returns:a webob Response object
class swift.proxy.server.ObjectController(app, account_name, container_name, object_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for object requests.

COPY(*a, **kw)

HTTP COPY request handler.

DELETE(*a, **kw)

HTTP DELETE request handler.

GET(*a, **kw)

Handler for HTTP GET requests.

GETorHEAD(req)

Handle HTTP GET or HEAD requests.

HEAD(*a, **kw)

Handler for HTTP HEAD requests.

POST(*a, **kw)

HTTP POST request handler.

PUT(*a, **kw)

HTTP PUT request handler.

class swift.proxy.server.SegmentedIterable(controller, container, listing, response=None)

Bases: object

Iterable that returns the object contents for a segmented object in Swift.

If set, the response’s bytes_transferred value will be updated (used to log the size of the request). Also, if there’s a failure that cuts the transfer short, the response’s status_int will be updated (again, just for logging since the original status would have already been sent to the client).

Parameters:
  • controller – The ObjectController instance to work with.
  • container – The container the object segments are within.
  • listing – The listing of object segments to iterate over; this may be an iterator or list that returns dicts with ‘name’ and ‘bytes’ keys.
  • response – The webob.Response this iterable is associated with, if any (default: None)
app_iter_range(start, stop)

Non-standard iterator function for use with Webob in serving Range requests more quickly. This will skip over segments and do a range request on the first segment to return data from, if needed.

Parameters:
  • start – The first byte (zero-based) to return. None for 0.
  • stop – The last byte (zero-based) to return. None for end.
next()
swift.proxy.server.app_factory(global_conf, **local_conf)

paste.deploy app factory for creating WSGI proxy apps.

swift.proxy.server.delay_denial(func)

Decorator to declare which methods should have any swift.authorize call delayed. This is so the method can load the Request object up with additional information that may be needed by the authorization system.

Parameters:func – function to delay authorization on
swift.proxy.server.get_account_memcache_key(account)
swift.proxy.server.get_container_memcache_key(account, container)
swift.proxy.server.public(func)

Decorator to declare which methods are public accessible as HTTP requests

Parameters:func – function to make public
swift.proxy.server.update_headers(response, headers)

Helper function to update headers in the response.

Parameters:
  • response – webob.Response object
  • headers – dictionary headers