Author: tomaz
Date: Sun Jun  3 07:34:56 2012
New Revision: 1345628

URL: http://svn.apache.org/viewvc?rev=1345628&view=rev
Log:
Fix a bug in the CloudFiles driver which prevented it to work with
accounts which use a non ORD endpoint. Contributed by Geoff Greer, part of
LIBCLOUD-205.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/common/openstack.py
    libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
    libcloud/trunk/test/storage/test_cloudfiles.py

Modified: libcloud/trunk/CHANGES
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1345628&r1=1345627&r2=1345628&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Sun Jun  3 07:34:56 2012
@@ -30,6 +30,10 @@ Changes with Apache Libcloud in developm
       returns no images. ; LIBCLOUD-202
       [Gabriel Reid]
 
+    - Add force_ipv4 argument to _wait_until_running and default it to True.
+      This will make Libcloud ignore IPv6 addresses when using deploy_node.
+      [Jay Doane, Tomaz muraus]
+
   *) DNS
 
     - Add support for GEO RecordType to Zerigo driver. ; LIBCLOUD-203
@@ -47,6 +51,10 @@ Changes with Apache Libcloud in developm
       - Amazon S3
       [Tomaz Muraus]
 
+    - Fix a bug in the CloudFiles driver which prevented it to work with
+      accounts which use a non ORD endpoint. ; LIBCLOUD-205
+      [Geoff Greer]
+
 Changes with Apache Libcloud 0.10.1:
 
   *) General:

Modified: libcloud/trunk/libcloud/common/openstack.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/openstack.py?rev=1345628&r1=1345627&r2=1345628&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/openstack.py (original)
+++ libcloud/trunk/libcloud/common/openstack.py Sun Jun  3 07:34:56 2012
@@ -259,6 +259,19 @@ class OpenStackServiceCatalog(object):
             raise LibcloudError('auth version "%s" not supported'
                                 % (self._auth_version))
 
+    def get_endpoints(self, service_type=None, name=None):
+        eps = []
+
+        if '2.0' in self._auth_version:
+            endpoints = self._service_catalog.get(service_type, {}).get(name, 
{})
+        elif ('1.1' in self._auth_version) or ('1.0' in self._auth_version):
+            endpoints = self._service_catalog.get(name, {})
+
+        for regionName, values in endpoints.items():
+            eps.append(values[0])
+
+        return eps
+
     def get_endpoint(self, service_type=None, name=None, region=None):
 
         if '2.0' in self._auth_version:

Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1345628&r1=1345627&r2=1345628&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sun Jun  3 07:34:56 
2012
@@ -113,23 +113,23 @@ class CloudFilesConnection(OpenStackBase
         # First, we parse out both files and cdn endpoints
         # for each auth version
         if '2.0' in self._auth_version:
-            ep = self.service_catalog.get_endpoint(service_type='object-store',
-                                                   name='cloudFiles',
-                                                   region='ORD')
-            cdn_ep = self.service_catalog.get_endpoint(
+            eps = 
self.service_catalog.get_endpoints(service_type='object-store',
+                                                     name='cloudFiles')
+            cdn_eps = self.service_catalog.get_endpoints(
                     service_type='object-store',
-                    name='cloudFilesCDN',
-                    region='ORD')
+                    name='cloudFilesCDN')
         elif ('1.1' in self._auth_version) or ('1.0' in self._auth_version):
-            ep = self.service_catalog.get_endpoint(name='cloudFiles',
-                                                   region='ORD')
-            cdn_ep = self.service_catalog.get_endpoint(name='cloudFilesCDN',
-                                                       region='ORD')
+            eps = self.service_catalog.get_endpoints(name='cloudFiles')
+            cdn_eps = self.service_catalog.get_endpoints(name='cloudFilesCDN')
 
         # if this is a CDN request, return the cdn url instead
         if cdn_request:
-            ep = cdn_ep
+            eps = cdn_eps
 
+        if len(eps) == 0:
+            raise LibcloudError('Could not find specified endpoint')
+
+        ep = eps[0]
         if 'publicURL' in ep:
             return ep['publicURL']
         else:

Modified: libcloud/trunk/test/storage/test_cloudfiles.py
URL: 
http://svn.apache.org/viewvc/libcloud/trunk/test/storage/test_cloudfiles.py?rev=1345628&r1=1345627&r2=1345628&view=diff
==============================================================================
--- libcloud/trunk/test/storage/test_cloudfiles.py (original)
+++ libcloud/trunk/test/storage/test_cloudfiles.py Sun Jun  3 07:34:56 2012
@@ -101,6 +101,14 @@ class CloudFilesTests(unittest.TestCase)
         else:
             self.fail('Exception was not thrown')
 
+    def test_service_catalog(self):
+        self.assertEqual(
+             'https://storage101.ord1.clouddrive.com/v1/MossoCloudFS',
+             self.driver.connection.get_endpoint())
+        self.assertEqual(
+             'https://cdn2.clouddrive.com/v1/MossoCloudFS',
+             self.driver.connection.get_endpoint(cdn_request=True))
+
     def test_list_containers(self):
         CloudFilesMockHttp.type = 'EMPTY'
         containers = self.driver.list_containers()


Reply via email to