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
This commit is contained in:
Simon Collins 2018-01-17 12:11:15 +13:00
parent 6c2193b994
commit 3929a8b7cd
1 changed files with 5 additions and 1 deletions

View File

@ -419,8 +419,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)