Merge lp:~vishvananda/nova/lp706072 into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Vish Ishaya
Approved revision: 594
Merged at revision: 617
Proposed branch: lp:~vishvananda/nova/lp706072
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 63 lines (+23/-7)
2 files modified
nova/api/ec2/cloud.py (+21/-7)
nova/db/sqlalchemy/api.py (+2/-0)
To merge this branch: bzr merge lp:~vishvananda/nova/lp706072
Reviewer Review Type Date Requested Status
Rick Harris (community) Approve
Devin Carlen (community) Approve
Jay Pipes (community) Needs Fixing
Review via email: mp+47128@code.launchpad.net

Description of the change

Wraps the NotFound exception at the api layer to print the proper instance id. Does the same for volume. Note that euca-describe-volumes doesn't pass in volume ids properly, so you will get no error messages on euca-describe-volumes with improper ids. We may also need to wrap a few other calls as well.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi!

Code looks good! Need to i18n those strings in the exceptions, though! :)

-jay

review: Needs Fixing
Revision history for this message
Vish Ishaya (vishvananda) wrote :

DOH! Fixed

lp:~vishvananda/nova/lp706072 updated
594. By Vish Ishaya

i18n!

Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/ec2/cloud.py'
2--- nova/api/ec2/cloud.py 2011-01-20 20:04:57 +0000
3+++ nova/api/ec2/cloud.py 2011-01-22 00:05:24 +0000
4@@ -529,11 +529,18 @@
5
6 def describe_volumes(self, context, volume_id=None, **kwargs):
7 if volume_id:
8- volume_id = [ec2_id_to_id(x) for x in volume_id]
9- volumes = self.volume_api.get_all(context)
10- # NOTE(vish): volume_id is an optional list of volume ids to filter by.
11- volumes = [self._format_volume(context, v) for v in volumes
12- if volume_id is None or v['id'] in volume_id]
13+ volumes = []
14+ for ec2_id in volume_id:
15+ internal_id = ec2_id_to_id(ec2_id)
16+ try:
17+ volume = self.volume_api.get(context, internal_id)
18+ volumes.append(volume)
19+ except exception.NotFound:
20+ raise exception.NotFound(_("Volume %s not found")
21+ % ec2_id)
22+ else:
23+ volumes = self.volume_api.get_all(context)
24+ volumes = [self._format_volume(context, v) for v in volumes]
25 return {'volumeSet': volumes}
26
27 def _format_volume(self, context, volume):
28@@ -657,8 +664,15 @@
29 reservations = {}
30 # NOTE(vish): instance_id is an optional list of ids to filter by
31 if instance_id:
32- instance_id = [ec2_id_to_id(x) for x in instance_id]
33- instances = [self.compute_api.get(context, x) for x in instance_id]
34+ instances = []
35+ for ec2_id in instance_id:
36+ internal_id = ec2_id_to_id(ec2_id)
37+ try:
38+ instance = self.compute_api.get(context, internal_id)
39+ instances.append(instance)
40+ except exception.NotFound:
41+ raise exception.NotFound(_("Instance %s not found")
42+ % ec2_id)
43 else:
44 instances = self.compute_api.get_all(context, **kwargs)
45 for instance in instances:
46
47=== modified file 'nova/db/sqlalchemy/api.py'
48--- nova/db/sqlalchemy/api.py 2011-01-20 01:34:54 +0000
49+++ nova/db/sqlalchemy/api.py 2011-01-22 00:05:24 +0000
50@@ -1395,11 +1395,13 @@
51
52 if is_admin_context(context):
53 result = session.query(models.Volume).\
54+ options(joinedload('instance')).\
55 filter_by(id=volume_id).\
56 filter_by(deleted=can_read_deleted(context)).\
57 first()
58 elif is_user_context(context):
59 result = session.query(models.Volume).\
60+ options(joinedload('instance')).\
61 filter_by(project_id=context.project_id).\
62 filter_by(id=volume_id).\
63 filter_by(deleted=False).\