From: Ivan Kolodyazhny Date: Wed, 8 Apr 2015 10:49:49 +0000 (+0300) Subject: Add volume status to error messages in backup create flow X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=992d7a10dfcadd7844a396c4afbb0954c2ecfaa9;p=openstack-build%2Fcinder-build.git Add volume status to error messages in backup create flow If volume status is not 'available' we can't create a backup. Adding current volume status to error message will make logs more user-friendly. Change-Id: Iab7a794a5104b28c54de23571f589fcf60e09c7d --- diff --git a/cinder/backup/api.py b/cinder/backup/api.py index fd41e97a0..1c94dd059 100644 --- a/cinder/backup/api.py +++ b/cinder/backup/api.py @@ -127,7 +127,9 @@ class API(base.Base): volume = self.volume_api.get(context, volume_id) if volume['status'] != "available": - msg = _('Volume to be backed up must be available') + msg = (_('Volume to be backed up must be available ' + 'but the current status is "%s".') + % volume['status']) raise exception.InvalidVolume(reason=msg) volume_host = volume_utils.extract_host(volume['host'], 'host') diff --git a/cinder/tests/unit/api/contrib/test_backups.py b/cinder/tests/unit/api/contrib/test_backups.py index 09077e674..7624efc07 100644 --- a/cinder/tests/unit/api/contrib/test_backups.py +++ b/cinder/tests/unit/api/contrib/test_backups.py @@ -609,9 +609,6 @@ class BackupsAPITestCase(test.TestCase): self.assertEqual(res.status_int, 400) self.assertEqual(res_dict['badRequest']['code'], 400) - self.assertEqual(res_dict['badRequest']['message'], - 'Invalid volume: Volume to be backed up must' - ' be available') def test_create_backup_with_InvalidVolume2(self): # need to create the volume referenced below first @@ -633,9 +630,6 @@ class BackupsAPITestCase(test.TestCase): self.assertEqual(res.status_int, 400) self.assertEqual(res_dict['badRequest']['code'], 400) - self.assertEqual(res_dict['badRequest']['message'], - 'Invalid volume: Volume to be backed up must' - ' be available') @mock.patch('cinder.db.service_get_all_by_topic') def test_create_backup_WithOUT_enabled_backup_service(