]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Provide user with more information on quota fail
authorOllie Leahy <oliver.leahy@hp.com>
Fri, 4 Oct 2013 14:56:26 +0000 (14:56 +0000)
committerOllie Leahy <oliver.leahy@hp.com>
Fri, 4 Oct 2013 16:21:10 +0000 (16:21 +0000)
Provide the user with useful information when a snapshot or volume
create fails because it would cause the user to exceed available quota.
Specifically report the user's current gigabyte usage and quota
allocations.

Closes-Bug: #1235148

Change-Id: Ib4c5dbcbd172c69834c2824791af755380f38e01

cinder/exception.py
cinder/tests/api/contrib/test_backups.py
cinder/tests/api/contrib/test_volume_transfer.py
cinder/transfer/api.py
cinder/volume/api.py
cinder/volume/flows/create_volume/__init__.py

index 7c2bdddc9c2a174a4437d18117fb06124164d968..1a35d2c62005fae47efe65e24e3dcf771b141a37 100644 (file)
@@ -399,8 +399,9 @@ class QuotaError(CinderException):
 
 
 class VolumeSizeExceedsAvailableQuota(QuotaError):
-    message = _("Requested volume or snapshot exceeds "
-                "allowed Gigabytes quota")
+    message = _("Requested volume or snapshot exceeds allowed Gigabytes "
+                "quota. Requested %(requested)sG, quota is %(quota)sG and "
+                "%(consumed)sG has been consumed.")
 
 
 class VolumeLimitExceeded(QuotaError):
index 9cca5e254d7fb73e20617ea949b8f16ac69599a2..0ff300e75d39c1ad509458097fd4e54e7624557c 100644 (file)
@@ -852,7 +852,9 @@ class BackupsAPITestCase(test.TestCase):
 
         def fake_backup_api_restore_throwing_VolumeSizeExceedsAvailableQuota(
                 cls, context, backup_id, volume_id):
-            raise exception.VolumeSizeExceedsAvailableQuota()
+            raise exception.VolumeSizeExceedsAvailableQuota(requested='2',
+                                                            consumed='2',
+                                                            quota='3')
 
         self.stubs.Set(
             cinder.backup.API,
@@ -877,7 +879,8 @@ class BackupsAPITestCase(test.TestCase):
         self.assertEqual(res_dict['overLimit']['code'], 413)
         self.assertEqual(res_dict['overLimit']['message'],
                          'Requested volume or snapshot exceeds allowed '
-                         'Gigabytes quota')
+                         'Gigabytes quota. Requested 2G, quota is 3G and '
+                         '2G has been consumed.')
 
     def test_restore_backup_with_VolumeLimitExceeded(self):
 
index 5ca1e9ac97897f8f8daef1f26b59de9c7b6f4389..30d5f22acb73f80d5a7b57b31e42e59fb0e7d825 100644 (file)
@@ -513,7 +513,9 @@ class VolumeTransferAPITestCase(test.TestCase):
 
         def fake_transfer_api_accept_throwing_VolumeSizeExceedsAvailableQuota(
                 cls, context, transfer, volume_id):
-            raise exception.VolumeSizeExceedsAvailableQuota()
+            raise exception.VolumeSizeExceedsAvailableQuota(requested='2',
+                                                            consumed='2',
+                                                            quota='3')
 
         self.stubs.Set(
             cinder.transfer.API,
@@ -538,7 +540,8 @@ class VolumeTransferAPITestCase(test.TestCase):
         self.assertEqual(res_dict['overLimit']['code'], 413)
         self.assertEqual(res_dict['overLimit']['message'],
                          'Requested volume or snapshot exceeds allowed '
-                         'Gigabytes quota')
+                         'Gigabytes quota. Requested 2G, quota is 3G and '
+                         '2G has been consumed.')
 
     def test_accept_transfer_with_VolumeLimitExceeded(self):
 
index c52f3faa51e12f8af2ce7842645a9a1481b1ab69..99ccf23a7e586887256b94ce6df4dc51d962970d 100644 (file)
@@ -162,7 +162,10 @@ class API(base.Base):
                                 's_size': vol_ref['size'],
                                 'd_consumed': _consumed('gigabytes'),
                                 'd_quota': quotas['gigabytes']})
-                raise exception.VolumeSizeExceedsAvailableQuota()
+                raise exception.VolumeSizeExceedsAvailableQuota(
+                    requested=vol_ref['size'],
+                    consumed=_consumed('gigabytes'),
+                    quota=quotas['gigabytes'])
             elif 'volumes' in overs:
                 msg = _("Quota exceeded for %(s_pid)s, tried to create "
                         "volume (%(d_consumed)d volumes "
index fd43731d13e844f2d7574ddbd62d51b1a5420a11..c17330d63140ece28d06da78f0aaf61f4e9a5e91 100644 (file)
@@ -496,7 +496,10 @@ class API(base.Base):
                                     's_size': volume['size'],
                                     'd_consumed': _consumed(over),
                                     'd_quota': quotas[over]})
-                    raise exception.VolumeSizeExceedsAvailableQuota()
+                    raise exception.VolumeSizeExceedsAvailableQuota(
+                        requested=volume['size'],
+                        consumed=_consumed('gigabytes'),
+                        quota=quotas['gigabytes'])
                 elif 'snapshots' in over:
                     msg = _("Quota exceeded for %(s_pid)s, tried to create "
                             "snapshot (%(d_consumed)d snapshots "
index 03a7933e11cd44da9480695681d53bd794369c46..0bda98918bbc85f9abdf41fca3953546c35f6510 100644 (file)
@@ -634,7 +634,10 @@ class QuotaReserveTask(base.CinderTask):
                                 's_size': size,
                                 'd_consumed': _consumed('gigabytes'),
                                 'd_quota': quotas['gigabytes']})
-                raise exception.VolumeSizeExceedsAvailableQuota()
+                raise exception.VolumeSizeExceedsAvailableQuota(
+                    requested=size,
+                    consumed=_consumed('gigabytes'),
+                    quota=quotas['gigabytes'])
             elif _is_over('volumes'):
                 msg = _("Quota exceeded for %(s_pid)s, tried to create "
                         "volume (%(d_consumed)d volumes "