libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject libcloud git commit: Ensure that request_path is restored on exception raise when requesting a license. Closes #968
Date Tue, 21 Feb 2017 16:21:40 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 57913fceb -> 7366122bc


Ensure that request_path is restored on exception raise when requesting a license.
Closes #968


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

Branch: refs/heads/trunk
Commit: 7366122bc0266039a7e59c0cdce516cb4af7d1f5
Parents: 57913fc
Author: Peter Amstutz <peter.amstutz@curoverse.com>
Authored: Fri Jan 6 10:10:04 2017 -0500
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Tue Feb 21 17:21:22 2017 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/gce.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/7366122b/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 3bfe9ee..1195170 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -325,13 +325,19 @@ class GCELicense(UuidMixin, LazyObject):
         # connection thread-safe? Saving, modifying, and restoring
         # driver.connection.request_path is really hacky and thread-unsafe.
         saved_request_path = self.driver.connection.request_path
-        new_request_path = saved_request_path.replace(self.driver.project,
-                                                      self.project)
-        self.driver.connection.request_path = new_request_path
+        try:
+            new_request_path = saved_request_path.replace(self.driver.project,
+                                                          self.project)
+            self.driver.connection.request_path = new_request_path
 
-        request = '/global/licenses/%s' % self.name
-        response = self.driver.connection.request(request, method='GET').object
-        self.driver.connection.request_path = saved_request_path
+            request = '/global/licenses/%s' % self.name
+            response = self.driver.connection.request(request,
+                                                      method='GET').object
+        except:
+            raise
+        finally:
+            # Restore the connection request_path
+            self.driver.connection.request_path = saved_request_path
 
         self.extra = {
             'selfLink': response.get('selfLink'),


Mime
View raw message