OpenStack Swift Storage Driver Documentation

Connecting to the OpenStack Swift installation

When connecting to the OpenStack Swift installation, you need to, besides the username and api key argument also pass the following keyword arguments to the driver constructor:

  • ex_force_auth_url - Authentication service (Keystone) API URL. It can either be a full URL with a path.
  • ex_force_service_type - Service type which will be used to find a matching service in the service catalog. Defaults to object-store
  • ex_force_service_name Service name which will be used to find a matching service in the service catalog. Defaults to swift

For more information about other keyword arguments you can pass to the constructor, please refer to the Connecting to the OpenStack installation section of our documentation.

Examples

1. Connect to OpenStack Swift Installation

This example shows how to connect to a Swift installation which uses a non-default value (Object Storage Service) for the service name attribute in the service catalog.

from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver

cls = get_driver(Provider.OPENSTACK_SWIFT)

driver = cls('username', 'api key',
             region='ord',
             ex_force_auth_url='http://192.168.1.101:5000',
             ex_force_service_type='object-store',
             ex_force_service_name='Object Storage Service')

print(driver.list_containers())

2. Connecting to Rackspace CloudFiles using a generic Swift driver

This example shows how to connect to the Rackspace CloudFiles using a generic Swift driver.

Keep in mind that this example is here only for demonstration purposes. When you are connecting to Rackspace CloudFiles installation for real, you should use CLOUDFILES provider constant which only requires you to specify username, api key and region.

from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver

cls = get_driver(Provider.OPENSTACK_SWIFT)

driver = cls('username', 'api key',
             region='ord',
             ex_force_auth_url='https://auth.api.rackspacecloud.com:443',
             ex_force_service_type='object-store',
             ex_force_service_name='cloudFiles')

print(driver.list_containers())