"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/volume/flows/manager/create_volume.py" between
cinder-15.0.1.tar.gz and cinder-15.1.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 (latest release).

create_volume.py  (cinder-15.0.1):create_volume.py  (cinder-15.1.0)
skipping to change at line 557 skipping to change at line 557
encryption) encryption)
if image_info.encrypted == 'yes': if image_info.encrypted == 'yes':
key_str = source_pass + "\n" + new_pass + "\n" key_str = source_pass + "\n" + new_pass + "\n"
del source_pass del source_pass
(out, err) = utils.execute( (out, err) = utils.execute(
'cryptsetup', 'cryptsetup',
'luksChangeKey', 'luksChangeKey',
attach_info['device']['path'], attach_info['device']['path'],
'--force-password',
run_as_root=True, run_as_root=True,
process_input=key_str, process_input=key_str,
log_errors=processutils.LOG_ALL_ERRORS) log_errors=processutils.LOG_ALL_ERRORS)
del key_str del key_str
model_update = {'encryption_key_id': new_key_id} model_update = {'encryption_key_id': new_key_id}
else: else:
# volume has not been written to yet, format with luks # volume has not been written to yet, format with luks
del source_pass del source_pass
skipping to change at line 581 skipping to change at line 582
if encryption['provider'] == 'luks': if encryption['provider'] == 'luks':
# Force ambiguous "luks" provider to luks1 for # Force ambiguous "luks" provider to luks1 for
# compatibility with new versions of cryptsetup. # compatibility with new versions of cryptsetup.
encryption['provider'] = 'luks1' encryption['provider'] = 'luks1'
(out, err) = utils.execute( (out, err) = utils.execute(
'cryptsetup', 'cryptsetup',
'--batch-mode', '--batch-mode',
'luksFormat', 'luksFormat',
'--force-password',
'--type', encryption['provider'], '--type', encryption['provider'],
'--cipher', encryption['cipher'], '--cipher', encryption['cipher'],
'--key-size', str(encryption['key_size']), '--key-size', str(encryption['key_size']),
'--key-file=-', '--key-file=-',
attach_info['device']['path'], attach_info['device']['path'],
run_as_root=True, run_as_root=True,
process_input=new_pass) process_input=new_pass)
del new_pass del new_pass
model_update = {'encryption_key_id': new_key_id} model_update = {'encryption_key_id': new_key_id}
skipping to change at line 770 skipping to change at line 772
image_meta) image_meta)
if cache_entry: if cache_entry:
LOG.debug('Creating from source image-volume %(volume_id)s', LOG.debug('Creating from source image-volume %(volume_id)s',
{'volume_id': cache_entry['volume_id']}) {'volume_id': cache_entry['volume_id']})
model_update = self._create_from_source_volume( model_update = self._create_from_source_volume(
context, context,
volume, volume,
cache_entry['volume_id'] cache_entry['volume_id']
) )
return model_update, True return model_update, True
except exception.SnapshotLimitReached:
# If this exception occurred when cloning the image-volume,
# it is because the image-volume reached its snapshot limit.
# Delete current cache entry and create a "fresh" entry
# NOTE: This will not delete the existing image-volume and
# only delete the cache entry
with excutils.save_and_reraise_exception():
self.image_volume_cache.evict(context, cache_entry)
except NotImplementedError: except NotImplementedError:
LOG.warning('Backend does not support creating image-volume ' LOG.warning('Backend does not support creating image-volume '
'clone. Image will be downloaded from Glance.') 'clone. Image will be downloaded from Glance.')
return None, False return None, False
@coordination.synchronized('{image_id}') @coordination.synchronized('{image_id}')
def _prepare_image_cache_entry(self, context, volume, def _prepare_image_cache_entry(self, context, volume,
image_location, image_id, image_location, image_id,
image_meta, image_service): image_meta, image_service):
internal_context = cinder_context.get_internal_tenant_context() internal_context = cinder_context.get_internal_tenant_context()
skipping to change at line 853 skipping to change at line 863
'not use image-volume cache.') 'not use image-volume cache.')
else: else:
try: try:
model_update, cloned = self._create_from_image_cache( model_update, cloned = self._create_from_image_cache(
context, context,
internal_context, internal_context,
volume, volume,
image_id, image_id,
image_meta image_meta
) )
except exception.SnapshotLimitReached:
# This exception will be handled by the caller's
# (_create_from_image) retry decorator
with excutils.save_and_reraise_exception():
LOG.debug("Snapshot limit reached. Creating new "
"image-volume.")
except exception.CinderException as e: except exception.CinderException as e:
LOG.warning('Failed to create volume from image-volume ' LOG.warning('Failed to create volume from image-volume '
'cache, image will be downloaded from Glance. ' 'cache, image will be downloaded from Glance. '
'Error: %(exception)s', 'Error: %(exception)s',
{'exception': e}) {'exception': e})
# If an exception occurred when cloning the image-volume,
# it may be the image-volume reached its snapshot limit.
# Create another "fresh" cache entry.
update_cache = True
# Don't cache unless directed. # Don't cache unless directed.
if not cloned and update_cache: if not cloned and update_cache:
should_create_cache_entry = True should_create_cache_entry = True
# cleanup consistencygroup field in the volume, # cleanup consistencygroup field in the volume,
# because when creating cache entry, it will need # because when creating cache entry, it will need
# to update volume object. # to update volume object.
self._cleanup_cg_in_volume(volume) self._cleanup_cg_in_volume(volume)
# Fall back to default behavior of creating volume, # Fall back to default behavior of creating volume,
# download the image data and copy it into the volume. # download the image data and copy it into the volume.
skipping to change at line 955 skipping to change at line 966
# letting it be raised further up the stack. # letting it be raised further up the stack.
if volume.size != original_size: if volume.size != original_size:
try: try:
self.driver.extend_volume(volume, original_size) self.driver.extend_volume(volume, original_size)
finally: finally:
volume.size = original_size volume.size = original_size
volume.save() volume.save()
return model_update return model_update
@utils.retry(exception.SnapshotLimitReached, retries=1)
def _create_from_image(self, context, volume, def _create_from_image(self, context, volume,
image_location, image_id, image_meta, image_location, image_id, image_meta,
image_service, **kwargs): image_service, **kwargs):
LOG.debug("Cloning %(volume_id)s from image %(image_id)s " LOG.debug("Cloning %(volume_id)s from image %(image_id)s "
" at location %(image_location)s.", " at location %(image_location)s.",
{'volume_id': volume.id, {'volume_id': volume.id,
'image_location': image_location, 'image_id': image_id}) 'image_location': image_location, 'image_id': image_id})
virtual_size = image_meta.get('virtual_size') virtual_size = image_meta.get('virtual_size')
if virtual_size: if virtual_size:
 End of changes. 6 change blocks. 
5 lines changed or deleted 17 lines changed or added

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