Fix the download error when the image locations are blank

When the image locations are blank, glance client will get a http response
with no content, glance client should show user no data could be found,
instead of processing the blank response body that will lead to exception.

Glance client will also get a 204 response when an image is in a queued
state (this is true for 'master' and liberty/kilo/juno based servers).

Closes-Bug: #1472449

Co-Authored-by: Stuart McLaren <stuart.mclaren@hp.com>
Change-Id: I5d3d02d6aa7c8dd054cd2933e15b4a26e91afea1
This commit is contained in:
Long Quan Sha
2015-07-08 09:29:53 +08:00
committed by Stuart McLaren
parent deff84dadf
commit 44d0b02c67
3 changed files with 16 additions and 2 deletions
+7 -1
View File
@@ -14,7 +14,7 @@
# under the License.
import errno
import mock
import testtools
from glanceclient import exc
@@ -866,6 +866,12 @@ class TestController(testtools.TestCase):
body = ''.join([b for b in body])
self.assertEqual('CCC', body)
def test_download_no_data(self):
resp = utils.FakeResponse(headers={}, status_code=204)
self.controller.http_client.get = mock.Mock(return_value=(resp, None))
body = self.controller.data('image_id')
self.assertEqual(None, body)
def test_update_replace_prop(self):
image_id = '3a4560a1-e585-443e-9b39-553b46ec92d1'
params = {'name': 'pong'}