"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/image/image_utils.py" between
cinder-15.5.0.tar.gz and cinder-15.6.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Train" series (maintained release).

image_utils.py  (cinder-15.5.0):image_utils.py  (cinder-15.6.0)
skipping to change at line 558 skipping to change at line 558
raise exception.ImageUnacceptable( raise exception.ImageUnacceptable(
image_id=image_id, image_id=image_id,
reason=_("Image compression disallowed, " reason=_("Image compression disallowed, "
"but container_format is " "but container_format is "
"%(container_format)s.") % compression_param) "%(container_format)s.") % compression_param)
# NOTE(avishay): I'm not crazy about creating temp files which may be # NOTE(avishay): I'm not crazy about creating temp files which may be
# large and cause disk full errors which would confuse users. # large and cause disk full errors which would confuse users.
# Unfortunately it seems that you can't pipe to 'qemu-img convert' because # Unfortunately it seems that you can't pipe to 'qemu-img convert' because
# it seeks. Maybe we can think of something for a future version. # it seeks. Maybe we can think of something for a future version.
with temporary_file() as tmp: with temporary_file(prefix='image_download_%s_' % image_id) as tmp:
has_meta = False if not image_meta else True has_meta = False if not image_meta else True
try: try:
format_raw = True if image_meta['disk_format'] == 'raw' else False format_raw = True if image_meta['disk_format'] == 'raw' else False
except TypeError: except TypeError:
format_raw = False format_raw = False
data = get_qemu_data(image_id, has_meta, format_raw, data = get_qemu_data(image_id, has_meta, format_raw,
tmp, run_as_root) tmp, run_as_root)
if data is None: if data is None:
qemu_img = False qemu_img = False
skipping to change at line 667 skipping to change at line 667
with open(volume_path, 'rb') as image_file: with open(volume_path, 'rb') as image_file:
image_service.update(context, image_id, {}, image_service.update(context, image_id, {},
tpool.Proxy(image_file)) tpool.Proxy(image_file))
else: else:
with utils.temporary_chown(volume_path): with utils.temporary_chown(volume_path):
with open(volume_path, 'rb') as image_file: with open(volume_path, 'rb') as image_file:
image_service.update(context, image_id, {}, image_service.update(context, image_id, {},
tpool.Proxy(image_file)) tpool.Proxy(image_file))
return return
with temporary_file() as tmp: with temporary_file(prefix='vol_upload_') as tmp:
LOG.debug("%s was %s, converting to %s", LOG.debug("%s was %s, converting to %s",
image_id, volume_format, image_meta['disk_format']) image_id, volume_format, image_meta['disk_format'])
data = qemu_img_info(volume_path, run_as_root=run_as_root) data = qemu_img_info(volume_path, run_as_root=run_as_root)
backing_file = data.backing_file backing_file = data.backing_file
fmt = data.file_format fmt = data.file_format
if backing_file is not None: if backing_file is not None:
# Disallow backing files as a security measure. # Disallow backing files as a security measure.
# This prevents a user from writing an image header into a raw # This prevents a user from writing an image header into a raw
# volume with a backing file pointing to data they wish to # volume with a backing file pointing to data they wish to
skipping to change at line 881 skipping to change at line 881
def for_image_service(image_service): def for_image_service(image_service):
instance = image_service.temp_images instance = image_service.temp_images
if instance: if instance:
return instance return instance
return TemporaryImages(image_service) return TemporaryImages(image_service)
@classmethod @classmethod
@contextlib.contextmanager @contextlib.contextmanager
def fetch(cls, image_service, context, image_id, suffix=''): def fetch(cls, image_service, context, image_id, suffix=''):
tmp_images = cls.for_image_service(image_service).temporary_images tmp_images = cls.for_image_service(image_service).temporary_images
with temporary_file(suffix=suffix) as tmp: with temporary_file(prefix='image_fetch_%s_' % image_id,
suffix=suffix) as tmp:
fetch_verify_image(context, image_service, image_id, tmp) fetch_verify_image(context, image_service, image_id, tmp)
user = context.user_id user = context.user_id
if not tmp_images.get(user): if not tmp_images.get(user):
tmp_images[user] = {} tmp_images[user] = {}
tmp_images[user][image_id] = tmp tmp_images[user][image_id] = tmp
LOG.debug("Temporary image %(id)s is fetched for user %(user)s.", LOG.debug("Temporary image %(id)s is fetched for user %(user)s.",
{'id': image_id, 'user': user}) {'id': image_id, 'user': user})
yield tmp yield tmp
del tmp_images[user][image_id] del tmp_images[user][image_id]
LOG.debug("Temporary image %(id)s for user %(user)s is deleted.", LOG.debug("Temporary image %(id)s for user %(user)s is deleted.",
 End of changes. 3 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)