From 0bc531254cb964556cbe8d2fbf1f9321f92aaf93 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Mon, 25 Feb 2013 15:03:20 -0800 Subject: ec2 _format_security_group() accesses db when using quantum_driver This patch fixes _format_security_group() so that it does not access the db when using quantum. In addition, this patch implements the querying params that were missing in get() and list() in the quantum security group driver. Fixes bug 1131956 Change-Id: I5ec65829301bca7e5b215d5052a18528dff76517 --- nova/api/ec2/cloud.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index dcbde3428..60b06c233 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -503,9 +503,17 @@ class CloudController(object): r['groups'] = [] r['ipRanges'] = [] if rule['group_id']: - source_group = rule['grantee_group'] - r['groups'] += [{'groupName': source_group['name'], - 'userId': source_group['project_id']}] + if rule.get('grantee_group'): + source_group = rule['grantee_group'] + r['groups'] += [{'groupName': source_group['name'], + 'userId': source_group['project_id']}] + else: + # rule is not always joined with grantee_group + # for example when using quantum driver. + source_group = self.security_group_api.get( + context, id=rule['group_id']) + r['groups'] += [{'groupName': source_group.get('name'), + 'userId': source_group.get('project_id')}] if rule['protocol']: r['ipProtocol'] = rule['protocol'].lower() r['fromPort'] = rule['from_port'] -- cgit