diff options
| author | Matthew Treinish <treinish@linux.vnet.ibm.com> | 2012-09-07 14:16:14 -0400 |
|---|---|---|
| committer | Matthew Treinish <treinish@linux.vnet.ibm.com> | 2012-09-10 14:34:04 -0400 |
| commit | 210dc28ed61925f873b3da743e4703fecf1ce1b4 (patch) | |
| tree | 3d3388c973f044234b900bf23c1ce38834ad9776 | |
| parent | 37cc45b8fdaa199b248a7ef5f683d514733b8387 (diff) | |
| download | nova-210dc28ed61925f873b3da743e4703fecf1ce1b4.tar.gz nova-210dc28ed61925f873b3da743e4703fecf1ce1b4.tar.xz nova-210dc28ed61925f873b3da743e4703fecf1ce1b4.zip | |
Make size optional when creating a volume from a snapshot.
This patch makes the field optional, defaulting to the same
size as the snapshot (and therefore the origination volume).
Mirror of change I3fea7fe1c0415d10e549c66a242cf2a336a7204e from
Cinder.
Change-Id: I940a048ecf8a7b8212fa4945e3aadf2de8176554
Signed-off-by: Matthew Treinish <treinish@linux.vnet.ibm.com>
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 8 | ||||
| -rw-r--r-- | nova/api/openstack/volume/volumes.py | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index df3c14169..41e168411 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -224,8 +224,6 @@ class VolumeController(object): raise exc.HTTPUnprocessableEntity() vol = body['volume'] - size = vol['size'] - LOG.audit(_("Create volume of %s GB"), size, context=context) vol_type = vol.get('volume_type', None) if vol_type: @@ -244,6 +242,12 @@ class VolumeController(object): else: snapshot = None + size = vol.get('size', None) + if size is None and snapshot is not None: + size = snapshot['volume_size'] + + LOG.audit(_("Create volume of %s GB"), size, context=context) + availability_zone = vol.get('availability_zone', None) new_volume = self.volume_api.create(context, diff --git a/nova/api/openstack/volume/volumes.py b/nova/api/openstack/volume/volumes.py index 8c5652084..85bbbd374 100644 --- a/nova/api/openstack/volume/volumes.py +++ b/nova/api/openstack/volume/volumes.py @@ -219,10 +219,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) @@ -242,6 +238,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) + kwargs['availability_zone'] = volume.get('availability_zone', None) new_volume = self.volume_api.create(context, |
