Selaa lähdekoodia

Added docs on using object storage and some doc fixes

Nuwan Goonasekera 8 vuotta sitten
vanhempi
sitoutus
5c5bd2d293

+ 1 - 0
docs/api_docs/cloud/resources.rst

@@ -152,6 +152,7 @@ VMFirewallRule
 -----------------
 .. autoclass:: cloudbridge.cloud.interfaces.resources.VMFirewallRule
     :members:
+    :undoc-members:
 
 TrafficDirection
 -----------------

+ 2 - 2
docs/api_docs/cloud/services.rst

@@ -88,9 +88,9 @@ VMFirewallService
 .. autoclass:: cloudbridge.cloud.interfaces.services.VMFirewallService
     :members:
 
-VMTypesService
+VMTypeService
 --------------------
-.. autoclass:: cloudbridge.cloud.interfaces.services.VMTypesService
+.. autoclass:: cloudbridge.cloud.interfaces.services.VMTypeService
     :members:
 
 RegionService

+ 1 - 1
docs/extras/_images/object_relationships_detailed.svg

@@ -367,7 +367,7 @@
        xml:space="preserve">images</text>
   </a>
   <a
-     xlink:href="../api_docs/cloud/services.html#vmtypesservice"
+     xlink:href="../api_docs/cloud/services.html#vmtypeservice"
      target="_parent"
      id="svg_23">
     <path

+ 1 - 1
docs/topics/block_storage.rst

@@ -18,7 +18,7 @@ performed via the :class:`.VolumeService`. To start, let's create a 1GB volume.
     vol.wait_till_ready()
     provider.storage.volumes.list()
 
-Next, let's attach the volume to a running instance as device ``/dev/sdh``::
+Next, let's attach the volume to a running instance as device ``/dev/sdh``:
 
     vol.attach('i-dbf37022', '/dev/sdh')
     vol.refresh()

+ 70 - 0
docs/topics/object_storage.rst

@@ -0,0 +1,70 @@
+Working with object storage
+==========================
+Object storage provides a simple way to store and retrieve large amounts of
+unstructured data over HTTP. Object Storage is also referred to as Blob (Binary
+Large OBject) Storage by Azure, and Simple Storage Service (S3) by Amazon.
+
+Typically, you would store your objects within a Bucket, as it is known in
+AWS and GCE. A Bucket is also called a Container in OpenStack and Azure. In
+CloudBridge, we use the term Bucket.
+
+Storing objects in a bucket
+---------------------------
+To store an object within a bucket, we need to first create a bucket or
+retrieve an existing bucket.
+
+.. code-block:: python
+
+    bucket = provider.storage.buckets.create('my-bucket')
+    bucket.objects.list()
+
+Next, let's upload some data to this bucket. To efficiently upload a file,
+simple use the upload_from_file method.
+
+.. code-block:: python
+
+    obj = bucket.objects.create('my-data.txt')
+    obj.upload_from_file('/path/to/myfile.txt')
+
+You can also use the upload() function to upload from an in memory stream.
+Note that, an object you create with objects.create() doesn't actually get
+persisted until you upload some content.
+
+To locate and download this uploaded file again, you can do the following:
+
+.. code-block:: python
+
+    bucket = provider.storage.buckets.find('my-bucket')[0]
+    obj = bucket.objects.find('my-data.txt')[0]
+    print("Size: {0}, Modified: {1}".format(obj.size, obj.last_modified))
+    with open('/tmp/myfile.txt', 'wb') as f:
+        test_obj.save_content(f)
+ 
+
+Using tokens for authentication
+-------------------------------
+Some providers may support using temporary credentials with a session token,
+in which case you will be able to access a particular bucket by using that
+session token.
+
+.. code-block:: python
+
+    provider = CloudProviderFactory().create_provider(
+        ProviderList.AWS,
+        {'aws_access_key': 'ACCESS_KEY',
+         'aws_secret_key': 'SECRET_KEY',
+         'aws_session_token': 'MY_SESSION_TOKEN'})
+.. code-block:: python
+
+    provider = CloudProviderFactory().create_provider(
+        ProviderList.OPENSTACK,
+        {'os_storage_url': 'SWIFT_STORAGE_URL',
+         'os_auth_token': 'MY_SESSION_TOKEN'})
+
+Once a provider is obtained, you can access the container as usual:
+
+.. code-block:: python
+
+    bucket = provider.object_store.get(container)
+    obj = bucket.create_object('my_object.txt')
+    obj.upload_from_file(source)

+ 1 - 0
docs/topics/overview.rst

@@ -12,5 +12,6 @@ Introductions to all the key parts of CloudBridge you'll need to know:
     Object states and lifecycles <object_lifecycles.rst>
     Paging and iteration <paging_and_iteration.rst>
     Using block storage <block_storage.rst>
+    Using object storage <object_storage.rst>
     Troubleshooting <troubleshooting.rst>