diff options
author | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-05-22 21:10:03 +0930 |
---|---|---|
committer | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-06-07 10:16:59 +0930 |
commit | bc0a05dd4aa5e1eb104efd63fda7bbe939bc7cbe (patch) | |
tree | f1d197771e0965a3eb59e33983376ce8331e6cee /nova/api | |
parent | 8b632660aff27582c9b8ced3e0642399f3139f81 (diff) | |
download | nova-bc0a05dd4aa5e1eb104efd63fda7bbe939bc7cbe.tar.gz nova-bc0a05dd4aa5e1eb104efd63fda7bbe939bc7cbe.tar.xz nova-bc0a05dd4aa5e1eb104efd63fda7bbe939bc7cbe.zip |
Handle security group quota exceeded gracefully
Handle the security group quota exceeded more gracefully so a
traceback is not generated in the log files when this error
occurs. This does not change the API as the HTTP status code
returned remains the same.
Fixes bug 1182859
Change-Id: Id3ac513048751759f01b328482b4f02e26ff66ee
Diffstat (limited to 'nova/api')
-rw-r--r-- | nova/api/openstack/compute/contrib/security_groups.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index 041eb0dc5..40b085be1 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -289,8 +289,12 @@ class SecurityGroupController(SecurityGroupControllerBase): self.security_group_api.validate_property(group_description, 'description', None) - group_ref = self.security_group_api.create_security_group( - context, group_name, group_description) + try: + group_ref = self.security_group_api.create_security_group( + context, group_name, group_description) + except exception.SecurityGroupLimitExceeded as err: + raise exc.HTTPRequestEntityTooLarge( + explanation=err.format_message()) return {'security_group': self._format_security_group(context, group_ref)} @@ -356,9 +360,13 @@ class SecurityGroupRulesController(SecurityGroupControllerBase): msg = _("Bad prefix for network in cidr %s") % new_rule['cidr'] raise exc.HTTPBadRequest(explanation=msg) - security_group_rule = ( - self.security_group_api.create_security_group_rule( - context, security_group, new_rule)) + try: + security_group_rule = ( + self.security_group_api.create_security_group_rule( + context, security_group, new_rule)) + except exception.SecurityGroupLimitExceeded as err: + raise exc.HTTPRequestEntityTooLarge( + explanation=err.format_message()) return {"security_group_rule": self._format_security_group_rule( context, |