Skip to content

Commit

Permalink
Merge "Fix chown fail for nfs file without necessary permission"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 30, 2013
2 parents 82f3662 + 1498958 commit 0f7d937
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cinder/image/image_utils.py
Expand Up @@ -316,11 +316,8 @@ def fetch_to_volume_format(context, image_service,
if backing_file is not None:
raise exception.ImageUnacceptable(
image_id=image_id,
reason=_("fmt=%(fmt)s backed by:"
"%(backing_file)s") % {
'fmt': fmt,
'backing_file': backing_file,
})
reason=_("fmt=%(fmt)s backed by:%(backing_file)s")
% {'fmt': fmt, 'backing_file': backing_file, })

# NOTE(jdg): I'm using qemu-img convert to write
# to the volume regardless if it *needs* conversion or not
Expand Down Expand Up @@ -349,12 +346,13 @@ def upload_volume(context, image_service, image_meta, volume_path,
if (image_meta['disk_format'] == volume_format):
LOG.debug("%s was %s, no need to convert to %s" %
(image_id, volume_format, image_meta['disk_format']))
if os.name == 'nt':
with fileutils.file_open(volume_path) as image_file:
image_service.update(context, image_id, {}, image_file)
with utils.temporary_chown(volume_path):
if os.name == 'nt' or os.access(volume_path, os.R_OK):
with fileutils.file_open(volume_path) as image_file:
image_service.update(context, image_id, {}, image_file)
else:
with utils.temporary_chown(volume_path):
with fileutils.file_open(volume_path) as image_file:
image_service.update(context, image_id, {}, image_file)
return

if (CONF.image_conversion_dir and not
Expand Down

0 comments on commit 0f7d937

Please sign in to comment.