Skip to content

Commit

Permalink
Merge "Make size optional when creating a volume from a snapshot."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 10, 2012
2 parents d938aed + 210dc28 commit 14e0b7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions nova/api/openstack/compute/contrib/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ def create(self, req, body):
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:
Expand All @@ -244,6 +242,12 @@ def create(self, req, body):
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,
Expand Down
10 changes: 6 additions & 4 deletions nova/api/openstack/volume/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ def create(self, req, body):

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)
Expand All @@ -242,6 +238,12 @@ def create(self, req, body):
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,
Expand Down

0 comments on commit 14e0b7d

Please sign in to comment.