diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index 3c7a0dcbe4ff..0d85c7b8786d 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -414,10 +414,6 @@ class SecurityGroupRulesController(SecurityGroupControllerBase): msg = _("Parent or group id is not integer") 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 #check if groupId exists db.security_group_get(context, group_id) diff --git a/nova/tests/api/openstack/compute/contrib/test_security_groups.py b/nova/tests/api/openstack/compute/contrib/test_security_groups.py index a9422cd26d3c..0cf66ec6e290 100644 --- a/nova/tests/api/openstack/compute/contrib/test_security_groups.py +++ b/nova/tests/api/openstack/compute/contrib/test_security_groups.py @@ -784,11 +784,14 @@ class TestSecurityGroupRules(test.TestCase): req, {'security_group_rule': rule}) 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') - self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, - req, {'security_group_rule': rule}) + res_dict = self.controller.create(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): rule = {'ip_protocol': proto, 'parent_group_id': '2'}