Show quota detail when inject file quota exceeds
Provide quota info when: 1) inject file path is too long 2) inject file content is too long Change-Id: If5235c47b8d4372e7e1b88f456391c012c843605 Closes-Bug: #1668163
This commit is contained in:
parent
008bc0b971
commit
34242dbdbf
@ -311,9 +311,11 @@ class API(base.Base):
|
||||
# Favor path limit over content limit for reporting
|
||||
# purposes
|
||||
if 'injected_file_path_bytes' in exc.kwargs['overs']:
|
||||
raise exception.OnsetFilePathLimitExceeded()
|
||||
raise exception.OnsetFilePathLimitExceeded(
|
||||
allowed=exc.kwargs['quotas']['injected_file_path_bytes'])
|
||||
else:
|
||||
raise exception.OnsetFileContentLimitExceeded()
|
||||
raise exception.OnsetFileContentLimitExceeded(
|
||||
allowed=exc.kwargs['quotas']['injected_file_content_bytes'])
|
||||
|
||||
def _check_metadata_properties_quota(self, context, metadata=None):
|
||||
"""Enforce quota limits on metadata properties."""
|
||||
|
@ -1398,11 +1398,11 @@ class OnsetFileLimitExceeded(QuotaError):
|
||||
|
||||
|
||||
class OnsetFilePathLimitExceeded(OnsetFileLimitExceeded):
|
||||
msg_fmt = _("Personality file path too long")
|
||||
msg_fmt = _("Personality file path exceeds maximum %(allowed)s")
|
||||
|
||||
|
||||
class OnsetFileContentLimitExceeded(OnsetFileLimitExceeded):
|
||||
msg_fmt = _("Personality file content too long")
|
||||
msg_fmt = _("Personality file content exceeds maximum %(allowed)s")
|
||||
|
||||
|
||||
class KeypairLimitExceeded(QuotaError):
|
||||
|
@ -3208,7 +3208,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
def test_check_injected_file_quota_onset_file_path_limit(self):
|
||||
# This is the second call to limit_check.
|
||||
side_effect = (mock.DEFAULT,
|
||||
exception.OverQuota(overs='injected_file_path_bytes'))
|
||||
exception.OverQuota(overs='injected_file_path_bytes',
|
||||
quotas={'injected_file_path_bytes': 255}))
|
||||
self.assertRaises(exception.OnsetFilePathLimitExceeded,
|
||||
self._test_check_injected_file_quota_onset_file_limit_exceeded,
|
||||
side_effect)
|
||||
@ -3216,7 +3217,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
def test_check_injected_file_quota_onset_file_content_limit(self):
|
||||
# This is the second call to limit_check but with different overs.
|
||||
side_effect = (mock.DEFAULT,
|
||||
exception.OverQuota(overs='injected_file_content_bytes'))
|
||||
exception.OverQuota(overs='injected_file_content_bytes',
|
||||
quotas={'injected_file_content_bytes': 10240}))
|
||||
self.assertRaises(exception.OnsetFileContentLimitExceeded,
|
||||
self._test_check_injected_file_quota_onset_file_limit_exceeded,
|
||||
side_effect)
|
||||
|
Loading…
Reference in New Issue
Block a user