You are here: Home / Systems / Swift object storage / python

python

The python-swiftclient brings you an easy and clear python API.

General

Please see platforms and instructions for supported platforms and installation instructions.
 

Usage

The client is already installed on mistral. Please load the python package by typing:

module load swift

Examples

Following is an example program, which shows how to create a container and upload a file.
 
from swiftclient.client import Connection
from getpass import getpass

pw = getpass()

c = Connection("https://swift.dkrz.de/auth/v1.0", "account:user", pw, auth_version=1.0)

c.put_container("my_container")

f = open("/path/to/myfile")

c.put_object("my_container", "my_object", f)

To retrieve all objects and metadata from a container:

# Credentials, and imports
...
metadata, objects = c.get_container("my_container")

Help

Please visit http://docs.openstack.org/developer/python-swiftclient/

Document Actions