diff options
| author | Oleg Bondarev <obondarev@mirantis.com> | 2013-04-26 12:52:26 +0400 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2013-05-14 09:55:23 +0100 |
| commit | 586e752e69ca891714f390bf59ad30d5081d4498 (patch) | |
| tree | 39a29f9cbd6e73b57893ab575c5275cd46f3915c /nova/api | |
| parent | 28f0b01717f17ecc545a25f6deb0aa240e5aaf0d (diff) | |
| download | nova-586e752e69ca891714f390bf59ad30d5081d4498.tar.gz nova-586e752e69ca891714f390bf59ad30d5081d4498.tar.xz nova-586e752e69ca891714f390bf59ad30d5081d4498.zip | |
Refactor nova.volume.cinder.API to reduce roundtrips with Cinder
Make cinder.API methods accept volume_id instead of the whole volume object.
This will remove redundant roundtrip to get the volume before
passing it to other methods as in fact they only need the id.
Fixes bug 1172297
Change-Id: I5e7f944c1c29b2f211ece2ef86c0959c81e806df
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 10 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 11 |
2 files changed, 8 insertions, 13 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 3d210404c..33ffbbc21 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -391,8 +391,8 @@ class CloudController(object): LOG.audit(_("Create snapshot of volume %s"), volume_id, context=context) volume_id = ec2utils.ec2_vol_id_to_uuid(volume_id) - volume = self.volume_api.get(context, volume_id) - args = (context, volume, kwargs.get('name'), kwargs.get('description')) + args = (context, volume_id, kwargs.get('name'), + kwargs.get('description')) if kwargs.get('force', False): snapshot = self.volume_api.create_snapshot_force(*args) else: @@ -403,8 +403,7 @@ class CloudController(object): def delete_snapshot(self, context, snapshot_id, **kwargs): snapshot_id = ec2utils.ec2_snap_id_to_uuid(snapshot_id) - snapshot = self.volume_api.get_snapshot(context, snapshot_id) - self.volume_api.delete_snapshot(context, snapshot) + self.volume_api.delete_snapshot(context, snapshot_id) return True def describe_key_pairs(self, context, key_name=None, **kwargs): @@ -863,8 +862,7 @@ class CloudController(object): validate_ec2_id(volume_id) volume_id = ec2utils.ec2_vol_id_to_uuid(volume_id) try: - volume = self.volume_api.get(context, volume_id) - self.volume_api.delete(context, volume) + self.volume_api.delete(context, volume_id) except exception.InvalidVolume: raise exception.EC2APIError(_('Delete Failed')) diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 640ac0c76..6b598c6eb 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -187,8 +187,7 @@ class VolumeController(wsgi.Controller): LOG.audit(_("Delete volume with id: %s"), id, context=context) try: - vol = self.volume_api.get(context, id) - self.volume_api.delete(context, vol) + self.volume_api.delete(context, id) except exception.NotFound: raise exc.HTTPNotFound() return webob.Response(status_int=202) @@ -573,8 +572,7 @@ class SnapshotController(wsgi.Controller): LOG.audit(_("Delete snapshot with id: %s"), id, context=context) try: - snapshot = self.volume_api.get_snapshot(context, id) - self.volume_api.delete_snapshot(context, snapshot) + self.volume_api.delete_snapshot(context, id) except exception.NotFound: return exc.HTTPNotFound() return webob.Response(status_int=202) @@ -610,7 +608,6 @@ class SnapshotController(wsgi.Controller): snapshot = body['snapshot'] volume_id = snapshot['volume_id'] - vol = self.volume_api.get(context, volume_id) force = snapshot.get('force', False) LOG.audit(_("Create snapshot from volume %s"), volume_id, @@ -622,12 +619,12 @@ class SnapshotController(wsgi.Controller): if utils.bool_from_str(force): new_snapshot = self.volume_api.create_snapshot_force(context, - vol, + volume_id, snapshot.get('display_name'), snapshot.get('display_description')) else: new_snapshot = self.volume_api.create_snapshot(context, - vol, + volume_id, snapshot.get('display_name'), snapshot.get('display_description')) |
