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
'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):
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'