summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-09-05 19:45:33 +0000
committerGerrit Code Review <review@openstack.org>2017-09-05 19:45:33 +0000
commit7bcd528e71551e2fb19c55404134905caf166ac9 (patch)
tree4db5946d8cb1460f1f4b6e6cfc781949bd6ee2d7
parentb30851f3af8ea72786de5b4678030a97181eb698 (diff)
parent038eb7be4fa75fd7b8c2ad2a69f831e7186dbb9f (diff)
Merge "NetApp ONTAP: Fix revert-to-snapshot" into stable/pike5.0.1
-rw-r--r--manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py9
-rw-r--r--manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py26
-rw-r--r--releasenotes/notes/bug-1694768-fix-netapp-cdot-revert-to-snapshot-5e1be65260454988.yaml4
3 files changed, 30 insertions, 9 deletions
diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py
index e07c234..47baa3a 100644
--- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py
+++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py
@@ -879,7 +879,8 @@ class NetAppCmodeFileStorageLibrary(object):
879 """Reverts a share (in place) to the specified snapshot.""" 879 """Reverts a share (in place) to the specified snapshot."""
880 vserver, vserver_client = self._get_vserver(share_server=share_server) 880 vserver, vserver_client = self._get_vserver(share_server=share_server)
881 share_name = self._get_backend_share_name(snapshot['share_id']) 881 share_name = self._get_backend_share_name(snapshot['share_id'])
882 snapshot_name = self._get_backend_snapshot_name(snapshot['id']) 882 snapshot_name = (snapshot.get('provider_location') or
883 self._get_backend_snapshot_name(snapshot['id']))
883 LOG.debug('Restoring snapshot %s', snapshot_name) 884 LOG.debug('Restoring snapshot %s', snapshot_name)
884 vserver_client.restore_snapshot(share_name, snapshot_name) 885 vserver_client.restore_snapshot(share_name, snapshot_name)
885 886
@@ -1824,8 +1825,10 @@ class NetAppCmodeFileStorageLibrary(object):
1824 vserver, vserver_client = self._get_vserver(share_server=share_server) 1825 vserver, vserver_client = self._get_vserver(share_server=share_server)
1825 share_name = self._get_backend_share_name( 1826 share_name = self._get_backend_share_name(
1826 active_replica_snapshot['share_id']) 1827 active_replica_snapshot['share_id'])
1827 snapshot_name = self._get_backend_snapshot_name( 1828 snapshot_name = (
1828 active_replica_snapshot['id']) 1829 active_replica_snapshot.get('provider_location') or
1830 self._get_backend_snapshot_name(active_replica_snapshot['id']))
1831
1829 LOG.debug('Restoring snapshot %s', snapshot_name) 1832 LOG.debug('Restoring snapshot %s', snapshot_name)
1830 1833
1831 dm_session = data_motion.DataMotionSession() 1834 dm_session = data_motion.DataMotionSession()
diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py
index d56e870..d705dbe 100644
--- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py
+++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py
@@ -1309,22 +1309,29 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
1309 snapshot_name) 1309 snapshot_name)
1310 self.assertEqual(snapshot_name, model_update['provider_location']) 1310 self.assertEqual(snapshot_name, model_update['provider_location'])
1311 1311
1312 def test_revert_to_snapshot(self): 1312 @ddt.data(True, False)
1313 def test_revert_to_snapshot(self, use_snap_provider_location):
1313 1314
1314 vserver_client = mock.Mock() 1315 vserver_client = mock.Mock()
1315 self.mock_object(self.library, 1316 self.mock_object(self.library,
1316 '_get_vserver', 1317 '_get_vserver',
1317 mock.Mock(return_value=(fake.VSERVER1, 1318 mock.Mock(return_value=(fake.VSERVER1,
1318 vserver_client))) 1319 vserver_client)))
1320 fake_snapshot = copy.deepcopy(fake.SNAPSHOT)
1321 if use_snap_provider_location:
1322 fake_snapshot['provider_location'] = 'fake-provider-location'
1323 else:
1324 del fake_snapshot['provider_location']
1319 1325
1320 result = self.library.revert_to_snapshot( 1326 result = self.library.revert_to_snapshot(
1321 self.context, fake.SNAPSHOT, share_server=fake.SHARE_SERVER) 1327 self.context, fake_snapshot, share_server=fake.SHARE_SERVER)
1322 1328
1323 self.assertIsNone(result) 1329 self.assertIsNone(result)
1324 share_name = self.library._get_backend_share_name( 1330 share_name = self.library._get_backend_share_name(
1325 fake.SNAPSHOT['share_id']) 1331 fake_snapshot['share_id'])
1326 snapshot_name = self.library._get_backend_snapshot_name( 1332 snapshot_name = (self.library._get_backend_snapshot_name(
1327 fake.SNAPSHOT['id']) 1333 fake_snapshot['id']) if not use_snap_provider_location
1334 else 'fake-provider-location')
1328 vserver_client.restore_snapshot.assert_called_once_with(share_name, 1335 vserver_client.restore_snapshot.assert_called_once_with(share_name,
1329 snapshot_name) 1336 snapshot_name)
1330 1337
@@ -3919,11 +3926,18 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
3919 snapshot_list = [fake_snapshot, fake_snapshot_2, fake_snapshot_3] 3926 snapshot_list = [fake_snapshot, fake_snapshot_2, fake_snapshot_3]
3920 return replica_list, snapshot_list 3927 return replica_list, snapshot_list
3921 3928
3922 def test_revert_to_replicated_snapshot(self): 3929 @ddt.data(True, False)
3930 def test_revert_to_replicated_snapshot(self, use_snap_provider_location):
3923 3931
3924 replica_list, snapshot_list = self._get_fake_replicas_and_snapshots() 3932 replica_list, snapshot_list = self._get_fake_replicas_and_snapshots()
3925 fake_replica, fake_replica_2, fake_replica_3 = replica_list 3933 fake_replica, fake_replica_2, fake_replica_3 = replica_list
3926 fake_snapshot, fake_snapshot_2, fake_snapshot_3 = snapshot_list 3934 fake_snapshot, fake_snapshot_2, fake_snapshot_3 = snapshot_list
3935
3936 if not use_snap_provider_location:
3937 del fake_snapshot['provider_location']
3938 del fake_snapshot_2['provider_location']
3939 del fake_snapshot_3['provider_location']
3940
3927 share_name = self.library._get_backend_share_name( 3941 share_name = self.library._get_backend_share_name(
3928 fake_snapshot['share_id']) 3942 fake_snapshot['share_id'])
3929 snapshot_name = self.library._get_backend_snapshot_name( 3943 snapshot_name = self.library._get_backend_snapshot_name(
diff --git a/releasenotes/notes/bug-1694768-fix-netapp-cdot-revert-to-snapshot-5e1be65260454988.yaml b/releasenotes/notes/bug-1694768-fix-netapp-cdot-revert-to-snapshot-5e1be65260454988.yaml
new file mode 100644
index 0000000..08b9750
--- /dev/null
+++ b/releasenotes/notes/bug-1694768-fix-netapp-cdot-revert-to-snapshot-5e1be65260454988.yaml
@@ -0,0 +1,4 @@
1---
2fixes:
3 - Fixed the NetApp ONTAP driver to handle reverting to replicated
4 and migrated snapshots.