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 2012/11/18 02:31:28 UTC

svn commit: r1410810 - in /libcloud/branches/0.11.x/libcloud: storage/drivers/cloudfiles.py test/storage/test_cloudfiles.py

Author: tomaz
Date: Sun Nov 18 01:31:27 2012
New Revision: 1410810

URL: http://svn.apache.org/viewvc?rev=1410810&view=rev
Log:
Hook up ex_force_service_region argument in the CloudFiles driver. Contributed
by Dan Di Spaltro, part of LIBCLOUD-260.

Modified:
    libcloud/branches/0.11.x/libcloud/storage/drivers/cloudfiles.py
    libcloud/branches/0.11.x/libcloud/test/storage/test_cloudfiles.py

Modified: libcloud/branches/0.11.x/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.11.x/libcloud/storage/drivers/cloudfiles.py?rev=1410810&r1=1410809&r2=1410810&view=diff
==============================================================================
--- libcloud/branches/0.11.x/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/branches/0.11.x/libcloud/storage/drivers/cloudfiles.py Sun Nov 18 01:31:27 2012
@@ -112,6 +112,8 @@ class CloudFilesConnection(OpenStackBase
         self.api_version = API_VERSION
         self.accept_format = 'application/json'
         self.cdn_request = False
+        if self._ex_force_service_region:
+            self.service_region = self._ex_force_service_region
 
     def get_endpoint(self):
         # First, we parse out both files and cdn endpoints
@@ -131,6 +133,13 @@ class CloudFilesConnection(OpenStackBase
         if self.cdn_request:
             eps = cdn_eps
 
+        if self.service_region:
+            _eps = []
+            for ep in eps:
+                if ep['region'].lower() == self.service_region.lower():
+                    _eps.append(ep)
+            eps = _eps
+
         if len(eps) == 0:
             raise LibcloudError('Could not find specified endpoint')
 

Modified: libcloud/branches/0.11.x/libcloud/test/storage/test_cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.11.x/libcloud/test/storage/test_cloudfiles.py?rev=1410810&r1=1410809&r2=1410810&view=diff
==============================================================================
--- libcloud/branches/0.11.x/libcloud/test/storage/test_cloudfiles.py (original)
+++ libcloud/branches/0.11.x/libcloud/test/storage/test_cloudfiles.py Sun Nov 18 01:31:27 2012
@@ -82,6 +82,23 @@ class CloudFilesTests(unittest.TestCase)
         self.assertEquals('/v1/MossoCloudFS',
             driver.connection.request_path)
 
+    def test_invalid_ex_force_service_region(self):
+        driver = CloudFilesStorageDriver('driver', 'dummy',
+                ex_force_service_region='invalid')
+
+        try:
+            driver.list_containers()
+        except:
+            e = sys.exc_info()[1]
+            self.assertEquals(e.value, 'Could not find specified endpoint')
+        else:
+            self.fail('Exception was not thrown')
+
+    def test_ex_force_service_region(self):
+        driver = CloudFilesStorageDriver('driver', 'dummy',
+                ex_force_service_region='ORD')
+        driver.list_containers()
+
     def test_force_auth_url_kwargs(self):
         kwargs = {
             'ex_force_auth_version': '2.0',