You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/01/06 18:54:10 UTC

[5/8] git commit: docs: Add some documentation and examples for OpenStack Swift driver.

docs: Add some documentation and examples for OpenStack Swift driver.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b30c9b31
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b30c9b31
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b30c9b31

Branch: refs/heads/trunk
Commit: b30c9b31f47f2f356723b334a405879ecc40c217
Parents: 19a8c0c
Author: Tomaz Muraus <to...@apache.org>
Authored: Mon Jan 6 18:39:51 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Mon Jan 6 18:39:51 2014 +0100

----------------------------------------------------------------------
 docs/compute/drivers/openstack.rst              |  2 +
 .../swift/connect_to_rackspace_cloudfiles.py    | 12 +++++
 docs/examples/storage/swift/connect_to_swift.py | 12 +++++
 docs/storage/drivers/openstack_swift.rst        | 46 ++++++++++++++++++++
 4 files changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b30c9b31/docs/compute/drivers/openstack.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/openstack.rst b/docs/compute/drivers/openstack.rst
index 57c15f6..73bf703 100644
--- a/docs/compute/drivers/openstack.rst
+++ b/docs/compute/drivers/openstack.rst
@@ -1,6 +1,8 @@
 OpenStack Compute Driver Documentation
 ======================================
 
+.. _connecting-to-openstack-installation:
+
 Connecting to the OpenStack installation
 ----------------------------------------
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/b30c9b31/docs/examples/storage/swift/connect_to_rackspace_cloudfiles.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/swift/connect_to_rackspace_cloudfiles.py b/docs/examples/storage/swift/connect_to_rackspace_cloudfiles.py
new file mode 100644
index 0000000..095b492
--- /dev/null
+++ b/docs/examples/storage/swift/connect_to_rackspace_cloudfiles.py
@@ -0,0 +1,12 @@
+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())

http://git-wip-us.apache.org/repos/asf/libcloud/blob/b30c9b31/docs/examples/storage/swift/connect_to_swift.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/swift/connect_to_swift.py b/docs/examples/storage/swift/connect_to_swift.py
new file mode 100644
index 0000000..b641c08
--- /dev/null
+++ b/docs/examples/storage/swift/connect_to_swift.py
@@ -0,0 +1,12 @@
+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())

http://git-wip-us.apache.org/repos/asf/libcloud/blob/b30c9b31/docs/storage/drivers/openstack_swift.rst
----------------------------------------------------------------------
diff --git a/docs/storage/drivers/openstack_swift.rst b/docs/storage/drivers/openstack_swift.rst
new file mode 100644
index 0000000..2d64add
--- /dev/null
+++ b/docs/storage/drivers/openstack_swift.rst
@@ -0,0 +1,46 @@
+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 :ref:`Connecting to the OpenStack installation
+section <connecting-to-openstack-installation>` 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 for the service name attribute in the service catalog.
+
+.. literalinclude:: /examples/storage/swift/connect_to_swift.py
+   :language: python
+
+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.
+
+.. literalinclude:: /examples/storage/swift/connect_to_rackspace_cloudfiles.py
+   :language: python