diff --git a/Authors b/Authors index 36ec620cdeb3..633677d886ff 100644 --- a/Authors +++ b/Authors @@ -103,6 +103,7 @@ Nachi Ueno Naveed Massjouni Nikolay Sokolov Nirmal Ranganathan +Ollie Leahy Paul Voccio Renuka Apte Ricardo Carrillo Cruz diff --git a/nova/exception.py b/nova/exception.py index 78a888faa2ea..c6e08824be98 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -396,7 +396,7 @@ class SnapshotNotFound(NotFound): message = _("Snapshot %(snapshot_id)s could not be found.") -class VolumeIsBusy(Error): +class VolumeIsBusy(NovaException): message = _("deleting volume %(volume_name)s that has snapshot") diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 588b7a3288a6..6c81facf8b71 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -294,6 +294,34 @@ class DriverTestCase(test.TestCase): self.volume.delete_volume(self.context, volume_id) +class VolumeDriverTestCase(DriverTestCase): + """Test case for VolumeDriver""" + driver_name = "nova.volume.driver.VolumeDriver" + + def setUp(self): + super(VolumeDriverTestCase, self).setUp() + + def tearDown(self): + super(VolumeDriverTestCase, self).tearDown() + + def test_delete_busy_volume(self): + """Test deleting a busy volume.""" + self.stubs.Set(self.volume.driver, '_volume_not_present', + lambda x: False) + self.stubs.Set(self.volume.driver, '_delete_volume', + lambda x, y: False) + # Want DriverTestCase._fake_execute to return 'o' so that + # volume.driver.delete_volume() raises the VolumeIsBusy exception. + self.output = 'o' + self.assertRaises(exception.VolumeIsBusy, + self.volume.driver.delete_volume, + {'name': 'test1', 'size': 1024}) + # when DriverTestCase._fake_execute returns something other than + # 'o' volume.driver.delete_volume() does not raise an exception. + self.output = 'x' + self.volume.driver.delete_volume({'name': 'test1', 'size': 1024}) + + class ISCSITestCase(DriverTestCase): """Test Case for ISCSIDriver""" driver_name = "nova.volume.driver.ISCSIDriver"