Skip to content

Commit

Permalink
Make get_security_groups() return security group rules
Browse files Browse the repository at this point in the history
In nova, get_security_groups() returns the security groups and their
security group rules. In order to implement the security group proxy
it needs to return this data to nova. This can be done using multiple
requests from nova-api to quantum i.e: get_security_groups(), then
get_security_group() for each group to obtain the rules. If one has a lot
of security groups this will generate a lot of requests. Adding this change
allows all the security groups and their rules to be returned in one shot.

Fix bug 1105399

Change-Id: Ib685960311221ac4e5fe0913c7e00e15ab74accb
  • Loading branch information
aaronorosen committed Jan 28, 2013
1 parent 5db8a22 commit dc3e446
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions quantum/db/securitygroups_db.py
Expand Up @@ -202,6 +202,8 @@ def _make_security_group_dict(self, security_group, fields=None):
'description': security_group['description']}
if security_group.get('external_id'):
res['external_id'] = security_group['external_id']
res['security_group_rules'] = [self._make_security_group_rule_dict(r)
for r in security_group.rules]
return self._fields(res, fields)

def _make_security_group_binding_dict(self, security_group, fields=None):
Expand Down
5 changes: 5 additions & 0 deletions quantum/tests/unit/test_extension_security_group.py
Expand Up @@ -281,6 +281,11 @@ def test_list_security_groups(self):
res = self.new_list_request('security-groups')
groups = self.deserialize('json', res.get_response(self.ext_api))
self.assertEqual(len(groups['security_groups']), 2)
for group in groups['security_groups']:
if group['name'] == 'default':
self.assertEquals(len(group['security_group_rules']), 2)
else:
self.assertEquals(len(group['security_group_rules']), 0)

def test_get_security_group(self):
name = 'webservers'
Expand Down

0 comments on commit dc3e446

Please sign in to comment.