Redundant size check in volume restore api

In cinder volume restore api, we do twice size check when restore volume
with a given volume uuid. It's necessary to remove the redundant check.

Change-Id: I8f240b2c0d1014d212ff56c2c9b5e193f9d552bd
Closes-Bug: #1264053
This commit is contained in:
ling-yun 2013-12-25 16:03:27 +08:00
parent 8a5ce963dc
commit 5fe07c1be3
1 changed files with 3 additions and 8 deletions

View File

@ -165,12 +165,6 @@ class API(base.Base):
greenthread.sleep(1)
else:
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":
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',
size, volume['size'])
if size > volume['size']:
msg = _('Volume to be restored to is smaller '
'than the backup to be restored')
msg = (_('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=msg)
LOG.audit(_("Overwriting volume %(volume_id)s with restore of "