From 8b1de88df1d6a84f8f674f3565a1636ffe0a3df3 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Tue, 17 May 2016 12:25:37 -0300 Subject: [PATCH] HDS_HNAS: Fix improper error message When attempting to delete a snapshot, if the filesystem is unmounted, the error message is the output of the delete command. The delete command should not be invoked in such scenario, and a proper message should be included in the exception. Change-Id: If60f8644d4aebf5f364de44c6bef8085d2e539f7 Closes-bug: #1582747 --- manila/share/drivers/hitachi/hds_hnas.py | 3 +++ manila/tests/share/drivers/hitachi/test_hds_hnas.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/manila/share/drivers/hitachi/hds_hnas.py b/manila/share/drivers/hitachi/hds_hnas.py index 5e5060f1b7..393a0b699e 100644 --- a/manila/share/drivers/hitachi/hds_hnas.py +++ b/manila/share/drivers/hitachi/hds_hnas.py @@ -607,6 +607,9 @@ class HDSHNASDriver(driver.ShareDriver): :param share_id: ID of share that snapshot was created. :param snapshot_id: ID of snapshot. """ + + self._check_fs_mounted() + path = '/snapshots/' + share_id + '/' + snapshot_id self.hnas.tree_delete(path) path = '/snapshots/' + share_id diff --git a/manila/tests/share/drivers/hitachi/test_hds_hnas.py b/manila/tests/share/drivers/hitachi/test_hds_hnas.py index 10622f7ac9..c1b294789f 100644 --- a/manila/tests/share/drivers/hitachi/test_hds_hnas.py +++ b/manila/tests/share/drivers/hitachi/test_hds_hnas.py @@ -306,6 +306,7 @@ class HDSHNASTestCase(test.TestCase): def test_delete_snapshot(self): self.mock_object(hds_hnas.HDSHNASDriver, "_get_hnas_share_id", mock.Mock(return_value=share['id'])) + self.mock_object(hds_hnas.HDSHNASDriver, "_check_fs_mounted") self.mock_object(ssh.HNASSSHBackend, "tree_delete", mock.Mock()) self.mock_object(ssh.HNASSSHBackend, "delete_directory", mock.Mock()) @@ -313,6 +314,7 @@ class HDSHNASTestCase(test.TestCase): self.assertTrue(self.mock_log.debug.called) self.assertTrue(self.mock_log.info.called) + hds_hnas.HDSHNASDriver._check_fs_mounted.assert_called_once_with() ssh.HNASSSHBackend.tree_delete.assert_called_once_with( '/snapshots/' + share['id'] + '/' + snapshot['id']) ssh.HNASSSHBackend.delete_directory.assert_called_once_with(