The python-swiftclient
project comprises a command line tool and two
separate APIs for accessing swift programmatically. Choosing the most
appropriate method for a given use case is the first problem a user needs to
solve.
Alongside the command line tool, the python-swiftclient
includes two
levels of API:
Example use cases:
SwiftService
API to perform operations offered by the CLI
if your use case requires integration with a Python-based workflow.
This method offers greater control and flexibility over individual object
operations, such as the metadata set on each object. The SwiftService
class provides methods to perform multiple sets of operations against a
swift object store using a configurable shared thread pool. A single
instance of the SwiftService
class can be shared between multiple
threads in your own code.SwiftService
API to develop Python applications that use
swift to store and retrieve objects. A SwiftService
instance provides
a configurable thread pool for performing all operations supported by the
CLI.Connection
API if your use case requires fine grained control
over advanced features or you wish to use your own existing threading
model. Examples of advanced features requiring the use of the
Connection
API include creating an SLO manifest that references
already existing objects, or fine grained control over the query strings
supplied with each HTTP request.This section covers some important considerations, helpful hints, and things to avoid when integrating an object store into your workflow.
It cannot be stressed enough that your usage of the object store should reflect the proper use case, and not treat the storage like a traditional filesystem. There are two main restrictions to bear in mind when designing an application that uses an object store:
There is no mechanism to perform a combination of reading the data/metadata from an object and writing an update to that data/metadata in an atomic way. Any user with access to a container could update the contents or metadata associated with an object at any time.
Workflows that assume that no updates have been made since the last read of an object should be discouraged. Enabling a workflow of this type requires an external object locking mechanism and/or cooperation between all clients accessing the data.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.