diff options
-rw-r--r-- | nova/api/openstack/compute/contrib/security_groups.py | 2 | ||||
-rw-r--r-- | nova/exception.py | 4 | ||||
-rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_security_groups.py | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index 004df4e73..1705bdd26 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -509,7 +509,7 @@ class NativeSecurityGroupAPI(compute.api.SecurityGroupAPI): @staticmethod def raise_over_quota(msg): - raise exc.HTTPBadRequest(explanation=msg) + raise exception.SecurityGroupLimitExceeded(msg) @staticmethod def raise_not_found(msg): diff --git a/nova/exception.py b/nova/exception.py index c6f05e97e..b63406427 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -1040,6 +1040,10 @@ class KeypairLimitExceeded(QuotaError): message = _("Maximum number of key pairs exceeded") +class SecurityGroupLimitExceeded(QuotaError): + message = _("Maximum number of security groups or rules exceeded") + + class AggregateError(NovaException): message = _("Aggregate %(aggregate_id)s: action '%(action)s' " "caused an error: %(reason)s.") 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 9e636de14..ea7d21db1 100644 --- a/nova/tests/api/openstack/compute/contrib/test_security_groups.py +++ b/nova/tests/api/openstack/compute/contrib/test_security_groups.py @@ -231,7 +231,8 @@ class TestSecurityGroups(test.TestCase): self.assertEqual(res_dict['security_group']['name'], name) sg = security_group_template() - self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, + self.assertRaises(exception.SecurityGroupLimitExceeded, + self.controller.create, req, {'security_group': sg}) def test_get_security_group_list(self): @@ -936,7 +937,8 @@ class TestSecurityGroupRules(test.TestCase): 'ip_protocol': 'tcp', 'from_port': '121', 'to_port': '121', 'parent_group_id': '2', 'group_id': '1' } - self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, + self.assertRaises(exception.SecurityGroupLimitExceeded, + self.controller.create, req, {'security_group_rule': rule}) |