From 97475c085ad18ee8c7719fecd22c1380b01284b8 Mon Sep 17 00:00:00 2001 From: Simon Collins Date: Wed, 17 Jan 2018 12:11:15 +1300 Subject: [PATCH] Security group quota error handling When adding a new rule to a secruity group that would exceede the quota, the error message displays a quota error, rather than rule already exists error. It does this my first checking for an "OverQuotaClient" error, then if that except doesn't trigger it checks for any other conflict Change-Id: I8eaa0f00b25c8c3b75fef2bf46979f1f248c6896 Closes-Bug: #1699724 (cherry picked from commit 3929a8b7cd893f0b4c0ff6c20d5d1fd9077b4dd2) --- openstack_dashboard/api/neutron.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 3266eb396a..5e395ba11e 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -377,8 +377,12 @@ class SecurityGroupManager(object): 'remote_group_id': group_id}} try: rule = self.client.create_security_group_rule(body) + except neutron_exc.OverQuotaClient: + raise exceptions.Conflict( + _('Security group rule quotas exceed.')) except neutron_exc.Conflict: - raise exceptions.Conflict(_('Security group rule already exists.')) + raise exceptions.Conflict( + _('Security group rule already exists.')) rule = rule.get('security_group_rule') sg_dict = self._sg_name_dict(parent_group_id, [rule]) return SecurityGroupRule(rule, sg_dict)