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
This commit is contained in:
parent
70bf53b574
commit
8b1de88df1
@ -607,6 +607,9 @@ class HDSHNASDriver(driver.ShareDriver):
|
|||||||
:param share_id: ID of share that snapshot was created.
|
:param share_id: ID of share that snapshot was created.
|
||||||
:param snapshot_id: ID of snapshot.
|
:param snapshot_id: ID of snapshot.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self._check_fs_mounted()
|
||||||
|
|
||||||
path = '/snapshots/' + share_id + '/' + snapshot_id
|
path = '/snapshots/' + share_id + '/' + snapshot_id
|
||||||
self.hnas.tree_delete(path)
|
self.hnas.tree_delete(path)
|
||||||
path = '/snapshots/' + share_id
|
path = '/snapshots/' + share_id
|
||||||
|
@ -306,6 +306,7 @@ class HDSHNASTestCase(test.TestCase):
|
|||||||
def test_delete_snapshot(self):
|
def test_delete_snapshot(self):
|
||||||
self.mock_object(hds_hnas.HDSHNASDriver, "_get_hnas_share_id",
|
self.mock_object(hds_hnas.HDSHNASDriver, "_get_hnas_share_id",
|
||||||
mock.Mock(return_value=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, "tree_delete", mock.Mock())
|
||||||
self.mock_object(ssh.HNASSSHBackend, "delete_directory", 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.debug.called)
|
||||||
self.assertTrue(self.mock_log.info.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(
|
ssh.HNASSSHBackend.tree_delete.assert_called_once_with(
|
||||||
'/snapshots/' + share['id'] + '/' + snapshot['id'])
|
'/snapshots/' + share['id'] + '/' + snapshot['id'])
|
||||||
ssh.HNASSSHBackend.delete_directory.assert_called_once_with(
|
ssh.HNASSSHBackend.delete_directory.assert_called_once_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user