]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Make size optional when creating a volume from a snap
authorDuncan Thomas <duncan.thomas@gmail.com>
Fri, 17 Aug 2012 10:15:52 +0000 (10:15 +0000)
committerDuncan Thomas <duncan.thomas@gmail.com>
Fri, 31 Aug 2012 13:51:12 +0000 (13:51 +0000)
Changing the size of a volume when cloning a snapshot doesn't
make a great deal of sense *and isn't part of the ec2 api).

This patch makes the field optional, defaulting to the same
size as the snapshot (and therefore the origination volume).

Change-Id: I3fea7fe1c0415d10e549c66a242cf2a336a7204e

cinder/api/openstack/volume/volumes.py

index 0525a4f3540eac704c9d85f5ccb125ee1f6853c9..4f43e60383af4aa1c23f5527b24286a0b38b5ede 100644 (file)
@@ -242,10 +242,6 @@ class VolumeController(object):
 
         volume = body['volume']
 
-        size = volume['size']
-
-        LOG.audit(_("Create volume of %s GB"), size, context=context)
-
         kwargs = {}
 
         req_volume_type = volume.get('volume_type', None)
@@ -265,6 +261,12 @@ class VolumeController(object):
         else:
             kwargs['snapshot'] = None
 
+        size = volume.get('size', None)
+        if size is None and kwargs['snapshot'] is not None:
+            size = kwargs['snapshot']['volume_size']
+
+        LOG.audit(_("Create volume of %s GB"), size, context=context)
+
         image_href = None
         image_uuid = None
         if self.ext_mgr.is_loaded('os-image-create'):