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

Proposed by Vish Ishaya on 2011-02-23
Status: Merged
Approved by: Devin Carlen on 2011-02-23
Approved revision: 721
Merged at revision: 723
Proposed branch: lp:~vishvananda/nova/lp723938
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 53 lines (+8/-10)
3 files modified
nova/api/ec2/cloud.py (+3/-2)
nova/db/api.py (+2/-2)
nova/db/sqlalchemy/api.py (+3/-6)
To merge this branch: bzr merge lp:~vishvananda/nova/lp723938
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve on 2011-02-23
Jay Pipes (community) 2011-02-23 Approve on 2011-02-23
Review via email: mp+51001@code.launchpad.net

Description of the change

Fixes the describe_availability_zones to use an elevated context when getting services and the db calls to pass parameters correctly so is_admin check works.

To post a comment you must log in.
lp:~vishvananda/nova/lp723938 updated on 2011-02-23
721. By Vish Ishaya on 2011-02-23

fix describe_availability_zones

Jay Pipes (jaypipes) wrote :

lgtm.

review: Approve
Devin Carlen (devcamcar) 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-02-23 19:26:38 +0000
3+++ nova/api/ec2/cloud.py 2011-02-23 20:57:34 +0000
4@@ -198,8 +198,9 @@
5 return self._describe_availability_zones(context, **kwargs)
6
7 def _describe_availability_zones(self, context, **kwargs):
8- enabled_services = db.service_get_all(context)
9- disabled_services = db.service_get_all(context, True)
10+ ctxt = context.elevated()
11+ enabled_services = db.service_get_all(ctxt)
12+ disabled_services = db.service_get_all(ctxt, True)
13 available_zones = []
14 for zone in [service.availability_zone for service
15 in enabled_services]:
16
17=== modified file 'nova/db/api.py'
18--- nova/db/api.py 2011-02-17 22:14:07 +0000
19+++ nova/db/api.py 2011-02-23 20:57:34 +0000
20@@ -85,8 +85,8 @@
21
22
23 def service_get_all(context, disabled=False):
24- """Get all service."""
25- return IMPL.service_get_all(context, None, disabled)
26+ """Get all services."""
27+ return IMPL.service_get_all(context, disabled)
28
29
30 def service_get_all_by_topic(context, topic):
31
32=== modified file 'nova/db/sqlalchemy/api.py'
33--- nova/db/sqlalchemy/api.py 2011-02-23 18:11:35 +0000
34+++ nova/db/sqlalchemy/api.py 2011-02-23 20:57:34 +0000
35@@ -136,15 +136,12 @@
36
37
38 @require_admin_context
39-def service_get_all(context, session=None, disabled=False):
40- if not session:
41- session = get_session()
42-
43- result = session.query(models.Service).\
44+def service_get_all(context, disabled=False):
45+ session = get_session()
46+ return session.query(models.Service).\
47 filter_by(deleted=can_read_deleted(context)).\
48 filter_by(disabled=disabled).\
49 all()
50- return result
51
52
53 @require_admin_context