Repository: libcloud
Updated Branches:
refs/heads/trunk e72e2a5a3 -> 5072fc0de
[google compute] raise notfound on images that are not found
Closes #441
Signed-off-by: Eric Johnson <erjohnso@google.com>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5072fc0d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5072fc0d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5072fc0d
Branch: refs/heads/trunk
Commit: 5072fc0de8d7a3adc8c1a2cf86f6d8ec695b42c1
Parents: e72e2a5
Author: Eric Johnson <erjohnso@google.com>
Authored: Wed Jan 28 23:55:23 2015 +0000
Committer: Eric Johnson <erjohnso@google.com>
Committed: Thu Jan 29 20:39:52 2015 +0000
----------------------------------------------------------------------
CHANGES.rst | 7 +++++++
libcloud/compute/drivers/gce.py | 6 +++++-
libcloud/test/compute/test_gce.py | 5 +++++
3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5072fc0d/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 6bf5137..991f790 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -16,6 +16,13 @@ General
Compute
~~~~~~~
+- GCE driver now raises ResourceNotFoundError when the specified image is
+ not found in any image project. Previously, this would return None but now
+ raises the not-found exception instead. This fixes a bug where returning
+ None caused ex_delete_image to raise an AttributeError.
+ (GITHUB-441)
+ [Eric Johnson]
+
- GCE driver update to support JSON format Service Account files and a PY3
fix from Siim Põder for LIBCLOUD-627.
(LIBCLOUD-627, LIBCLOUD-657, GITHUB-438)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5072fc0d/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index ab98179..1778818 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -3810,7 +3810,7 @@ n
:return: GCENodeImage object based on provided information or None if
an image with that name is not found.
- :rtype: :class:`GCENodeImage` or ``None``
+ :rtype: :class:`GCENodeImage` or raise ``ResourceNotFoundError``
"""
if partial_name.startswith('https://'):
response = self.connection.request(partial_name, method='GET')
@@ -3821,6 +3821,10 @@ n
for short_name in short_list:
if partial_name.startswith(short_name):
image = self._match_images(img_proj, partial_name)
+
+ if not image:
+ raise ResourceNotFoundError('Could not find image \'%s\'' % (
+ partial_name), None, None)
return image
def ex_get_route(self, name):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5072fc0d/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index c56a746..35ec80f 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -858,6 +858,11 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
self.assertTrue(destroyed)
def test_ex_delete_image(self):
+ self.assertRaises(ResourceNotFoundError,
+ self.driver.ex_get_image, 'missing-image')
+ self.assertRaises(ResourceNotFoundError,
+ self.driver.ex_delete_image, 'missing-image')
+
image = self.driver.ex_get_image('debian-7')
deleted = self.driver.ex_delete_image(image)
self.assertTrue(deleted)
|