"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/volume/drivers/rbd.py" between
cinder-17.0.1.tar.gz and cinder-17.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 "Victoria" series (latest release).

rbd.py  (cinder-17.0.1):rbd.py  (cinder-17.1.0)
skipping to change at line 247 skipping to change at line 247
if val is not None: if val is not None:
setattr(self.configuration, attr, utils.convert_str(val)) setattr(self.configuration, attr, utils.convert_str(val))
self._backend_name = (self.configuration.volume_backend_name or self._backend_name = (self.configuration.volume_backend_name or
self.__class__.__name__) self.__class__.__name__)
self._active_backend_id = active_backend_id self._active_backend_id = active_backend_id
self._active_config = {} self._active_config = {}
self._is_replication_enabled = False self._is_replication_enabled = False
self._replication_targets = [] self._replication_targets = []
self._target_names = [] self._target_names = []
self._clone_v2_api_checked = False
if self.rbd is not None: if self.rbd is not None:
self.RBD_FEATURE_LAYERING = self.rbd.RBD_FEATURE_LAYERING self.RBD_FEATURE_LAYERING = self.rbd.RBD_FEATURE_LAYERING
self.RBD_FEATURE_EXCLUSIVE_LOCK = \ self.RBD_FEATURE_EXCLUSIVE_LOCK = \
self.rbd.RBD_FEATURE_EXCLUSIVE_LOCK self.rbd.RBD_FEATURE_EXCLUSIVE_LOCK
self.RBD_FEATURE_OBJECT_MAP = self.rbd.RBD_FEATURE_OBJECT_MAP self.RBD_FEATURE_OBJECT_MAP = self.rbd.RBD_FEATURE_OBJECT_MAP
self.RBD_FEATURE_FAST_DIFF = self.rbd.RBD_FEATURE_FAST_DIFF self.RBD_FEATURE_FAST_DIFF = self.rbd.RBD_FEATURE_FAST_DIFF
self.RBD_FEATURE_JOURNALING = self.rbd.RBD_FEATURE_JOURNALING self.RBD_FEATURE_JOURNALING = self.rbd.RBD_FEATURE_JOURNALING
self.MULTIATTACH_EXCLUSIONS = ( self.MULTIATTACH_EXCLUSIONS = (
skipping to change at line 293 skipping to change at line 294
except IOError: except IOError:
LOG.debug('Cannot read RBD keyring file: %s.', self.keyring_file) LOG.debug('Cannot read RBD keyring file: %s.', self.keyring_file)
@classmethod @classmethod
def get_driver_options(cls): def get_driver_options(cls):
additional_opts = cls._get_oslo_driver_opts( additional_opts = cls._get_oslo_driver_opts(
'replication_device', 'reserved_percentage', 'replication_device', 'reserved_percentage',
'max_over_subscription_ratio', 'volume_dd_blocksize') 'max_over_subscription_ratio', 'volume_dd_blocksize')
return RBD_OPTS + additional_opts return RBD_OPTS + additional_opts
def _show_msg_check_clone_v2_api(self, volume_name):
if not self._clone_v2_api_checked:
self._clone_v2_api_checked = True
with RBDVolumeProxy(self, volume_name) as volume:
try:
if (volume.volume.op_features() &
self.rbd.RBD_OPERATION_FEATURE_CLONE_PARENT):
LOG.info('Using v2 Clone API')
return
except AttributeError:
pass
LOG.warning('Not using v2 clone API, please upgrade to'
' mimic+ and set the OSD minimum client'
' compat version to mimic for better'
' performance, fewer deletion issues')
def _get_target_config(self, target_id): def _get_target_config(self, target_id):
"""Get a replication target from known replication targets.""" """Get a replication target from known replication targets."""
for target in self._replication_targets: for target in self._replication_targets:
if target['name'] == target_id: if target['name'] == target_id:
return target return target
if not target_id or target_id == 'default': if not target_id or target_id == 'default':
return { return {
'name': self.configuration.rbd_cluster_name, 'name': self.configuration.rbd_cluster_name,
'conf': self.configuration.rbd_ceph_conf, 'conf': self.configuration.rbd_ceph_conf,
'user': self.configuration.rbd_user, 'user': self.configuration.rbd_user,
skipping to change at line 557 skipping to change at line 574
Calculate free and total capacity of the pool based on the pool's Calculate free and total capacity of the pool based on the pool's
defined quota and pools stats. defined quota and pools stats.
Returns a tuple with (free, total) where they are either unknown or a Returns a tuple with (free, total) where they are either unknown or a
real number with a 2 digit precision. real number with a 2 digit precision.
""" """
pool_name = self.configuration.rbd_pool pool_name = self.configuration.rbd_pool
with RADOSClient(self) as client: with RADOSClient(self) as client:
ret, df_outbuf, __ = client.cluster.mon_command( ret, df_outbuf, __ = client.cluster.mon_command(
'{"prefix":"df", "format":"json"}', '') '{"prefix":"df", "format":"json"}', b'')
if ret: if ret:
LOG.warning('Unable to get rados pool stats.') LOG.warning('Unable to get rados pool stats.')
return 'unknown', 'unknown' return 'unknown', 'unknown'
ret, quota_outbuf, __ = client.cluster.mon_command( ret, quota_outbuf, __ = client.cluster.mon_command(
'{"prefix":"osd pool get-quota", "pool": "%s",' '{"prefix":"osd pool get-quota", "pool": "%s",'
' "format":"json"}' % pool_name, '') ' "format":"json"}' % pool_name, b'')
if ret: if ret:
LOG.warning('Unable to get rados pool quotas.') LOG.warning('Unable to get rados pool quotas.')
return 'unknown', 'unknown' return 'unknown', 'unknown'
df_outbuf = encodeutils.safe_decode(df_outbuf) df_outbuf = encodeutils.safe_decode(df_outbuf)
df_data = json.loads(df_outbuf) df_data = json.loads(df_outbuf)
pool_stats = [pool for pool in df_data['pools'] pool_stats = [pool for pool in df_data['pools']
if pool['name'] == pool_name][0]['stats'] if pool['name'] == pool_name][0]['stats']
quota_outbuf = encodeutils.safe_decode(quota_outbuf) quota_outbuf = encodeutils.safe_decode(quota_outbuf)
skipping to change at line 1027 skipping to change at line 1044
vol.resize(size) vol.resize(size)
def create_volume_from_snapshot(self, volume, snapshot): def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot.""" """Creates a volume from a snapshot."""
volume_update = self._clone(volume, self.configuration.rbd_pool, volume_update = self._clone(volume, self.configuration.rbd_pool,
snapshot.volume_name, snapshot.name) snapshot.volume_name, snapshot.name)
if self.configuration.rbd_flatten_volume_from_snapshot: if self.configuration.rbd_flatten_volume_from_snapshot:
self._flatten(self.configuration.rbd_pool, volume.name) self._flatten(self.configuration.rbd_pool, volume.name)
if int(volume.size): if int(volume.size):
self._resize(volume) self._resize(volume)
self._show_msg_check_clone_v2_api(snapshot.volume_name)
return volume_update return volume_update
def _delete_backup_snaps(self, rbd_image): def _delete_backup_snaps(self, rbd_image):
backup_snaps = self._get_backup_snaps(rbd_image) backup_snaps = self._get_backup_snaps(rbd_image)
if backup_snaps: if backup_snaps:
for snap in backup_snaps: for snap in backup_snaps:
rbd_image.remove_snap(snap['name']) rbd_image.remove_snap(snap['name'])
else: else:
LOG.debug("volume has no backup snaps") LOG.debug("volume has no backup snaps")
skipping to change at line 1603 skipping to change at line 1622
with tempfile.NamedTemporaryFile(dir=tmp_dir) as tmp: with tempfile.NamedTemporaryFile(dir=tmp_dir) as tmp:
image_utils.fetch_to_raw(context, image_service, image_id, image_utils.fetch_to_raw(context, image_service, image_id,
tmp.name, tmp.name,
self.configuration.volume_dd_blocksize, self.configuration.volume_dd_blocksize,
size=volume.size) size=volume.size)
if encrypted: if encrypted:
self._encrypt_image(context, volume, tmp_dir, tmp.name) self._encrypt_image(context, volume, tmp_dir, tmp.name)
self.delete_volume(volume) @utils.retry(exception.VolumeIsBusy,
self.configuration.rados_connection_interval,
self.configuration.rados_connection_retries)
def _delete_volume(volume):
self.delete_volume(volume)
_delete_volume(volume)
chunk_size = self.configuration.rbd_store_chunk_size * units.Mi chunk_size = self.configuration.rbd_store_chunk_size * units.Mi
order = int(math.log(chunk_size, 2)) order = int(math.log(chunk_size, 2))
# keep using the command line import instead of librbd since it # keep using the command line import instead of librbd since it
# detects zeroes to preserve sparseness in the image # detects zeroes to preserve sparseness in the image
args = ['rbd', 'import', args = ['rbd', 'import',
'--pool', self.configuration.rbd_pool, '--pool', self.configuration.rbd_pool,
'--order', order, '--order', order,
tmp.name, volume.name, tmp.name, volume.name,
'--new-format'] '--new-format']
 End of changes. 6 change blocks. 
3 lines changed or deleted 28 lines changed or added

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