Prevent create volume from snapshot with bad size

Prevent to create a volume from a snapshot with a volume size less
than the snapshot size.

Check if a volume size is specified that it is less than
the snapshot size.

Raise a exception if it's lesser.

Fixes bug 1161841

Change-Id: Ic1afbfb025ce0b3906c35c6c50a71734d74a9851
This commit is contained in:
Jean-Baptiste RANSY
2013-03-30 15:25:29 +01:00
parent b7986d03c5
commit cabca4fd30
2 changed files with 18 additions and 1 deletions

View File

@@ -104,7 +104,10 @@ class API(base.Base):
raise exception.InvalidSnapshot(reason=msg)
if not size:
size = snapshot['volume_size']
elif size < snapshot['volume_size']:
msg = _("Volume size cannot be lesser than"
" the Snapshot size")
raise exception.InvalidInput(reason=msg)
snapshot_id = snapshot['id']
else:
snapshot_id = None