From 358ccf5f196b6b43f18778afae279633c051c6d9 Mon Sep 17 00:00:00 2001 From: MotoKen Date: Thu, 1 Nov 2012 15:07:52 +0800 Subject: Improve EC2 describe_security_groups performance The current implementation of EC2 describe_security_groups makes one query per grantee group rule in _format_security_group. This will dramatically slow down response time if users make strong use of grantee group rules. This patch uses just one DB query to get security groups with joined grantee_group rules to improve the performance. Fixes bug 1073024. Change-Id: I34f3253bfef0eabfea39819de03a274dd6f6aaa8 --- nova/api/ec2/cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 20e68030f..3446b5a8f 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -457,7 +457,7 @@ class CloudController(object): r['groups'] = [] r['ipRanges'] = [] if rule.group_id: - source_group = db.security_group_get(context, rule.group_id) + source_group = rule.grantee_group r['groups'] += [{'groupName': source_group.name, 'userId': source_group.project_id}] if rule.protocol: -- cgit