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

Proposed by Vish Ishaya
Status: Merged
Approved by: Jesse Andrews
Approved revision: 704
Merged at revision: 706
Proposed branch: lp:~vishvananda/nova/lp721660
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 153 lines (+15/-15)
5 files modified
nova/api/ec2/__init__.py (+1/-1)
nova/api/ec2/cloud.py (+10/-10)
nova/objectstore/bucket.py (+1/-1)
nova/objectstore/image.py (+1/-1)
nova/volume/api.py (+2/-2)
To merge this branch: bzr merge lp:~vishvananda/nova/lp721660
Reviewer Review Type Date Requested Status
Jesse Andrews (community) Approve
Devin Carlen (community) Approve
Rick Harris (community) Approve
Review via email: mp+50440@code.launchpad.net

Description of the change

Various optimizations of lookups relating to users.

To post a comment you must log in.
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm

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

lgtm

review: Approve
Revision history for this message
Jesse Andrews (anotherjesse) wrote :

I I can haz speed!

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/__init__.py'
2--- nova/api/ec2/__init__.py 2011-02-13 18:45:20 +0000
3+++ nova/api/ec2/__init__.py 2011-02-19 09:49:55 +0000
4@@ -294,7 +294,7 @@
5 return True
6 if 'none' in roles:
7 return False
8- return any(context.project.has_role(context.user.id, role)
9+ return any(context.project.has_role(context.user_id, role)
10 for role in roles)
11
12
13
14=== modified file 'nova/api/ec2/cloud.py'
15--- nova/api/ec2/cloud.py 2011-02-15 00:51:51 +0000
16+++ nova/api/ec2/cloud.py 2011-02-19 09:49:55 +0000
17@@ -282,7 +282,7 @@
18 'description': 'fixme'}]}
19
20 def describe_key_pairs(self, context, key_name=None, **kwargs):
21- key_pairs = db.key_pair_get_all_by_user(context, context.user.id)
22+ key_pairs = db.key_pair_get_all_by_user(context, context.user_id)
23 if not key_name is None:
24 key_pairs = [x for x in key_pairs if x['name'] in key_name]
25
26@@ -290,7 +290,7 @@
27 for key_pair in key_pairs:
28 # filter out the vpn keys
29 suffix = FLAGS.vpn_key_suffix
30- if context.user.is_admin() or \
31+ if context.is_admin or \
32 not key_pair['name'].endswith(suffix):
33 result.append({
34 'keyName': key_pair['name'],
35@@ -301,7 +301,7 @@
36
37 def create_key_pair(self, context, key_name, **kwargs):
38 LOG.audit(_("Create key pair %s"), key_name, context=context)
39- data = _gen_key(context, context.user.id, key_name)
40+ data = _gen_key(context, context.user_id, key_name)
41 return {'keyName': key_name,
42 'keyFingerprint': data['fingerprint'],
43 'keyMaterial': data['private_key']}
44@@ -310,7 +310,7 @@
45 def delete_key_pair(self, context, key_name, **kwargs):
46 LOG.audit(_("Delete key pair %s"), key_name, context=context)
47 try:
48- db.key_pair_destroy(context, context.user.id, key_name)
49+ db.key_pair_destroy(context, context.user_id, key_name)
50 except exception.NotFound:
51 # aws returns true even if the key doesn't exist
52 pass
53@@ -318,7 +318,7 @@
54
55 def describe_security_groups(self, context, group_name=None, **kwargs):
56 self.compute_api.ensure_default_security_group(context)
57- if context.user.is_admin():
58+ if context.is_admin:
59 groups = db.security_group_get_all(context)
60 else:
61 groups = db.security_group_get_by_project(context,
62@@ -494,7 +494,7 @@
63 if db.security_group_exists(context, context.project_id, group_name):
64 raise exception.ApiError(_('group %s already exists') % group_name)
65
66- group = {'user_id': context.user.id,
67+ group = {'user_id': context.user_id,
68 'project_id': context.project_id,
69 'name': group_name,
70 'description': group_description}
71@@ -674,7 +674,7 @@
72 else:
73 instances = self.compute_api.get_all(context, **kwargs)
74 for instance in instances:
75- if not context.user.is_admin():
76+ if not context.is_admin:
77 if instance['image_id'] == FLAGS.vpn_image_id:
78 continue
79 i = {}
80@@ -702,7 +702,7 @@
81 i['dnsName'] = i['publicDnsName'] or i['privateDnsName']
82 i['keyName'] = instance['key_name']
83
84- if context.user.is_admin():
85+ if context.is_admin:
86 i['keyName'] = '%s (%s, %s)' % (i['keyName'],
87 instance['project_id'],
88 instance['host'])
89@@ -736,7 +736,7 @@
90
91 def format_addresses(self, context):
92 addresses = []
93- if context.user.is_admin():
94+ if context.is_admin:
95 iterator = db.floating_ip_get_all(context)
96 else:
97 iterator = db.floating_ip_get_all_by_project(context,
98@@ -750,7 +750,7 @@
99 ec2_id = id_to_ec2_id(instance_id)
100 address_rv = {'public_ip': address,
101 'instance_id': ec2_id}
102- if context.user.is_admin():
103+ if context.is_admin:
104 details = "%s (%s)" % (address_rv['instance_id'],
105 floating_ip_ref['project_id'])
106 address_rv['instance_id'] = details
107
108=== modified file 'nova/objectstore/bucket.py'
109--- nova/objectstore/bucket.py 2010-11-29 12:14:26 +0000
110+++ nova/objectstore/bucket.py 2011-02-19 09:49:55 +0000
111@@ -107,7 +107,7 @@
112
113 def is_authorized(self, context):
114 try:
115- return context.user.is_admin() or \
116+ return context.is_admin or \
117 self.owner_id == context.project_id
118 except Exception, e:
119 return False
120
121=== modified file 'nova/objectstore/image.py'
122--- nova/objectstore/image.py 2011-01-20 17:52:02 +0000
123+++ nova/objectstore/image.py 2011-02-19 09:49:55 +0000
124@@ -69,7 +69,7 @@
125 # but only modified by admin or owner.
126 try:
127 return (self.metadata['isPublic'] and readonly) or \
128- context.user.is_admin() or \
129+ context.is_admin or \
130 self.metadata['imageOwnerId'] == context.project_id
131 except:
132 return False
133
134=== modified file 'nova/volume/api.py'
135--- nova/volume/api.py 2011-02-04 10:26:28 +0000
136+++ nova/volume/api.py 2011-02-19 09:49:55 +0000
137@@ -49,7 +49,7 @@
138
139 options = {
140 'size': size,
141- 'user_id': context.user.id,
142+ 'user_id': context.user_id,
143 'project_id': context.project_id,
144 'availability_zone': FLAGS.storage_availability_zone,
145 'status': "creating",
146@@ -85,7 +85,7 @@
147 return self.db.volume_get(context, volume_id)
148
149 def get_all(self, context):
150- if context.user.is_admin():
151+ if context.is_admin:
152 return self.db.volume_get_all(context)
153 return self.db.volume_get_all_by_project(context, context.project_id)
154