slimta.cloudstorage.rackspace

This module defines the queue storage mechanism specific to the Rackspace Cloud hosting service. It requires an account as well as the Cloud Files and optionally the Cloud Queues services.

For each queued message, the contents and metadata of the message are written to Cloud Files. Upon success, a reference to the message is injected into Cloud Queues as a new message.

The Cloud Queues service is only necessary for alerting separate slimta processes that a new message has been queued. If reception and relaying are happening in the same process, Cloud Queues is unnecessary.

auth = RackspaceCloudAuth({'username': 'slimta', 'api_key': 'xxxxxx'},
                          region='IAD')
cloud_files = RackspaceCloudFiles(auth)
cloud_queues = RackspaceCloudQueues(auth)

storage = CloudStorage(cloud_files, cloud_queues)
exception slimta.cloudstorage.rackspace.RackspaceError(response)

Bases: slimta.cloudstorage.CloudStorageError

Thrown when an unexpected status has been returned from a Rackspace Cloud API request and the engine does not know how to continue.

response = None

The HTTPResponse object that triggered the exception.

class slimta.cloudstorage.rackspace.RackspaceCloudAuth(credentials[, endpoint='https://identity....acecloud.com/v2.0/'[, region=None[, timeout=None[, tls=None]]]])

Bases: object

This class implements and manages the creation of authentication tokens when RackspaceCloudFiles or RackspaceCloudQueues objects require them.

Parameters:
  • credentials (dict) –

    This dictionary defines how credentials are sent to the Auth API.

    If the function key is defined, it must be a callable that takes no arguments and returns a tuple. The tuple must contain a token string, a Cloud Files service endpoint, and a Cloud Queues service endpoint.

    Otherwise, this dictionary must have a username key whose value is the Rackspace Cloud username string.

    The password key may be used to fetch tokens using the account’s password. Alternatively, the api_key key may be used to fetch tokens using the account’s API key. With username, either password or api_key must be given.

    Optionally, tenant_id may also be provided for situations where it is necessary for authentication.

  • endpoint – If given, this is the Rackspace Cloud Auth endpoint to hit when creating tokens.
  • region – When discovering API endpoints from the service catalog, this is the endpoint region to use, e.g. IAD or HKG. If not given, the first region returned is used.
  • timeout – Timeout, in seconds, for requests to the Cloud Auth API to create a new token for the session.
  • tls – Optional dictionary of TLS settings passed directly as keyword arguments to gevent.ssl.SSLSocket. This is only used for URLs with the https scheme.
queues_endpoint = None

The current Cloud Queues API endpoint in use by the mechanism. This should be populated automatically on authentication.

files_endpoint = None

The current Cloud Files API endpoint in use by the mechanism. This should be populated automatically on authentication.

token_id

The current token in use by the mechanism.

create_token()

Creates a new token for use in future requests to Rackspace Cloud services. This method is called automatically in most cases. The new token is stored in the token_id attribute.

class slimta.cloudstorage.rackspace.RackspaceCloudFiles(auth[, container='slimta-queue'[, timeout=None[, tls=None[, prefix='']]]])

Bases: object

Instances of this class may be passed in to the CloudStorage constructor for the storage parameter to use Cloud Files as the storage backend.

Keys added to the container are generated with prefix + str(uuid.uuid4()).

Parameters:
  • auth – The RackspaceCloudAuth object used to manage tokens this service.
  • container – The Cloud Files container name to use. The files in this container will be named with random UUID strings.
  • timeout – Timeout, in seconds, for all requests to the Cloud Files API to return before an exception is thrown.
  • tls – Optional dictionary of TLS settings passed directly as keyword arguments to gevent.ssl.SSLSocket. This is only used for URLs with the https scheme.
  • prefix – The string prefixed to every key added to the bucket.
class slimta.cloudstorage.rackspace.RackspaceCloudQueues(auth[, queue_name='slimta-queue'[, client_id=None[, timeout=None[, poll_pause=1.0[, tls=None]]]]])

Bases: object

Instances of this class may be passed in to the CloudStorage constructor for the message_queue parameter to use Cloud Queues as the message queue backend to alert other processes that a new message was stored.

Parameters:
  • auth – The RackspaceCloudAuth object used to manage tokens this service.
  • queue_name – The Cloud Files queue name to use.
  • client_id – The Client-ID header passed in with all Cloud Queues requests. By default, this is generated using uuid5() in conjunction with getfqdn() to be consistent across restarts.
  • timeout – Timeout, in seconds, for all requests to the Cloud Queues API.
  • poll_pause – The time, in seconds, to idle between attempts to poll the queue for new messages.
  • tls – Optional dictionary of TLS settings passed directly as keyword arguments to gevent.ssl.SSLSocket. This is only used for URLs with the https scheme.