You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/10/16 06:28:30 UTC

[1/5] libcloud git commit: Document changing signature version.

Repository: libcloud
Updated Branches:
  refs/heads/trunk 820ff6f70 -> be3d1e18a


Document changing signature version.

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: be3d1e18ac18a694a453a004d3f72ac7e9867c4e
Parents: 6d01dda
Author: Andrew Starr-Bochicchio <a....@gmail.com>
Authored: Sun Oct 15 13:06:06 2017 -0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Oct 16 10:24:58 2017 +0400

----------------------------------------------------------------------
 docs/examples/storage/digitalocean_spaces/v4sig.py | 8 ++++++++
 docs/storage/drivers/digitalocean_spaces.rst       | 7 +++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/be3d1e18/docs/examples/storage/digitalocean_spaces/v4sig.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/digitalocean_spaces/v4sig.py b/docs/examples/storage/digitalocean_spaces/v4sig.py
new file mode 100644
index 0000000..d370b33
--- /dev/null
+++ b/docs/examples/storage/digitalocean_spaces/v4sig.py
@@ -0,0 +1,8 @@
+from libcloud.storage.types import Provider
+from libcloud.storage.providers import get_driver
+
+cls = get_driver(Provider.DIGITALOCEAN_SPACES)
+
+driver = cls(key='DO_ACCESS_KEY',
+             secret='DO_SECRET_KEY',
+             signature_version='4')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/be3d1e18/docs/storage/drivers/digitalocean_spaces.rst
----------------------------------------------------------------------
diff --git a/docs/storage/drivers/digitalocean_spaces.rst b/docs/storage/drivers/digitalocean_spaces.rst
index 919cdc8..b8739fc 100644
--- a/docs/storage/drivers/digitalocean_spaces.rst
+++ b/docs/storage/drivers/digitalocean_spaces.rst
@@ -20,6 +20,13 @@ below.
 .. literalinclude:: /examples/storage/digitalocean_spaces/instantiate.py
    :language: python
 
+Spaces supports both the v2 and v4 AWS signature types. By default, this driver
+will use v2. You can configure it to use v4 by passing the ``signature_version``
+argument when instantiating the driver as shown below.
+
+.. literalinclude:: /examples/storage/digitalocean_spaces/v4sig.py
+   :language: python
+
 Specifying canned ACLs
 ~~~~~~~~~~~~~~~~~~~~~~
 


[4/5] libcloud git commit: Define contants and test for error states.

Posted by qu...@apache.org.
Define contants and test for error states.

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: 6d01dda509b0df827252f3106f8bfb7e933c3ad7
Parents: 24584e6
Author: Andrew Starr-Bochicchio <a....@gmail.com>
Authored: Sun Oct 15 13:05:22 2017 -0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Oct 16 10:24:58 2017 +0400

----------------------------------------------------------------------
 libcloud/storage/drivers/digitalocean_spaces.py   | 18 +++++++++---------
 libcloud/test/storage/test_digitalocean_spaces.py | 14 ++++++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/6d01dda5/libcloud/storage/drivers/digitalocean_spaces.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/digitalocean_spaces.py b/libcloud/storage/drivers/digitalocean_spaces.py
index 1808b4d..9f6768c 100644
--- a/libcloud/storage/drivers/digitalocean_spaces.py
+++ b/libcloud/storage/drivers/digitalocean_spaces.py
@@ -14,22 +14,23 @@
 # limitations under the License.
 
 from libcloud.common.types import LibcloudError
-from libcloud.common.aws import SignedAWSConnection, DEFAULT_SIGNATURE_VERSION
+from libcloud.common.aws import SignedAWSConnection
 from libcloud.storage.drivers.s3 import BaseS3Connection, S3Connection
-from libcloud.storage.drivers.s3 import S3StorageDriver, API_VERSION
+from libcloud.storage.drivers.s3 import S3StorageDriver
 
 __all__ = [
     'DigitalOceanSpacesStorageDriver'
 ]
 
 DO_SPACES_HOSTS_BY_REGION = {'nyc3': 'nyc3.digitaloceanspaces.com'}
-
 DO_SPACES_DEFAULT_REGION = 'nyc3'
+DEFAULT_SIGNATURE_VERSION = '2'
+S3_API_VERSION = '2006-03-01'
 
 
 class DOSpacesConnectionAWS4(SignedAWSConnection, BaseS3Connection):
     service_name = 's3'
-    version = API_VERSION
+    version = S3_API_VERSION
 
     def __init__(self, user_id, key, secure=True, host=None, port=None,
                  url=None, timeout=None, proxy_url=None, token=None,
@@ -42,7 +43,7 @@ class DOSpacesConnectionAWS4(SignedAWSConnection, BaseS3Connection):
                                                      proxy_url, token,
                                                      retry_delay,
                                                      backoff,
-                                                     4)  # force aws4
+                                                     signature_version=4)
 
 
 class DOSpacesConnectionAWS2(S3Connection):
@@ -79,14 +80,13 @@ class DigitalOceanSpacesStorageDriver(S3StorageDriver):
         self.signature_version = str(kwargs.pop('signature_version',
                                                 DEFAULT_SIGNATURE_VERSION))
 
-        if self.signature_version not in ['2', '4']:
-            raise ValueError('Invalid signature_version: %s' %
-                             (self.signature_version))
-
         if self.signature_version == '2':
             self.connectionCls = DOSpacesConnectionAWS2
         elif self.signature_version == '4':
             self.connectionCls = DOSpacesConnectionAWS4
+        else:
+            raise ValueError('Invalid signature_version: %s' %
+                             (self.signature_version))
         self.connectionCls.host = host
 
         super(DigitalOceanSpacesStorageDriver,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/6d01dda5/libcloud/test/storage/test_digitalocean_spaces.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_digitalocean_spaces.py b/libcloud/test/storage/test_digitalocean_spaces.py
index 47f4779..7c32deb 100644
--- a/libcloud/test/storage/test_digitalocean_spaces.py
+++ b/libcloud/test/storage/test_digitalocean_spaces.py
@@ -16,6 +16,8 @@
 import sys
 import unittest
 
+from libcloud.common.types import LibcloudError
+
 from libcloud.storage.base import Container, Object
 from libcloud.storage.drivers.digitalocean_spaces import (
     DigitalOceanSpacesStorageDriver,
@@ -67,6 +69,18 @@ class DigitalOceanSpacesTests(LibcloudTestCase):
         with self.assertRaises(NotImplementedError):
             self.object.get_cdn_url()
 
+    def test_invalid_signature_version(self):
+        with self.assertRaises(ValueError):
+            self.driver_type(*self.driver_args,
+                             signature_version='3',
+                             host=self.default_host)
+
+    def test_invalid_region(self):
+        with self.assertRaises(LibcloudError):
+            self.driver_type(*self.driver_args,
+                             region='atlantis',
+                             host=self.default_host)
+
 
 class DigitalOceanSpacesTests_v4(DigitalOceanSpacesTests):
     driver_type = DigitalOceanSpacesStorageDriver


[2/5] libcloud git commit: Add docs for DigitalOcean Spaces.

Posted by qu...@apache.org.
Add docs for DigitalOcean Spaces.

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: 24584e6d6aff0a8edbda39e47a75d038669c8dc1
Parents: 1bb5bed
Author: Andrew Starr-Bochicchio <a....@gmail.com>
Authored: Mon Oct 16 10:21:04 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Oct 16 10:24:58 2017 +0400

----------------------------------------------------------------------
 .../storage/digitalocean_spaces/__init__.py     |  0
 .../storage/digitalocean_spaces/instantiate.py  |  6 +++
 .../digitalocean_spaces/upload_object_acls.py   | 19 ++++++++
 docs/storage/_supported_methods_main.rst        |  2 +
 docs/storage/_supported_providers.rst           |  2 +
 docs/storage/drivers/digitalocean_spaces.rst    | 49 ++++++++++++++++++++
 6 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/examples/storage/digitalocean_spaces/__init__.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/digitalocean_spaces/__init__.py b/docs/examples/storage/digitalocean_spaces/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/examples/storage/digitalocean_spaces/instantiate.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/digitalocean_spaces/instantiate.py b/docs/examples/storage/digitalocean_spaces/instantiate.py
new file mode 100644
index 0000000..c882596
--- /dev/null
+++ b/docs/examples/storage/digitalocean_spaces/instantiate.py
@@ -0,0 +1,6 @@
+from libcloud.storage.types import Provider
+from libcloud.storage.providers import get_driver
+
+cls = get_driver(Provider.DIGITALOCEAN_SPACES)
+
+driver = cls(key='DO_ACCESS_KEY', secret='DO_SECRET_KEY')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/examples/storage/digitalocean_spaces/upload_object_acls.py
----------------------------------------------------------------------
diff --git a/docs/examples/storage/digitalocean_spaces/upload_object_acls.py b/docs/examples/storage/digitalocean_spaces/upload_object_acls.py
new file mode 100644
index 0000000..e5fe0bd
--- /dev/null
+++ b/docs/examples/storage/digitalocean_spaces/upload_object_acls.py
@@ -0,0 +1,19 @@
+from libcloud.storage.types import Provider
+from libcloud.storage.providers import get_driver
+
+FILE_PATH = '/home/user/myfile.tar.gz'
+
+cls = get_driver(Provider.DIGITALOCEAN_SPACES)
+driver = cls('api key', 'api secret key')
+
+container = driver.get_container(container_name='my-backups-12345')
+
+# This method blocks until all the parts have been uploaded.
+extra = {'content_type': 'application/octet-stream',
+         'acl': 'public-read'}
+
+with open(FILE_PATH, 'rb') as iterator:
+    obj = driver.upload_object_via_stream(iterator=iterator,
+                                          container=container,
+                                          object_name='backup.tar.gz',
+                                          extra=extra)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/storage/_supported_methods_main.rst
----------------------------------------------------------------------
diff --git a/docs/storage/_supported_methods_main.rst b/docs/storage/_supported_methods_main.rst
index 4f7eb96..0e377a2 100644
--- a/docs/storage/_supported_methods_main.rst
+++ b/docs/storage/_supported_methods_main.rst
@@ -8,6 +8,7 @@ Provider                      list containers list objects create container dele
 `Microsoft Azure (blobs)`_    yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
 `Backblaze B2`_               yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
 `CloudFiles`_                 yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
+`DigitalOcean Spaces`_        yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
 `Google Cloud Storage`_       yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
 `KTUCloud Storage`_           yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
 `Local Storage`_              yes             yes          yes              yes              yes           yes                     yes             yes                       yes          
@@ -40,6 +41,7 @@ Provider                      list containers list objects create container dele
 .. _`Microsoft Azure (blobs)`: http://windows.azure.com/
 .. _`Backblaze B2`: https://www.backblaze.com/b2/
 .. _`CloudFiles`: http://www.rackspace.com/
+.. _`DigitalOcean Spaces`: https://www.digitalocean.com/products/object-storage/
 .. _`Google Cloud Storage`: http://cloud.google.com/storage
 .. _`KTUCloud Storage`: http://www.rackspace.com/
 .. _`Local Storage`: http://example.com

http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/storage/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/storage/_supported_providers.rst b/docs/storage/_supported_providers.rst
index 482d49a..7c8687b 100644
--- a/docs/storage/_supported_providers.rst
+++ b/docs/storage/_supported_providers.rst
@@ -8,6 +8,7 @@ Provider                      Documentation
 `Microsoft Azure (blobs)`_    :doc:`Click </storage/drivers/azure_blobs>`         AZURE_BLOBS         single region driver         :mod:`libcloud.storage.drivers.azure_blobs`         :class:`AzureBlobsStorageDriver`        
 `Backblaze B2`_               :doc:`Click </storage/drivers/backblaze_b2>`        BACKBLAZE_B2        single region driver         :mod:`libcloud.storage.drivers.backblaze_b2`        :class:`BackblazeB2StorageDriver`       
 `CloudFiles`_                                                                     CLOUDFILES          dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.cloudfiles`          :class:`CloudFilesStorageDriver`        
+`DigitalOcean Spaces`_        :doc:`Click </storage/drivers/digitalocean_spaces>` DIGITALOCEAN_SPACES single region driver         :mod:`libcloud.storage.drivers.digitalocean_spaces` :class:`DigitalOceanSpacesStorageDriver`
 `Google Cloud Storage`_       :doc:`Click </storage/drivers/google_storage>`      GOOGLE_STORAGE      single region driver         :mod:`libcloud.storage.drivers.google_storage`      :class:`GoogleStorageDriver`            
 `KTUCloud Storage`_                                                               KTUCLOUD            dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.ktucloud`            :class:`KTUCloudStorageDriver`          
 `Local Storage`_                                                                  LOCAL               single region driver         :mod:`libcloud.storage.drivers.local`               :class:`LocalStorageDriver`             
@@ -40,6 +41,7 @@ Provider                      Documentation
 .. _`Microsoft Azure (blobs)`: http://windows.azure.com/
 .. _`Backblaze B2`: https://www.backblaze.com/b2/
 .. _`CloudFiles`: http://www.rackspace.com/
+.. _`DigitalOcean Spaces`: https://www.digitalocean.com/products/object-storage/
 .. _`Google Cloud Storage`: http://cloud.google.com/storage
 .. _`KTUCloud Storage`: http://www.rackspace.com/
 .. _`Local Storage`: http://example.com

http://git-wip-us.apache.org/repos/asf/libcloud/blob/24584e6d/docs/storage/drivers/digitalocean_spaces.rst
----------------------------------------------------------------------
diff --git a/docs/storage/drivers/digitalocean_spaces.rst b/docs/storage/drivers/digitalocean_spaces.rst
new file mode 100644
index 0000000..919cdc8
--- /dev/null
+++ b/docs/storage/drivers/digitalocean_spaces.rst
@@ -0,0 +1,49 @@
+DigitalOcean Spaces Storage Driver Documentation
+================================================
+
+`Spaces`_ is an `S3-interoperable`_ object storage service from cloud provider
+DigitalOcean.
+
+Connecting to Spaces
+--------------------
+
+To connect to DigitalOcean Spaces you need an access key and secret key. These
+can be retrieved on the "`Applications & API`_" page of the DigitalOcean control
+panel.
+
+Instantiating a driver
+~~~~~~~~~~~~~~~~~~~~~~
+
+Once you have obtained your credentials you can instantiate the driver as shown
+below.
+
+.. literalinclude:: /examples/storage/digitalocean_spaces/instantiate.py
+   :language: python
+
+Specifying canned ACLs
+~~~~~~~~~~~~~~~~~~~~~~
+
+Spaces supports a limited set of canned ACLs. In order to specify an ACL when
+uploading an object, you can pass an ``extra`` argument with the ``acl``
+attribute to the upload methods.
+
+For example:
+
+.. literalinclude:: /examples/storage/digitalocean_spaces/upload_object_acls.py
+   :language: python
+
+At this time, valid values for this attribute are only:
+
+* ``private`` (default)
+* ``public-read``
+
+API Docs
+--------
+
+.. autoclass:: libcloud.storage.drivers.digitalocean_spaces.DigitalOceanSpacesStorageDriver
+    :members:
+    :inherited-members:
+
+.. _`Spaces`: https://www.digitalocean.com/products/object-storage/
+.. _`Applications & API`: https://cloud.digitalocean.com/settings/api/tokens
+.. _`S3-interoperable`: https://developers.digitalocean.com/documentation/spaces/
\ No newline at end of file


[5/5] libcloud git commit: Update supported providers table

Posted by qu...@apache.org.
Update supported providers table

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: 1bb5bed7edcdd37f2df42c71948ebae9b0903fb5
Parents: 79052a0
Author: Andrew Starr-Bochicchio <a....@gmail.com>
Authored: Mon Oct 16 10:19:45 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Oct 16 10:24:58 2017 +0400

----------------------------------------------------------------------
 docs/storage/_supported_providers.rst | 68 +++++++++++++++---------------
 1 file changed, 34 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1bb5bed7/docs/storage/_supported_providers.rst
----------------------------------------------------------------------
diff --git a/docs/storage/_supported_providers.rst b/docs/storage/_supported_providers.rst
index 8f7f51e..482d49a 100644
--- a/docs/storage/_supported_providers.rst
+++ b/docs/storage/_supported_providers.rst
@@ -1,39 +1,39 @@
 .. NOTE: This file has been generated automatically using generate_provider_feature_matrix_table.py script, don't manually edit it
 
-============================= =============================================== ================= ============================ ============================================== ====================================
-Provider                      Documentation                                   Provider Constant Supported Regions            Module                                         Class Name                          
-============================= =============================================== ================= ============================ ============================================== ====================================
-`Aliyun OSS`_                                                                 ALIYUN_OSS        single region driver         :mod:`libcloud.storage.drivers.oss`            :class:`OSSStorageDriver`           
-`PCextreme AuroraObjects`_    :doc:`Click </storage/drivers/auroraobjects>`   AURORAOBJECTS     single region driver         :mod:`libcloud.storage.drivers.auroraobjects`  :class:`AuroraObjectsStorageDriver` 
-`Microsoft Azure (blobs)`_    :doc:`Click </storage/drivers/azure_blobs>`     AZURE_BLOBS       single region driver         :mod:`libcloud.storage.drivers.azure_blobs`    :class:`AzureBlobsStorageDriver`    
-`Backblaze B2`_               :doc:`Click </storage/drivers/backblaze_b2>`    BACKBLAZE_B2      single region driver         :mod:`libcloud.storage.drivers.backblaze_b2`   :class:`BackblazeB2StorageDriver`   
-`CloudFiles`_                                                                 CLOUDFILES        dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.cloudfiles`     :class:`CloudFilesStorageDriver`    
-`Google Cloud Storage`_       :doc:`Click </storage/drivers/google_storage>`  GOOGLE_STORAGE    single region driver         :mod:`libcloud.storage.drivers.google_storage` :class:`GoogleStorageDriver`        
-`KTUCloud Storage`_                                                           KTUCLOUD          dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.ktucloud`       :class:`KTUCloudStorageDriver`      
-`Local Storage`_                                                              LOCAL             single region driver         :mod:`libcloud.storage.drivers.local`          :class:`LocalStorageDriver`         
-`Nimbus.io`_                                                                  NIMBUS            single region driver         :mod:`libcloud.storage.drivers.nimbus`         :class:`NimbusStorageDriver`        
-`Ninefold`_                                                                   NINEFOLD          single region driver         :mod:`libcloud.storage.drivers.ninefold`       :class:`NinefoldStorageDriver`      
-`OpenStack Swift`_            :doc:`Click </storage/drivers/openstack_swift>` OPENSTACK_SWIFT   dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.cloudfiles`     :class:`OpenStackSwiftStorageDriver`
-`Amazon S3 (us-east-1)`_      :doc:`Click </storage/drivers/s3>`              S3                single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3StorageDriver`            
-`Amazon S3 (ap-northeast-1)`_                                                 S3_AP_NORTHEAST   single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APNE1StorageDriver`       
-`Amazon S3 (ap-northeast-1)`_                                                 S3_AP_NORTHEAST1  single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APNE1StorageDriver`       
-`Amazon S3 (ap-northeast-2)`_                                                 S3_AP_NORTHEAST2  single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APNE2StorageDriver`       
-`Amazon S3 (ap-south-1)`_                                                     S3_AP_SOUTH       single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APSouthStorageDriver`     
-`Amazon S3 (ap-southeast-1)`_                                                 S3_AP_SOUTHEAST   single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APSEStorageDriver`        
-`Amazon S3 (ap-southeast-2)`_                                                 S3_AP_SOUTHEAST2  single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3APSE2StorageDriver`       
-`Amazon S3 (ca-central-1)`_                                                   S3_CA_CENTRAL     single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3CACentralStorageDriver`   
-`Amazon S3 (cn-north-1)`_                                                     S3_CN_NORTH       single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3CNNorthStorageDriver`     
-`Amazon S3 (eu-central-1)`_                                                   S3_EU_CENTRAL     single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3EUCentralStorageDriver`   
-`Amazon S3 (eu-west-1)`_                                                      S3_EU_WEST        single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3EUWestStorageDriver`      
-`Amazon S3 (eu-west-2)`_                                                      S3_EU_WEST2       single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3EUWest2StorageDriver`     
-`Ceph RGW`_                                                                   S3_RGW            single region driver         :mod:`libcloud.storage.drivers.rgw`            :class:`S3RGWStorageDriver`         
-`RGW Outscale`_                                                               S3_RGW_OUTSCALE   single region driver         :mod:`libcloud.storage.drivers.rgw`            :class:`S3RGWOutscaleStorageDriver` 
-`Amazon S3 (sa-east-1)`_                                                      S3_SA_EAST        single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3SAEastStorageDriver`      
-`Amazon S3 (us-east-2)`_                                                      S3_US_EAST2       single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3USEast2StorageDriver`     
-`Amazon S3 (us-gov-west-1)`_                                                  S3_US_GOV_WEST    single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3USGovWestStorageDriver`   
-`Amazon S3 (us-west-1)`_                                                      S3_US_WEST        single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3USWestStorageDriver`      
-`Amazon S3 (us-west-2)`_                                                      S3_US_WEST_OREGON single region driver         :mod:`libcloud.storage.drivers.s3`             :class:`S3USWestOregonStorageDriver`
-============================= =============================================== ================= ============================ ============================================== ====================================
+============================= =================================================== =================== ============================ =================================================== ========================================
+Provider                      Documentation                                       Provider Constant   Supported Regions            Module                                              Class Name                              
+============================= =================================================== =================== ============================ =================================================== ========================================
+`Aliyun OSS`_                                                                     ALIYUN_OSS          single region driver         :mod:`libcloud.storage.drivers.oss`                 :class:`OSSStorageDriver`               
+`PCextreme AuroraObjects`_    :doc:`Click </storage/drivers/auroraobjects>`       AURORAOBJECTS       single region driver         :mod:`libcloud.storage.drivers.auroraobjects`       :class:`AuroraObjectsStorageDriver`     
+`Microsoft Azure (blobs)`_    :doc:`Click </storage/drivers/azure_blobs>`         AZURE_BLOBS         single region driver         :mod:`libcloud.storage.drivers.azure_blobs`         :class:`AzureBlobsStorageDriver`        
+`Backblaze B2`_               :doc:`Click </storage/drivers/backblaze_b2>`        BACKBLAZE_B2        single region driver         :mod:`libcloud.storage.drivers.backblaze_b2`        :class:`BackblazeB2StorageDriver`       
+`CloudFiles`_                                                                     CLOUDFILES          dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.cloudfiles`          :class:`CloudFilesStorageDriver`        
+`Google Cloud Storage`_       :doc:`Click </storage/drivers/google_storage>`      GOOGLE_STORAGE      single region driver         :mod:`libcloud.storage.drivers.google_storage`      :class:`GoogleStorageDriver`            
+`KTUCloud Storage`_                                                               KTUCLOUD            dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.ktucloud`            :class:`KTUCloudStorageDriver`          
+`Local Storage`_                                                                  LOCAL               single region driver         :mod:`libcloud.storage.drivers.local`               :class:`LocalStorageDriver`             
+`Nimbus.io`_                                                                      NIMBUS              single region driver         :mod:`libcloud.storage.drivers.nimbus`              :class:`NimbusStorageDriver`            
+`Ninefold`_                                                                       NINEFOLD            single region driver         :mod:`libcloud.storage.drivers.ninefold`            :class:`NinefoldStorageDriver`          
+`OpenStack Swift`_            :doc:`Click </storage/drivers/openstack_swift>`     OPENSTACK_SWIFT     dfw, hkg, iad, lon, ord, syd :mod:`libcloud.storage.drivers.cloudfiles`          :class:`OpenStackSwiftStorageDriver`    
+`Amazon S3 (us-east-1)`_      :doc:`Click </storage/drivers/s3>`                  S3                  single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3StorageDriver`                
+`Amazon S3 (ap-northeast-1)`_                                                     S3_AP_NORTHEAST     single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APNE1StorageDriver`           
+`Amazon S3 (ap-northeast-1)`_                                                     S3_AP_NORTHEAST1    single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APNE1StorageDriver`           
+`Amazon S3 (ap-northeast-2)`_                                                     S3_AP_NORTHEAST2    single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APNE2StorageDriver`           
+`Amazon S3 (ap-south-1)`_                                                         S3_AP_SOUTH         single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APSouthStorageDriver`         
+`Amazon S3 (ap-southeast-1)`_                                                     S3_AP_SOUTHEAST     single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APSEStorageDriver`            
+`Amazon S3 (ap-southeast-2)`_                                                     S3_AP_SOUTHEAST2    single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3APSE2StorageDriver`           
+`Amazon S3 (ca-central-1)`_                                                       S3_CA_CENTRAL       single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3CACentralStorageDriver`       
+`Amazon S3 (cn-north-1)`_                                                         S3_CN_NORTH         single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3CNNorthStorageDriver`         
+`Amazon S3 (eu-central-1)`_                                                       S3_EU_CENTRAL       single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3EUCentralStorageDriver`       
+`Amazon S3 (eu-west-1)`_                                                          S3_EU_WEST          single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3EUWestStorageDriver`          
+`Amazon S3 (eu-west-2)`_                                                          S3_EU_WEST2         single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3EUWest2StorageDriver`         
+`Ceph RGW`_                                                                       S3_RGW              single region driver         :mod:`libcloud.storage.drivers.rgw`                 :class:`S3RGWStorageDriver`             
+`RGW Outscale`_                                                                   S3_RGW_OUTSCALE     single region driver         :mod:`libcloud.storage.drivers.rgw`                 :class:`S3RGWOutscaleStorageDriver`     
+`Amazon S3 (sa-east-1)`_                                                          S3_SA_EAST          single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3SAEastStorageDriver`          
+`Amazon S3 (us-east-2)`_                                                          S3_US_EAST2         single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3USEast2StorageDriver`         
+`Amazon S3 (us-gov-west-1)`_                                                      S3_US_GOV_WEST      single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3USGovWestStorageDriver`       
+`Amazon S3 (us-west-1)`_                                                          S3_US_WEST          single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3USWestStorageDriver`          
+`Amazon S3 (us-west-2)`_                                                          S3_US_WEST_OREGON   single region driver         :mod:`libcloud.storage.drivers.s3`                  :class:`S3USWestOregonStorageDriver`    
+============================= =================================================== =================== ============================ =================================================== ========================================
 
 .. _`Aliyun OSS`: http://www.aliyun.com/product/oss
 .. _`PCextreme AuroraObjects`: https://www.pcextreme.com/aurora/objects


[3/5] libcloud git commit: [LIBCLOUD-955] Add DigitalOcean Spaces support.

Posted by qu...@apache.org.
[LIBCLOUD-955] Add DigitalOcean Spaces support.

Signed-off-by: Quentin Pradet <qu...@apache.org>


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

Branch: refs/heads/trunk
Commit: 79052a080f87a436f27701db7429fa7dcb11d433
Parents: 820ff6f
Author: Andrew Starr-Bochicchio <a....@gmail.com>
Authored: Fri Oct 6 15:59:48 2017 -0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Oct 16 10:24:58 2017 +0400

----------------------------------------------------------------------
 libcloud/storage/drivers/digitalocean_spaces.py | 101 +++++++++++++++
 libcloud/storage/providers.py                   |   3 +
 libcloud/storage/types.py                       |   1 +
 .../test/storage/test_digitalocean_spaces.py    | 122 +++++++++++++++++++
 4 files changed, 227 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/79052a08/libcloud/storage/drivers/digitalocean_spaces.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/digitalocean_spaces.py b/libcloud/storage/drivers/digitalocean_spaces.py
new file mode 100644
index 0000000..1808b4d
--- /dev/null
+++ b/libcloud/storage/drivers/digitalocean_spaces.py
@@ -0,0 +1,101 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from libcloud.common.types import LibcloudError
+from libcloud.common.aws import SignedAWSConnection, DEFAULT_SIGNATURE_VERSION
+from libcloud.storage.drivers.s3 import BaseS3Connection, S3Connection
+from libcloud.storage.drivers.s3 import S3StorageDriver, API_VERSION
+
+__all__ = [
+    'DigitalOceanSpacesStorageDriver'
+]
+
+DO_SPACES_HOSTS_BY_REGION = {'nyc3': 'nyc3.digitaloceanspaces.com'}
+
+DO_SPACES_DEFAULT_REGION = 'nyc3'
+
+
+class DOSpacesConnectionAWS4(SignedAWSConnection, BaseS3Connection):
+    service_name = 's3'
+    version = API_VERSION
+
+    def __init__(self, user_id, key, secure=True, host=None, port=None,
+                 url=None, timeout=None, proxy_url=None, token=None,
+                 retry_delay=None, backoff=None, **kwargs):
+
+        super(DOSpacesConnectionAWS4, self).__init__(user_id, key,
+                                                     secure, host,
+                                                     port, url,
+                                                     timeout,
+                                                     proxy_url, token,
+                                                     retry_delay,
+                                                     backoff,
+                                                     4)  # force aws4
+
+
+class DOSpacesConnectionAWS2(S3Connection):
+
+    def __init__(self, user_id, key, secure=True, host=None, port=None,
+                 url=None, timeout=None, proxy_url=None, token=None,
+                 retry_delay=None, backoff=None, **kwargs):
+
+        super(DOSpacesConnectionAWS2, self).__init__(user_id, key,
+                                                     secure, host,
+                                                     port, url,
+                                                     timeout,
+                                                     proxy_url, token,
+                                                     retry_delay,
+                                                     backoff)
+
+
+class DigitalOceanSpacesStorageDriver(S3StorageDriver):
+    name = 'DigitalOcean Spaces'
+    website = 'https://www.digitalocean.com/products/object-storage/'
+    supports_chunked_encoding = False
+    supports_s3_multipart_upload = True
+
+    def __init__(self, key, secret=None, secure=True, host=None, port=None,
+                 api_version=None, region=DO_SPACES_DEFAULT_REGION, **kwargs):
+
+        if region not in DO_SPACES_HOSTS_BY_REGION:
+            raise LibcloudError('Unknown region (%s)' % (region), driver=self)
+
+        host = DO_SPACES_HOSTS_BY_REGION[region]
+        self.name = 'DigitalOcean Spaces (%s)' % (region)
+
+        self.region_name = region
+        self.signature_version = str(kwargs.pop('signature_version',
+                                                DEFAULT_SIGNATURE_VERSION))
+
+        if self.signature_version not in ['2', '4']:
+            raise ValueError('Invalid signature_version: %s' %
+                             (self.signature_version))
+
+        if self.signature_version == '2':
+            self.connectionCls = DOSpacesConnectionAWS2
+        elif self.signature_version == '4':
+            self.connectionCls = DOSpacesConnectionAWS4
+        self.connectionCls.host = host
+
+        super(DigitalOceanSpacesStorageDriver,
+              self).__init__(key, secret,
+                             secure, host, port,
+                             api_version, region,
+                             **kwargs)
+
+    def _ex_connection_class_kwargs(self):
+        kwargs = {}
+        kwargs['signature_version'] = self.signature_version
+        return kwargs

http://git-wip-us.apache.org/repos/asf/libcloud/blob/79052a08/libcloud/storage/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/providers.py b/libcloud/storage/providers.py
index 56b049e..183189e 100644
--- a/libcloud/storage/providers.py
+++ b/libcloud/storage/providers.py
@@ -81,6 +81,9 @@ DRIVERS = {
     ('libcloud.storage.drivers.backblaze_b2', 'BackblazeB2StorageDriver'),
     Provider.ALIYUN_OSS:
     ('libcloud.storage.drivers.oss', 'OSSStorageDriver'),
+    Provider.DIGITALOCEAN_SPACES:
+    ('libcloud.storage.drivers.digitalocean_spaces',
+     'DigitalOceanSpacesStorageDriver'),
 }
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/79052a08/libcloud/storage/types.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/types.py b/libcloud/storage/types.py
index c093a0b..c9e7451 100644
--- a/libcloud/storage/types.py
+++ b/libcloud/storage/types.py
@@ -62,6 +62,7 @@ class Provider(object):
     AZURE_BLOBS = 'azure_blobs'
     BACKBLAZE_B2 = 'backblaze_b2'
     CLOUDFILES = 'cloudfiles'
+    DIGITALOCEAN_SPACES = 'digitalocean_spaces'
     GOOGLE_STORAGE = 'google_storage'
     KTUCLOUD = 'ktucloud'
     LOCAL = 'local'

http://git-wip-us.apache.org/repos/asf/libcloud/blob/79052a08/libcloud/test/storage/test_digitalocean_spaces.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_digitalocean_spaces.py b/libcloud/test/storage/test_digitalocean_spaces.py
new file mode 100644
index 0000000..47f4779
--- /dev/null
+++ b/libcloud/test/storage/test_digitalocean_spaces.py
@@ -0,0 +1,122 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+import unittest
+
+from libcloud.storage.base import Container, Object
+from libcloud.storage.drivers.digitalocean_spaces import (
+    DigitalOceanSpacesStorageDriver,
+    DOSpacesConnectionAWS4,
+    DOSpacesConnectionAWS2)
+
+from libcloud.test import LibcloudTestCase
+from libcloud.test.secrets import STORAGE_S3_PARAMS
+
+
+class DigitalOceanSpacesTests(LibcloudTestCase):
+    driver_type = DigitalOceanSpacesStorageDriver
+    driver_args = STORAGE_S3_PARAMS
+    default_host = 'nyc3.digitaloceanspaces.com'
+
+    @classmethod
+    def create_driver(self):
+        return self.driver_type(*self.driver_args,
+                                signature_version='2',
+                                host=self.default_host)
+
+    def setUp(self):
+        self.driver = self.create_driver()
+        self.container = Container('test-container', {}, self.driver)
+        self.object = Object('test-object', 1, 'hash', {},
+                             'meta_data', self.container, self.driver)
+
+    def test_connection_class_type(self):
+        res = self.driver.connectionCls is DOSpacesConnectionAWS2
+        self.assertTrue(res, 'driver.connectionCls does not match!')
+
+    def test_connection_class_host(self):
+        host = self.driver.connectionCls.host
+        self.assertEqual(host, self.default_host)
+
+    def test_container_enable_cdn_not_implemented(self):
+        with self.assertRaises(NotImplementedError):
+            self.container.enable_cdn()
+
+    def test_container_get_cdn_url_not_implemented(self):
+        with self.assertRaises(NotImplementedError):
+            self.container.get_cdn_url()
+
+    def test_object_enable_cdn_not_implemented(self):
+        with self.assertRaises(NotImplementedError):
+            self.object.enable_cdn()
+
+    def test_object_get_cdn_url_not_implemented(self):
+        with self.assertRaises(NotImplementedError):
+            self.object.get_cdn_url()
+
+
+class DigitalOceanSpacesTests_v4(DigitalOceanSpacesTests):
+    driver_type = DigitalOceanSpacesStorageDriver
+    driver_args = STORAGE_S3_PARAMS
+    default_host = 'nyc3.digitaloceanspaces.com'
+
+    @classmethod
+    def create_driver(self):
+        return self.driver_type(*self.driver_args,
+                                signature_version='4')
+
+    def test_connection_class_type(self):
+        res = self.driver.connectionCls is DOSpacesConnectionAWS4
+        self.assertTrue(res, 'driver.connectionCls does not match!')
+
+    def test_connection_class_host(self):
+        host = self.driver.connectionCls.host
+        self.assertEqual(host, self.default_host)
+
+
+class DigitalOceanSpacesDoubleInstanceTests(LibcloudTestCase):
+    driver_type = DigitalOceanSpacesStorageDriver
+    driver_args = STORAGE_S3_PARAMS
+    default_host = 'nyc3.digitaloceanspaces.com'
+
+    def setUp(self):
+        self.driver_v2 = self.driver_type(*self.driver_args,
+                                          signature_version='2')
+        self.driver_v4 = self.driver_type(*self.driver_args,
+                                          signature_version='4')
+
+    def test_connection_class_type(self):
+        res = self.driver_v2.connectionCls is DOSpacesConnectionAWS2
+        self.assertTrue(res, 'driver.connectionCls does not match!')
+
+        res = self.driver_v4.connectionCls is DOSpacesConnectionAWS4
+        self.assertTrue(res, 'driver.connectionCls does not match!')
+
+        # Verify again that connection class hasn't been overriden when
+        # instantiating a second driver class
+        res = self.driver_v2.connectionCls is DOSpacesConnectionAWS2
+        self.assertTrue(res, 'driver.connectionCls does not match!')
+
+    def test_connection_class_host(self):
+        host = self.driver_v2.connectionCls.host
+        self.assertEqual(host, self.default_host)
+
+        host = self.driver_v4.connectionCls.host
+        self.assertEqual(host, self.default_host)
+
+
+if __name__ == '__main__':
+    sys.exit(unittest.main())