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/24 23:53:48 UTC

[1/2] git commit: supporting internalURL for cloudfiles

Updated Branches:
  refs/heads/trunk 8d529766d -> dcf3c6714


supporting internalURL for cloudfiles

re-working `use_internal_url` in declaration, adding test case for endpoint variable

lint white-space fix

lint white-space fix

match indent to the first character of first arg

Signed-off-by: Tomaz Muraus <to...@apache.org>


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

Branch: refs/heads/trunk
Commit: 70f1554c132f797f4c599d9d054900c99ae2a4f6
Parents: 8d52976
Author: John Obelenus <jo...@gmail.com>
Authored: Fri Dec 6 11:04:23 2013 -0500
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 24 23:16:15 2014 +0100

----------------------------------------------------------------------
 libcloud/storage/drivers/cloudfiles.py   | 16 ++++++++++------
 libcloud/test/storage/test_cloudfiles.py |  8 ++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/70f1554c/libcloud/storage/drivers/cloudfiles.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/cloudfiles.py b/libcloud/storage/drivers/cloudfiles.py
index d6e7742..8d52c00 100644
--- a/libcloud/storage/drivers/cloudfiles.py
+++ b/libcloud/storage/drivers/cloudfiles.py
@@ -106,12 +106,14 @@ class CloudFilesConnection(OpenStackBaseConnection):
     auth_url = AUTH_URL
     _auth_version = '2.0'
 
-    def __init__(self, user_id, key, secure=True, **kwargs):
+    def __init__(self, user_id, key, secure=True,
+                 use_internal_url=False, **kwargs):
         super(CloudFilesConnection, self).__init__(user_id, key, secure=secure,
                                                    **kwargs)
         self.api_version = API_VERSION
         self.accept_format = 'application/json'
         self.cdn_request = False
+        self.endpoint_url = 'internalURL' if use_internal_url else 'publicURL'
 
     def get_endpoint(self):
         region = self._ex_force_service_region.upper()
@@ -136,8 +138,8 @@ class CloudFilesConnection(OpenStackBaseConnection):
         if not ep:
             raise LibcloudError('Could not find specified endpoint')
 
-        if 'publicURL' in ep:
-            return ep['publicURL']
+        if self.endpoint_url in ep:
+            return ep[self.endpoint_url]
         else:
             raise LibcloudError('Could not find specified endpoint')
 
@@ -182,8 +184,8 @@ class OpenStackSwiftConnection(CloudFilesConnection):
             endpoint = self.service_catalog.get_endpoint(
                 name=self._service_name, region=self._region_name)
 
-        if 'publicURL' in endpoint:
-            return endpoint['publicURL']
+        if self.endpoint_url in endpoint:
+            return endpoint[self.endpoint_url]
         else:
             raise LibcloudError('Could not find specified endpoint')
 
@@ -200,7 +202,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
     supports_chunked_encoding = True
 
     def __init__(self, key, secret=None, secure=True, host=None, port=None,
-                 region='ord', **kwargs):
+                 region='ord', use_internal_url=False, **kwargs):
         """
         @inherits:  :class:`StorageDriver.__init__`
 
@@ -211,6 +213,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
         if 'ex_force_service_region' in kwargs:
             region = kwargs['ex_force_service_region']
 
+        self.use_internal_url = use_internal_url
         OpenStackDriverMixin.__init__(self, (), **kwargs)
         super(CloudFilesStorageDriver, self).__init__(key=key, secret=secret,
                                                       secure=secure, host=host,
@@ -820,6 +823,7 @@ class CloudFilesStorageDriver(StorageDriver, OpenStackDriverMixin):
     def _ex_connection_class_kwargs(self):
         kwargs = self.openstack_connection_kwargs()
         kwargs['ex_force_service_region'] = self.region
+        kwargs['use_internal_url'] = self.use_internal_url
         return kwargs
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/70f1554c/libcloud/test/storage/test_cloudfiles.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_cloudfiles.py b/libcloud/test/storage/test_cloudfiles.py
index c71b71e..5f683fb 100644
--- a/libcloud/test/storage/test_cloudfiles.py
+++ b/libcloud/test/storage/test_cloudfiles.py
@@ -138,6 +138,14 @@ class CloudFilesTests(unittest.TestCase):
             self.driver.connection.get_endpoint())
         self.driver.connection.cdn_request = False
 
+    def test_endpoint_pointer(self):
+        kwargs = {'use_internal_url': False}
+        driver = CloudFilesStorageDriver('driver', 'dummy', **kwargs)
+        self.assertEquals(driver.connection.endpoint_url, 'publicURL')
+        kwargs = {'use_internal_url': True}
+        driver = CloudFilesStorageDriver('driver', 'dummy', **kwargs)
+        self.assertEquals(driver.connection.endpoint_url, 'internalURL')
+
     def test_list_containers(self):
         CloudFilesMockHttp.type = 'EMPTY'
         containers = self.driver.list_containers()


[2/2] git commit: Update changes.

Posted by to...@apache.org.
Update changes.


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

Branch: refs/heads/trunk
Commit: dcf3c671466b36ebdf5b2752f75ad97816550755
Parents: 70f1554
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Jan 24 23:26:42 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Jan 24 23:26:42 2014 +0100

----------------------------------------------------------------------
 CHANGES.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/dcf3c671/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index dcde99b..cccd238 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -11,6 +11,14 @@ Load Balancer
   in the GCE driver.
   [Rick Wright]
 
+Storage
+~~~~~~~
+
+- Allow user to use an internal endpoint in the CloudFiles driver by passing
+  "use_internal_url" argument to the driver constructor.
+  (GITHUB-229)
+  [John Obelenus]
+
 DNS
 ~~~