From d9dd8f2fd395ad02e536d8054b0615520771b93e Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 10 Nov 2011 21:28:24 -0500 Subject: Converting attach_volume to use instance object Related to blueprint internal-uuids Change-Id: I84d6e76d58de29f49d30ad3f8ac051becac626bd --- nova/api/ec2/cloud.py | 6 ++---- nova/api/openstack/contrib/volumes.py | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index a2f9ecdae..5a5b7e1d8 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1094,13 +1094,11 @@ class CloudController(object): def attach_volume(self, context, volume_id, instance_id, device, **kwargs): volume_id = ec2utils.ec2_id_to_id(volume_id) instance_id = ec2utils.ec2_id_to_id(instance_id) + instance = self.compute_api.get(context, instance_id) msg = _("Attach volume %(volume_id)s to instance %(instance_id)s" " at %(device)s") % locals() LOG.audit(msg, context=context) - self.compute_api.attach_volume(context, - instance_id=instance_id, - volume_id=volume_id, - device=device) + self.compute_api.attach_volume(context, instance, volume_id, device) volume = self.volume_api.get(context, volume_id=volume_id) return {'attachTime': volume['attach_time'], 'device': volume['mountpoint'], diff --git a/nova/api/openstack/contrib/volumes.py b/nova/api/openstack/contrib/volumes.py index cd10aaa99..917cfc61b 100644 --- a/nova/api/openstack/contrib/volumes.py +++ b/nova/api/openstack/contrib/volumes.py @@ -260,7 +260,6 @@ class VolumeAttachmentController(object): if not body: raise exc.HTTPUnprocessableEntity() - instance_id = server_id volume_id = body['volumeAttachment']['volumeId'] device = body['volumeAttachment']['device'] @@ -269,10 +268,9 @@ class VolumeAttachmentController(object): LOG.audit(msg, context=context) try: - self.compute_api.attach_volume(context, - instance_id=instance_id, - volume_id=volume_id, - device=device) + instance = self.compute_api.get(context, server_id) + self.compute_api.attach_volume(context, instance, + volume_id, device) except exception.NotFound: raise exc.HTTPNotFound() -- cgit