Skip to content

Commit

Permalink
Avoid extra glance v2 locations call!
Browse files Browse the repository at this point in the history
In 7df1c91 we added code to attempt to direct download
images from glance locations. This feature is meant to be off
by default however when it is disabled it adds an unnecessary
glance V2 API call.

This patch removes the extra get_locations call when
CONF.allowed_direct_url_schemes is empty (disabled). This effectively
fixes Nova on Python some 2.6 distros which fail to work with the
recent Glance V2 schema code.

Fixes LP Bug #1208656

Change-Id: I0989ed4f248cd1126d4703ad6498cfd66685ae31
  • Loading branch information
dprince committed Aug 6, 2013
1 parent 7df1c91 commit ae10402
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions nova/image/glance.py
Expand Up @@ -313,19 +313,21 @@ def _get_transfer_module(self, scheme):

def download(self, context, image_id, data=None):
"""Calls out to Glance for data and writes data."""
locations = self._get_locations(context, image_id)
for entry in locations:
loc_url = entry['url']
loc_meta = entry['metadata']
o = urlparse.urlparse(loc_url)
xfer_mod = self._get_transfer_module(o.scheme)
if xfer_mod:
try:
xfer_mod.download(o, data, loc_meta)
LOG.info("Successfully transferred using %s" % o.scheme)
return
except Exception as ex:
LOG.exception(ex)
if CONF.allowed_direct_url_schemes:
locations = self._get_locations(context, image_id)
for entry in locations:
loc_url = entry['url']
loc_meta = entry['metadata']
o = urlparse.urlparse(loc_url)
xfer_mod = self._get_transfer_module(o.scheme)
if xfer_mod:
try:
xfer_mod.download(o, data, loc_meta)
LOG.info("Successfully transferred using %s"
% o.scheme)
return
except Exception as ex:
LOG.exception(ex)

try:
image_chunks = self._client.call(context, 1, 'data', image_id)
Expand Down

0 comments on commit ae10402

Please sign in to comment.