From: Duncan Thomas Date: Fri, 17 Aug 2012 10:15:52 +0000 (+0000) Subject: Make size optional when creating a volume from a snap X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b84d6237729efb9241d934e2d06d77bf9adb8471;p=openstack-build%2Fcinder-build.git Make size optional when creating a volume from a snap 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 --- diff --git a/cinder/api/openstack/volume/volumes.py b/cinder/api/openstack/volume/volumes.py index 0525a4f35..4f43e6038 100644 --- a/cinder/api/openstack/volume/volumes.py +++ b/cinder/api/openstack/volume/volumes.py @@ -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'):