Merge "Fix HNAS snapshot creation on deleted shares"

This commit is contained in:
Jenkins 2016-03-16 14:38:29 +00:00 committed by Gerrit Code Review
commit b4fac2b7e7
4 changed files with 7 additions and 1 deletions

View File

@ -575,6 +575,7 @@ class HDSHNASDriver(driver.ShareDriver):
:param share_id: ID of share for snapshot.
:param snapshot_id: ID of new snapshot.
"""
self._ensure_share(share_id)
saved_list = self.hnas.get_host_list(share_id)
new_list = []

View File

@ -419,6 +419,9 @@ class HNASSSHBackend(object):
if 'DirectoryNotEmpty' in e.stderr:
LOG.debug("Share %(path)s has more snapshots.",
{'path': path})
elif 'NotFound' in e.stderr:
LOG.warning(_LW("Attempted to delete path %s but it does "
"not exist."), path)
else:
msg = six.text_type(e)
LOG.exception(msg)

View File

@ -239,6 +239,7 @@ class HDSHNASTestCase(test.TestCase):
ssh.HNASSSHBackend.vvol_delete.assert_called_once_with(share['id'])
def test_create_snapshot(self):
self.mock_object(hds_hnas.HDSHNASDriver, "_ensure_share")
self.mock_object(hds_hnas.HDSHNASDriver, "_get_hnas_share_id",
mock.Mock(return_value=share['id']))
self.mock_object(ssh.HNASSSHBackend, "get_host_list", mock.Mock(
@ -258,6 +259,7 @@ class HDSHNASTestCase(test.TestCase):
snapshot['id'])
def test_create_snapshot_first_snapshot(self):
self.mock_object(hds_hnas.HDSHNASDriver, "_ensure_share")
self.mock_object(hds_hnas.HDSHNASDriver, "_get_hnas_share_id",
mock.Mock(return_value=share['id']))
self.mock_object(ssh.HNASSSHBackend, "get_host_list", mock.Mock(

View File

@ -944,7 +944,7 @@ class HNASSSHTestCase(test.TestCase):
self.assertTrue(self.mock_log.debug.called)
def test__locked_selectfs_delete_exception(self):
msg = 'rmdir: cannot remove \'/path\': NotFound'
msg = 'rmdir: cannot remove \'/path\''
self.mock_object(ssh.HNASSSHBackend, '_execute', mock.Mock(
side_effect=[putils.ProcessExecutionError(stderr=msg)]))