From def5bafd50af3899486ddf8790c538dabbcf85af Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Tue, 8 Apr 2014 18:23:38 +0300 Subject: [PATCH 1/2] restore the connection request_path in case of failed request. This could happen if ex_project is specified and request gets ResourceNotFoundError, then request_path will be wrong for all other requests (eg on a script) --- libcloud/compute/drivers/gce.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index abe264e634..2d7aacc4ed 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -705,7 +705,11 @@ def list_images(self, ex_project=None): new_request_path = save_request_path.replace(self.project, ex_project) self.connection.request_path = new_request_path - response = self.connection.request(request, method='GET').object + try: + response = self.connection.request(request, method='GET').object + except: + self.connection.request_path = save_request_path + raise # Restore the connection request_path self.connection.request_path = save_request_path list_images = [self._to_node_image(i) for i in From 282b192d051dd2b37b068e5f89963852e245cbb7 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Tue, 8 Apr 2014 21:00:04 +0300 Subject: [PATCH 2/2] do not break on list_images in case of failed request --- libcloud/compute/drivers/gce.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 2d7aacc4ed..fb3a15f02d 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -708,10 +708,10 @@ def list_images(self, ex_project=None): try: response = self.connection.request(request, method='GET').object except: - self.connection.request_path = save_request_path - raise + response = {} # Restore the connection request_path - self.connection.request_path = save_request_path + finally: + self.connection.request_path = save_request_path list_images = [self._to_node_image(i) for i in response.get('items', [])] return list_images