Merge "Allow self-referential groups to be created"

This commit is contained in:
Jenkins 2012-03-30 00:49:19 +00:00 committed by Gerrit Code Review
commit 75676812e8
2 changed files with 6 additions and 7 deletions

View File

@ -414,10 +414,6 @@ class SecurityGroupRulesController(SecurityGroupControllerBase):
msg = _("Parent or group id is not integer") msg = _("Parent or group id is not integer")
raise exception.InvalidInput(reason=msg) raise exception.InvalidInput(reason=msg)
if parent_group_id == group_id:
msg = _("Parent group id and group id cannot be same")
raise exception.InvalidInput(reason=msg)
values['group_id'] = group_id values['group_id'] = group_id
#check if groupId exists #check if groupId exists
db.security_group_get(context, group_id) db.security_group_get(context, group_id)

View File

@ -784,11 +784,14 @@ class TestSecurityGroupRules(test.TestCase):
req, {'security_group_rule': rule}) req, {'security_group_rule': rule})
def test_create_with_same_group_parent_id_and_group_id(self): def test_create_with_same_group_parent_id_and_group_id(self):
rule = security_group_rule_template(group_id=2) rule = security_group_rule_template(group_id=1, parent_group_id=1)
req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules') req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules')
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, res_dict = self.controller.create(req, {'security_group_rule': rule})
req, {'security_group_rule': rule}) security_group_rule = res_dict['security_group_rule']
self.assertNotEquals(security_group_rule['id'], 0)
self.assertEquals(security_group_rule['parent_group_id'], 1)
self.assertEquals(security_group_rule['id'], 1)
def _test_create_with_no_ports_and_no_group(self, proto): def _test_create_with_no_ports_and_no_group(self, proto):
rule = {'ip_protocol': proto, 'parent_group_id': '2'} rule = {'ip_protocol': proto, 'parent_group_id': '2'}