summaryrefslogtreecommitdiff
path: root/glanceclient/v2
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-09 17:30:23 +0000
committerGerrit Code Review <review@openstack.org>2016-03-09 17:30:23 +0000
commit26d2a0f4c29d15208b426443e7a5f8570abdc323 (patch)
tree9abe306dd9e6732f55eb1265b050fd83b09231c3 /glanceclient/v2
parent8d87a244e04e623495f2e9c0a0f239d47faf8e0e (diff)
parentc077858dd6e0cd827af2418e1a05ca1f27937764 (diff)
downloadpython-glanceclient-1.1.1.tar.gz
Merge "Fix the download error when the image locations are blank" into stable/liberty1.1.1
Diffstat (limited to 'glanceclient/v2')
-rw-r--r--glanceclient/v2/images.py6
-rw-r--r--glanceclient/v2/shell.py4
2 files changed, 9 insertions, 1 deletions
diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py
index 451a0fe..2d68f64 100644
--- a/glanceclient/v2/images.py
+++ b/glanceclient/v2/images.py
@@ -14,8 +14,8 @@
# under the License.
import json
-
from oslo_utils import encodeutils
+from requests import codes
import six
from six.moves.urllib import parse
import warlock
@@ -189,9 +189,13 @@ class Controller(object):
:param image_id: ID of the image to download.
:param do_checksum: Enable/disable checksum validation.
+ :returns: An interable body or None
"""
url = '/v2/images/%s/file' % image_id
resp, body = self.http_client.get(url)
+ if resp.status_code == codes.no_content:
+ return None
+
checksum = resp.headers.get('content-md5', None)
content_length = int(resp.headers.get('content-length', 0))
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 86a1f3d..dab9e67 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -276,6 +276,10 @@ def do_explain(gc, args):
def do_image_download(gc, args):
"""Download a specific image."""
body = gc.images.data(args.id)
+ if body is None:
+ msg = ('Image %s has no data.' % args.id)
+ utils.exit(msg)
+
if args.progress:
body = progressbar.VerboseIteratorWrapper(body, len(body))
if not (sys.stdout.isatty() and args.file is None):