diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-10 21:36:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-10 21:36:51 +0000 |
| commit | 14e0b7dcfbac455952d6342dbac2c81b6eabbac1 (patch) | |
| tree | 372b15c75b171913735fe433ef83e7fedd277e97 /nova | |
| parent | d938aed913b25373269fb9ffecc89ac61e078d75 (diff) | |
| parent | 210dc28ed61925f873b3da743e4703fecf1ce1b4 (diff) | |
Merge "Make size optional when creating a volume from a snapshot."
Diffstat (limited to 'nova')
| -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, |
