Merge "Throw an exception in case of exceeding quota."

This commit is contained in:
Zuul 2020-05-04 16:52:41 +00:00 committed by Gerrit Code Review
commit 20e35d13bf
1 changed files with 9 additions and 4 deletions

View File

@ -186,10 +186,15 @@ def create_security_group_rule(body):
sgr = os_net.create_security_group_rule(**params)
return sgr.id
except os_exc.ConflictException as ex:
LOG.debug("Failed to create already existing security group "
"rule %s", body)
# Get existent sg rule id from exception message
return str(ex).split()[-1][:-1]
if 'quota' in ex.details.lower():
LOG.error("Failed to create security group rule %s: %s", body,
ex.details)
raise
else:
LOG.debug("Failed to create already existing security group "
"rule %s", body)
# Get existent sg rule id from exception message
return str(ex).split()[-1][:-1]
except os_exc.SDKException:
LOG.debug("Error creating security group rule")
raise