libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1345630 - in /libcloud/trunk: libcloud/common/openstack.py libcloud/storage/drivers/cloudfiles.py test/storage/test_cloudfiles.py
Date Sun, 03 Jun 2012 07:56:45 GMT
Author: tomaz
Date: Sun Jun  3 07:56:44 2012
New Revision: 1345630

URL: http://svn.apache.org/viewvc?rev=1345630&view=rev
Log:
Fix container.get_cdn_url() and make sure it uses the correct endpoint from the
service catalog. Contributed by Geoff Greer, part of LIBCLOUD-206.

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

Modified: libcloud/trunk/libcloud/common/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/openstack.py?rev=1345630&r1=1345629&r2=1345630&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/openstack.py (original)
+++ libcloud/trunk/libcloud/common/openstack.py Sun Jun  3 07:56:44 2012
@@ -447,7 +447,6 @@ class OpenStackBaseConnection(Connection
         return super(OpenStackBaseConnection, self).morph_action_hook(action)
 
     def request(self, **kwargs):
-        self._populate_hosts_and_request_paths()
         return super(OpenStackBaseConnection, self).request(**kwargs)
 
     def _populate_hosts_and_request_paths(self):

Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1345630&r1=1345629&r2=1345630&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sun Jun  3 07:56:44 2012
@@ -108,8 +108,9 @@ class CloudFilesConnection(OpenStackBase
                                                    **kwargs)
         self.api_version = API_VERSION
         self.accept_format = 'application/json'
+        self.cdn_request = False
 
-    def get_endpoint(self, cdn_request=False):
+    def get_endpoint(self):
         # First, we parse out both files and cdn endpoints
         # for each auth version
         if '2.0' in self._auth_version:
@@ -123,7 +124,7 @@ class CloudFilesConnection(OpenStackBase
             cdn_eps = self.service_catalog.get_endpoints(name='cloudFilesCDN')
 
         # if this is a CDN request, return the cdn url instead
-        if cdn_request:
+        if self.cdn_request:
             eps = cdn_eps
 
         if len(eps) == 0:
@@ -142,16 +143,7 @@ class CloudFilesConnection(OpenStackBase
         if not params:
             params = {}
 
-        # FIXME: Massive hack.
-        # This driver dynamically changes the url in its connection,
-        # based on arguments passed to request(). As such, we have to
-        # manually check and reset connection params each request
-        self._populate_hosts_and_request_paths()
-        if not self._ex_force_base_url:
-            self._reset_connection_params(self.get_endpoint(cdn_request))
-        else:
-            self._reset_connection_params(self._ex_force_base_url)
-
+        self.cdn_request = cdn_request
         params['format'] = 'json'
 
         if method in ['POST', 'PUT'] and 'Content-Type' not in headers:
@@ -163,10 +155,6 @@ class CloudFilesConnection(OpenStackBase
             method=method, headers=headers,
             raw=raw)
 
-    def _reset_connection_params(self, endpoint_url):
-        (self.host, self.port, self.secure, self.request_path) = \
-                self._tuple_from_url(endpoint_url)
-
 
 class CloudFilesUSConnection(CloudFilesConnection):
     """
@@ -288,8 +276,10 @@ class CloudFilesStorageDriver(StorageDri
 
     def enable_container_cdn(self, container):
         container_name = container.name
+        headers = {'X-CDN-Enabled': 'True'}
         response = self.connection.request('/%s' % (container_name),
                                            method='PUT',
+                                           headers=headers,
                                            cdn_request=True)
 
         if response.status in [ httplib.CREATED, httplib.ACCEPTED ]:

Modified: libcloud/trunk/test/storage/test_cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/storage/test_cloudfiles.py?rev=1345630&r1=1345629&r2=1345630&view=diff
==============================================================================
--- libcloud/trunk/test/storage/test_cloudfiles.py (original)
+++ libcloud/trunk/test/storage/test_cloudfiles.py Sun Jun  3 07:56:44 2012
@@ -105,9 +105,12 @@ class CloudFilesTests(unittest.TestCase)
         self.assertEqual(
              'https://storage101.ord1.clouddrive.com/v1/MossoCloudFS',
              self.driver.connection.get_endpoint())
+
+        self.driver.connection.cdn_request = True
         self.assertEqual(
              'https://cdn2.clouddrive.com/v1/MossoCloudFS',
-             self.driver.connection.get_endpoint(cdn_request=True))
+             self.driver.connection.get_endpoint())
+        self.driver.connection.cdn_request = False
 
     def test_list_containers(self):
         CloudFilesMockHttp.type = 'EMPTY'



Mime
View raw message