diff options
| author | Aaron Rosen <arosen@nicira.com> | 2013-03-29 18:09:28 -0700 |
|---|---|---|
| committer | Aaron Rosen <arosen@nicira.com> | 2013-03-29 18:28:56 -0700 |
| commit | afeb95dfc924ed7e768d76bc5ae4bd4c55e9dcb3 (patch) | |
| tree | 5931ad7bedea75a201ab7b77783484648b60af74 /nova/api | |
| parent | faf24498fc1f09ef2e975709482ad9985f18e913 (diff) | |
| download | nova-afeb95dfc924ed7e768d76bc5ae4bd4c55e9dcb3.tar.gz nova-afeb95dfc924ed7e768d76bc5ae4bd4c55e9dcb3.tar.xz nova-afeb95dfc924ed7e768d76bc5ae4bd4c55e9dcb3.zip | |
Query quantum once for instance's security groups
This patch adds the method get_instance_security_group_bindings()
which returns all the instance_id's and security groups for a given
tenant. This method is then used to avoid querying quantum for it's
security groups when using GET /v2/<project_id>/servers/detail.
Fixes bug 1161518
Change-Id: Ia28d5573c264f0316ab9fb257ca8e7ae35679883
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/security_groups.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index c019011f5..700d9b71e 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -482,10 +482,11 @@ class SecurityGroupsOutputController(wsgi.Controller): # quantum security groups the requested security groups for the # instance are not in the db and have not been sent to quantum yet. if req.method != 'POST': + sg_instance_bindings = ( + self.security_group_api + .get_instances_security_groups_bindings(context)) for server in servers: - groups = ( - self.security_group_api.get_instance_security_groups( - context, server['id'])) + groups = sg_instance_bindings.get(server['id']) if groups: server[key] = groups # In this section of code len(servers) == 1 as you can only POST |
