description = 'auto-created_from_restore_from_swift'
LOG.audit(_("Creating volume of %(size)s GB for restore of "
- "backup %(backup_id)s"), locals(), context=context)
+ "backup %(backup_id)s"),
+ {'size': size, 'backup_id': backup_id},
+ context=context)
volume = self.volume_api.create(context, size, name, description)
volume_id = volume['id']
volume = self.volume_api.get(context, volume_id)
volume_size = volume['size']
if volume_size < size:
- err = _('volume size %(volume_size)d is too small to restore '
- 'backup of size %(size)d.') % locals()
+ err = (_('volume size %(volume_size)d is too small to restore '
+ 'backup of size %(size)d.') %
+ {'volume_size': volume_size, 'size': size})
raise exception.InvalidVolume(reason=err)
if volume['status'] != "available":
raise exception.InvalidVolume(reason=msg)
LOG.audit(_("Overwriting volume %(volume_id)s with restore of "
- "backup %(backup_id)s"), locals(), context=context)
+ "backup %(backup_id)s"),
+ {'volume_id': volume_id, 'backup_id': backup_id},
+ context=context)
# Setting the status here rather than setting at start and unrolling
# for each error condition, it should be a very small window
volume_id = backup['volume_id']
volume = self.db.volume_get(context, volume_id)
LOG.info(_('create_backup started, backup: %(backup_id)s for '
- 'volume: %(volume_id)s') % locals())
+ 'volume: %(volume_id)s') %
+ {'backup_id': backup_id, 'volume_id': volume_id})
self.db.backup_update(context, backup_id, {'host': self.host,
'service':
CONF.backup_service})
actual_status = volume['status']
if actual_status != expected_status:
err = _('create_backup aborted, expected volume status '
- '%(expected_status)s but got %(actual_status)s') % locals()
+ '%(expected_status)s but got %(actual_status)s') % {
+ 'expected_status': expected_status,
+ 'actual_status': actual_status,
+ }
self.db.backup_update(context, backup_id, {'status': 'error',
'fail_reason': err})
raise exception.InvalidVolume(reason=err)
actual_status = backup['status']
if actual_status != expected_status:
err = _('create_backup aborted, expected backup status '
- '%(expected_status)s but got %(actual_status)s') % locals()
+ '%(expected_status)s but got %(actual_status)s') % {
+ 'expected_status': expected_status,
+ 'actual_status': actual_status,
+ }
self.db.volume_update(context, volume_id, {'status': 'available'})
self.db.backup_update(context, backup_id, {'status': 'error',
'fail_reason': err})
Restore volume backups from configured backup service.
"""
LOG.info(_('restore_backup started, restoring backup: %(backup_id)s'
- ' to volume: %(volume_id)s') % locals())
+ ' to volume: %(volume_id)s') %
+ {'backup_id': backup_id, 'volume_id': volume_id})
backup = self.db.backup_get(context, backup_id)
volume = self.db.volume_get(context, volume_id)
self.db.backup_update(context, backup_id, {'host': self.host})
actual_status = volume['status']
if actual_status != expected_status:
err = _('restore_backup aborted, expected volume status '
- '%(expected_status)s but got %(actual_status)s') % locals()
+ '%(expected_status)s but got %(actual_status)s') % {
+ 'expected_status': expected_status,
+ 'actual_status': actual_status
+ }
self.db.backup_update(context, backup_id, {'status': 'available'})
raise exception.InvalidVolume(reason=err)
actual_status = backup['status']
if actual_status != expected_status:
err = _('restore_backup aborted, expected backup status '
- '%(expected_status)s but got %(actual_status)s') % locals()
+ '%(expected_status)s but got %(actual_status)s') % {
+ 'expected_status': expected_status,
+ 'actual_status': actual_status
+ }
self.db.backup_update(context, backup_id, {'status': 'error',
'fail_reason': err})
self.db.volume_update(context, volume_id, {'status': 'error'})
err = _('restore_backup aborted, the backup service currently'
' configured [%(configured_service)s] is not the'
' backup service that was used to create this'
- ' backup [%(backup_service)s]') % locals()
+ ' backup [%(backup_service)s]') % {
+ 'configured_service': configured_service,
+ 'backup_service': backup_service,
+ }
self.db.backup_update(context, backup_id, {'status': 'available'})
self.db.volume_update(context, volume_id, {'status': 'error'})
raise exception.InvalidBackup(reason=err)
self.db.volume_update(context, volume_id, {'status': 'available'})
self.db.backup_update(context, backup_id, {'status': 'available'})
LOG.info(_('restore_backup finished, backup: %(backup_id)s restored'
- ' to volume: %(volume_id)s') % locals())
+ ' to volume: %(volume_id)s') %
+ {'backup_id': backup_id, 'volume_id': volume_id})
def delete_backup(self, context, backup_id):
"""
actual_status = backup['status']
if actual_status != expected_status:
err = _('delete_backup aborted, expected backup status '
- '%(expected_status)s but got %(actual_status)s') % locals()
+ '%(expected_status)s but got %(actual_status)s') % {
+ 'expected_status': expected_status,
+ 'actual_status': actual_status,
+ }
self.db.backup_update(context, backup_id, {'status': 'error',
'fail_reason': err})
raise exception.InvalidBackup(reason=err)
err = _('delete_backup aborted, the backup service currently'
' configured [%(configured_service)s] is not the'
' backup service that was used to create this'
- ' backup [%(backup_service)s]') % locals()
+ ' backup [%(backup_service)s]') % {
+ 'configured_service': configured_service,
+ 'backup_service': backup_service,
+ }
self.db.backup_update(context, backup_id,
{'status': 'error'})
raise exception.InvalidBackup(reason=err)
backup_id = backup['id']
container = backup['container']
LOG.debug(_('_create_container started, container: %(container)s,'
- 'backup: %(backup_id)s') % locals())
+ 'backup: %(backup_id)s') %
+ {'container': container, 'backup_id': backup_id})
if container is None:
container = CONF.backup_swift_container
self.db.backup_update(context, backup_id, {'container': container})
def _write_metadata(self, backup, volume_id, container, object_list):
filename = self._metadata_filename(backup)
LOG.debug(_('_write_metadata started, container name: %(container)s,'
- ' metadata filename: %(filename)s') % locals())
+ ' metadata filename: %(filename)s') %
+ {'container': container, 'filename': filename})
metadata = {}
metadata['version'] = self.SERVICE_VERSION
metadata['backup_id'] = backup['id']
if etag != md5:
err = _('error writing metadata file to swift, MD5 of metadata'
' file in swift [%(etag)s] is not the same as MD5 of '
- 'metadata file sent to swift [%(md5)s]') % locals()
+ 'metadata file sent to swift [%(md5)s]') % {'etag': etag,
+ 'md5': md5}
raise exception.InvalidBackup(reason=err)
LOG.debug(_('_write_metadata finished'))
container = backup['container']
filename = self._metadata_filename(backup)
LOG.debug(_('_read_metadata started, container name: %(container)s, '
- 'metadata filename: %(filename)s') % locals())
+ 'metadata filename: %(filename)s') %
+ {'container': container, 'filename': filename})
(resp, body) = self.conn.get_object(container, filename)
metadata = json.loads(body)
LOG.debug(_('_read_metadata finished (%s)') % metadata)
LOG.debug(_('starting backup of volume: %(volume_id)s to swift,'
' volume size: %(volume_size_bytes)d, swift object names'
' prefix %(object_prefix)s, availability zone:'
- ' %(availability_zone)s') % locals())
+ ' %(availability_zone)s') %
+ {
+ 'volume_id': volume_id,
+ 'volume_size_bytes': volume_size_bytes,
+ 'object_prefix': object_prefix,
+ 'availability_zone': availability_zone,
+ })
object_id = 1
object_list = []
while True:
comp_size_bytes = len(data)
LOG.debug(_('compressed %(data_size_bytes)d bytes of data'
' to %(comp_size_bytes)d bytes using '
- '%(algorithm)s') % locals())
+ '%(algorithm)s') %
+ {
+ 'data_size_bytes': data_size_bytes,
+ 'comp_size_bytes': comp_size_bytes,
+ 'algorithm': algorithm,
+ })
else:
LOG.debug(_('not compressing data'))
obj[object_name]['compression'] = 'none'
etag = self.conn.put_object(container, object_name, reader)
except socket.error as err:
raise exception.SwiftConnectionFailed(reason=str(err))
- LOG.debug(_('swift MD5 for %(object_name)s: %(etag)s') % locals())
+ LOG.debug(_('swift MD5 for %(object_name)s: %(etag)s') %
+ {'object_name': object_name, 'etag': etag, })
md5 = hashlib.md5(data).hexdigest()
obj[object_name]['md5'] = md5
- LOG.debug(_('backup MD5 for %(object_name)s: %(md5)s') % locals())
+ LOG.debug(_('backup MD5 for %(object_name)s: %(md5)s') %
+ {'object_name': object_name, 'md5': md5})
if etag != md5:
err = _('error writing object to swift, MD5 of object in '
'swift %(etag)s is not the same as MD5 of object sent '
- 'to swift %(md5)s') % locals()
+ 'to swift %(md5)s') % {'etag': etag, 'md5': md5}
raise exception.InvalidBackup(reason=err)
object_list.append(obj)
object_id += 1
object_name = metadata_object.keys()[0]
LOG.debug(_('restoring object from swift. backup: %(backup_id)s, '
'container: %(container)s, swift object name: '
- '%(object_name)s, volume: %(volume_id)s') % locals())
+ '%(object_name)s, volume: %(volume_id)s') %
+ {
+ 'backup_id': backup_id,
+ 'container': container,
+ 'object_name': object_name,
+ 'volume_id': volume_id,
+ })
try:
(resp, body) = self.conn.get_object(container, object_name)
except socket.error as err:
object_prefix = backup['service_metadata']
LOG.debug(_('starting restore of backup %(object_prefix)s from swift'
' container: %(container)s, to volume %(volume_id)s, '
- 'backup: %(backup_id)s') % locals())
+ 'backup: %(backup_id)s') %
+ {
+ 'object_prefix': object_prefix,
+ 'container': container,
+ 'volume_id': volume_id,
+ 'backup_id': backup_id,
+ })
try:
metadata = self._read_metadata(backup)
except socket.error as err:
raise exception.InvalidBackup(reason=err)
restore_func(backup, volume_id, metadata, volume_file)
LOG.debug(_('restore %(backup_id)s to %(volume_id)s finished.') %
- locals())
+ {'backup_id': backup_id, 'volume_id': volume_id})
def delete(self, backup):
"""Delete the given backup from swift."""
'continuing with delete') % swift_object_name)
else:
LOG.debug(_('deleted swift object: %(swift_object_name)s'
- ' in container: %(container)s') % locals())
+ ' in container: %(container)s') %
+ {
+ 'swift_object_name': swift_object_name,
+ 'container': container
+ })
# Deleting a backup's objects from swift can take some time.
# Yield so other threads can run
eventlet.sleep(0)