swift3

Static Web Middleware for OpenStack Swift

swift3.version_info = (1, 7, 0)

Version information (major, minor, revision).

swift3.version = '1.7.0'

Version string 'major.minor.revision'.

swift3.middleware

The swift3 middleware will emulate the S3 REST api on top of swift.

The following operations are currently supported:

  • GET Service
  • DELETE Bucket
  • GET Bucket (List Objects)
  • PUT Bucket
  • DELETE Object
  • Delete Multiple Objects
  • GET Object
  • HEAD Object
  • PUT Object
  • PUT Object (Copy)

To add this middleware to your configuration, add the swift3 middleware in front of the auth middleware, and before any other middleware that look at swift requests (like rate limiting).

To set up your client, the access key will be the concatenation of the account and user strings that should look like test:tester, and the secret access key is the account password. The host should also point to the swift storage hostname. It also will have to use the old style calling format, and not the hostname based container format.

An example client using the python boto library might look like the following for an SAIO setup:

from boto.s3.connection import S3Connection
connection = S3Connection(
    aws_access_key_id='test:tester',
    aws_secret_access_key='testing',
    port=8080,
    host='127.0.0.1',
    is_secure=False,
    calling_format=boto.s3.connection.OrdinaryCallingFormat())
class swift3.middleware.BucketController(env, app, account_name, token, container_name, **kwargs)

Bases: swift.common.wsgi.WSGIContext

Handles bucket request.

DELETE(env, start_response)

Handle DELETE Bucket request

GET(env, start_response)

Handle GET Bucket (List Objects) request

HEAD(env, start_response)

Handle HEAD Bucket (Get Metadata) request

POST(env, start_response)

Handle POST Bucket (Delete/Upload Multiple Objects) request

PUT(env, start_response)

Handle PUT Bucket request

class swift3.middleware.ObjectController(env, app, account_name, token, container_name, object_name, **kwargs)

Bases: swift.common.wsgi.WSGIContext

Handles requests on objects

DELETE(env, start_response)

Handle DELETE Object request

GET(env, start_response)

Handle GET Object request

GETorHEAD(env, start_response)
HEAD(env, start_response)

Handle HEAD Object request

POST(env, start_response)
PUT(env, start_response)

Handle PUT Object and PUT Object (Copy) request

class swift3.middleware.ServiceController(env, app, account_name, token, **kwargs)

Bases: swift.common.wsgi.WSGIContext

Handles account level requests.

GET(env, start_response)

Handle GET Service request

class swift3.middleware.Swift3Middleware(app, conf, *args, **kwargs)

Bases: object

Swift3 S3 compatibility midleware

get_controller(env, path)
handle_request(env, start_response)
swift3.middleware.canonical_string(req)

Canonicalize a request to a token that can be signed.

swift3.middleware.filter_factory(global_conf, **local_conf)

Standard filter factory to use the middleware with paste.deploy

swift3.middleware.get_acl(account_name, headers)

Attempts to construct an S3 ACL based on what is found in the swift headers

swift3.middleware.get_err_response(code)

Given an HTTP response code, create a properly formatted xml error response

Parameters:code – error code
Returns:webob.response object
swift3.middleware.swift_acl_translate(acl, group='', user='', xml=False)

Takes an S3 style ACL and returns a list of header/value pairs that implement that ACL in Swift, or “Unsupported” if there isn’t a way to do that yet.

swift3.middleware.validate_bucket_name(name)

Validates the name of the bucket against S3 criteria, http://docs.amazonwebservices.com/AmazonS3/latest/BucketRestrictions.html True if valid, False otherwise

Table Of Contents

Previous topic

Swift S3 Compatibility Middleware

This Page