Repository: libcloud Updated Branches: refs/heads/trunk afed2cbde -> 7ca1336ce
[google compute] list images does not break in case of invalid OS image types Closes #447 Signed-off-by: Eric Johnson <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7ca1336c Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7ca1336c Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7ca1336c Branch: refs/heads/trunk Commit: 7ca1336ce74292a8f4ff58b8fce68264d959129f Parents: afed2cb Author: Markos Gogoulos <[email protected]> Authored: Mon Feb 9 15:46:21 2015 +0200 Committer: Eric Johnson <[email protected]> Committed: Mon Feb 9 22:50:12 2015 +0000 ---------------------------------------------------------------------- CHANGES.rst | 4 ++++ libcloud/compute/drivers/gce.py | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/7ca1336c/CHANGES.rst ---------------------------------------------------------------------- diff --git a/CHANGES.rst b/CHANGES.rst index 9cef9f9..42ad0ad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,10 @@ General Compute ~~~~~~~ +- GCE driver fix to handle unknown image projects + (GITHUB-447) + [Markos Gogoulos] + - GCE driver updated to include ex_stop_node() and ex_start_node() methods. (GITHUB-442) [Eric Johnson] http://git-wip-us.apache.org/repos/asf/libcloud/blob/7ca1336c/libcloud/compute/drivers/gce.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 9cfad4d..cfba8d6 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -1285,9 +1285,13 @@ class GCENodeDriver(NodeDriver): image_list = self.ex_list_project_images(ex_project=None, ex_include_deprecated=dep) for img_proj in list(self.IMAGE_PROJECTS.keys()): - image_list.extend( - self.ex_list_project_images(ex_project=img_proj, - ex_include_deprecated=dep)) + try: + image_list.extend( + self.ex_list_project_images(ex_project=img_proj, + ex_include_deprecated=dep)) + except: + # do not break if an OS type is invalid + pass return image_list def ex_list_project_images(self, ex_project=None, @@ -1327,16 +1331,20 @@ class GCENodeDriver(NodeDriver): new_request_path = save_request_path.replace(self.project, proj) 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: + raise + finally: + # Restore the connection request_path + self.connection.request_path = save_request_path for img in response.get('items', []): if 'deprecated' not in img: list_images.append(self._to_node_image(img)) else: if ex_include_deprecated: list_images.append(self._to_node_image(img)) - # Restore the connection request_path - self.connection.request_path = save_request_path return list_images def list_locations(self):
