Merge "Redundant size check in volume restore api"

This commit is contained in:
Jenkins 2013-12-30 20:18:20 +00:00 committed by Gerrit Code Review
commit 07e0a120f3

View File

@ -165,12 +165,6 @@ class API(base.Base):
greenthread.sleep(1) greenthread.sleep(1)
else: else:
volume = self.volume_api.get(context, 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.') %
{'volume_size': volume_size, 'size': size})
raise exception.InvalidVolume(reason=err)
if volume['status'] != "available": if volume['status'] != "available":
msg = _('Volume to be restored to must be available') msg = _('Volume to be restored to must be available')
@ -179,8 +173,9 @@ class API(base.Base):
LOG.debug('Checking backup size %s against volume size %s', LOG.debug('Checking backup size %s against volume size %s',
size, volume['size']) size, volume['size'])
if size > volume['size']: if size > volume['size']:
msg = _('Volume to be restored to is smaller ' msg = (_('volume size %(volume_size)d is too small to restore '
'than the backup to be restored') 'backup of size %(size)d.') %
{'volume_size': volume['size'], 'size': size})
raise exception.InvalidVolume(reason=msg) raise exception.InvalidVolume(reason=msg)
LOG.audit(_("Overwriting volume %(volume_id)s with restore of " LOG.audit(_("Overwriting volume %(volume_id)s with restore of "