diff --git a/nova/compute/api.py b/nova/compute/api.py index ec4927e8fda5..d67158c95f89 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -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.""" diff --git a/nova/exception.py b/nova/exception.py index 7a0212d07b44..9b1cd9a16a6e 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -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): diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 732670aae862..3753e125215b 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -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)