Move keypair quota error message into exception
The KeypairLimitExceeded exception has a message string which is never used. We raise this exception and then return a different message to the API user. For the unified limit work, we want to move to using oslo.limit's better error messages when available, which means we need to honor the message in the exception. This just moves the legacy string into the exception and makes the API use that instead of overriding it. Related to bp/unified-limits-nova Change-Id: I217b3d0551291498191b556f62d78abf159778c2
This commit is contained in:
@@ -26,7 +26,6 @@ from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.objects import keypair as keypair_obj
|
||||
from nova.policies import keypairs as kp_policies
|
||||
|
||||
@@ -119,9 +118,8 @@ class KeypairController(wsgi.Controller):
|
||||
context, user_id, name, key_type_value)
|
||||
keypair['private_key'] = private_key
|
||||
return_priv_key = True
|
||||
except exception.KeypairLimitExceeded:
|
||||
msg = _("Quota exceeded, too many key pairs.")
|
||||
raise webob.exc.HTTPForbidden(explanation=msg)
|
||||
except exception.KeypairLimitExceeded as e:
|
||||
raise webob.exc.HTTPForbidden(explanation=str(e))
|
||||
except exception.InvalidKeypair as exc:
|
||||
raise webob.exc.HTTPBadRequest(explanation=exc.format_message())
|
||||
except exception.KeyPairExists as exc:
|
||||
|
||||
+1
-1
@@ -1270,7 +1270,7 @@ class OnsetFileContentLimitExceeded(OnsetFileLimitExceeded):
|
||||
|
||||
|
||||
class KeypairLimitExceeded(OverQuota):
|
||||
msg_fmt = _("Maximum number of key pairs exceeded")
|
||||
msg_fmt = _("Quota exceeded, too many key pairs.")
|
||||
|
||||
|
||||
class SecurityGroupLimitExceeded(OverQuota):
|
||||
|
||||
@@ -155,7 +155,7 @@ class CreateImportSharedTestMixIn(object):
|
||||
return_value={'user': {
|
||||
'key_pairs': CONF.quota.key_pairs}})
|
||||
def test_quota_limit(self, mock_count_as_dict):
|
||||
msg = "Maximum number of key pairs exceeded"
|
||||
msg = "Quota exceeded, too many key pairs."
|
||||
self.assertKeypairRaises(exception.KeypairLimitExceeded, msg, 'foo')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user