QNAP: driver should not manage snapshot which does not exist
The snapshot which does not exist in NAS shuold not be managed. Change-Id: I06475ccc507ee62f3da8f8795694f6da14064036 Closes-Bug: #1810374
This commit is contained in:
parent
d144bf7593
commit
cb7b8e292a
@ -75,9 +75,11 @@ class QnapShareDriver(driver.ShareDriver):
|
|||||||
of managed share should not be changed.
|
of managed share should not be changed.
|
||||||
1.0.6 - Add support for QES fw 2.1.0.
|
1.0.6 - Add support for QES fw 2.1.0.
|
||||||
1.0.7 - Add support for QES fw on TDS series NAS model.
|
1.0.7 - Add support for QES fw on TDS series NAS model.
|
||||||
|
1.0.8 - Fix bug, driver should not manage snapshot which does not
|
||||||
|
exist in NAS.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DRIVER_VERSION = '1.0.7'
|
DRIVER_VERSION = '1.0.8'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize QnapShareDriver."""
|
"""Initialize QnapShareDriver."""
|
||||||
@ -900,6 +902,7 @@ class QnapShareDriver(driver.ShareDriver):
|
|||||||
|
|
||||||
if len(snapshot_id_info) == 2:
|
if len(snapshot_id_info) == 2:
|
||||||
share_name = snapshot_id_info[0]
|
share_name = snapshot_id_info[0]
|
||||||
|
snapshot_name = snapshot_id_info[1]
|
||||||
else:
|
else:
|
||||||
msg = _("Incorrect provider_location format. It should have the "
|
msg = _("Incorrect provider_location format. It should have the "
|
||||||
"following format: share_name@snapshot_name.")
|
"following format: share_name@snapshot_name.")
|
||||||
@ -914,6 +917,15 @@ class QnapShareDriver(driver.ShareDriver):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.ShareNotFound(reason=msg)
|
raise exception.ShareNotFound(reason=msg)
|
||||||
|
|
||||||
|
check_snapshot = self.api_executor.get_snapshot_info(
|
||||||
|
volID=volID, snapshot_name=snapshot_name)
|
||||||
|
if check_snapshot is None:
|
||||||
|
msg = (_("The snapshot %(snapshot_name)s was not "
|
||||||
|
"found on backend.") %
|
||||||
|
{'snapshot_name': snapshot_name})
|
||||||
|
LOG.error(msg)
|
||||||
|
raise exception.InvalidParameterValue(err=msg)
|
||||||
|
|
||||||
_metadata = {
|
_metadata = {
|
||||||
'snapshot_id': snapshot_id,
|
'snapshot_id': snapshot_id,
|
||||||
}
|
}
|
||||||
|
@ -1147,6 +1147,35 @@ class QnapShareDriverTestCase(QnapShareDriverBaseTestCase):
|
|||||||
mock_private_storage.update.assert_called_once_with(
|
mock_private_storage.update.assert_called_once_with(
|
||||||
'fakeSnapshotId', fake_metadata)
|
'fakeSnapshotId', fake_metadata)
|
||||||
|
|
||||||
|
@mock.patch.object(qnap.QnapShareDriver, '_get_location_path')
|
||||||
|
def test_manage_existing_snapshot_not_exist(
|
||||||
|
self,
|
||||||
|
mock_get_location_path):
|
||||||
|
"""Test manage existing snapshot with snapshot which does not exist."""
|
||||||
|
fake_snapshot = fakes.SnapshotClass(
|
||||||
|
10, 'fakeShareName@fakeSnapshotName')
|
||||||
|
|
||||||
|
mock_api_executor = qnap.QnapShareDriver._create_api_executor
|
||||||
|
mock_api_executor.return_value.get_share_info.return_value = (
|
||||||
|
self.get_share_info_return_value())
|
||||||
|
mock_api_executor.return_value.get_snapshot_info.return_value = None
|
||||||
|
mock_private_storage = mock.Mock()
|
||||||
|
mock_private_storage.get.side_effect = [
|
||||||
|
'fakeVolId', 'fakeVolName']
|
||||||
|
|
||||||
|
self._do_setup('http://1.2.3.4:8080', '1.2.3.4', 'admin',
|
||||||
|
'qnapadmin', 'Storage Pool 1',
|
||||||
|
private_storage=mock_private_storage)
|
||||||
|
|
||||||
|
mock_api_return = mock_api_executor.return_value
|
||||||
|
self.assertRaises(
|
||||||
|
exception.InvalidParameterValue,
|
||||||
|
self.driver.manage_existing_snapshot,
|
||||||
|
snapshot=fake_snapshot,
|
||||||
|
driver_options='driver_options')
|
||||||
|
mock_api_return.get_share_info.assert_called_once_with(
|
||||||
|
'Storage Pool 1', vol_no='fakeVolId')
|
||||||
|
|
||||||
def test_unmanage_snapshot(self):
|
def test_unmanage_snapshot(self):
|
||||||
"""Test unmanage snapshot."""
|
"""Test unmanage snapshot."""
|
||||||
fake_snapshot = fakes.SnapshotClass(
|
fake_snapshot = fakes.SnapshotClass(
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixed the QNAP driver so that the snapshot which does not exist in NAS
|
||||||
|
will not be managed.
|
Loading…
Reference in New Issue
Block a user