Browse Source

Merge "NetApp ONTAP: Fix revert-to-snapshot" into stable/pike

Jenkins 1 year ago
parent
commit
7bcd528e71

+ 6
- 3
manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py View File

@@ -879,7 +879,8 @@ class NetAppCmodeFileStorageLibrary(object):
879 879
         """Reverts a share (in place) to the specified snapshot."""
880 880
         vserver, vserver_client = self._get_vserver(share_server=share_server)
881 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 884
         LOG.debug('Restoring snapshot %s', snapshot_name)
884 885
         vserver_client.restore_snapshot(share_name, snapshot_name)
885 886
 
@@ -1824,8 +1825,10 @@ class NetAppCmodeFileStorageLibrary(object):
1824 1825
         vserver, vserver_client = self._get_vserver(share_server=share_server)
1825 1826
         share_name = self._get_backend_share_name(
1826 1827
             active_replica_snapshot['share_id'])
1827
-        snapshot_name = self._get_backend_snapshot_name(
1828
-            active_replica_snapshot['id'])
1828
+        snapshot_name = (
1829
+            active_replica_snapshot.get('provider_location') or
1830
+            self._get_backend_snapshot_name(active_replica_snapshot['id']))
1831
+
1829 1832
         LOG.debug('Restoring snapshot %s', snapshot_name)
1830 1833
 
1831 1834
         dm_session = data_motion.DataMotionSession()

+ 20
- 6
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py View File

@@ -1309,22 +1309,29 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
1309 1309
                                                                snapshot_name)
1310 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 1315
         vserver_client = mock.Mock()
1315 1316
         self.mock_object(self.library,
1316 1317
                          '_get_vserver',
1317 1318
                          mock.Mock(return_value=(fake.VSERVER1,
1318 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 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 1329
         self.assertIsNone(result)
1324 1330
         share_name = self.library._get_backend_share_name(
1325
-            fake.SNAPSHOT['share_id'])
1326
-        snapshot_name = self.library._get_backend_snapshot_name(
1327
-            fake.SNAPSHOT['id'])
1331
+            fake_snapshot['share_id'])
1332
+        snapshot_name = (self.library._get_backend_snapshot_name(
1333
+            fake_snapshot['id']) if not use_snap_provider_location
1334
+            else 'fake-provider-location')
1328 1335
         vserver_client.restore_snapshot.assert_called_once_with(share_name,
1329 1336
                                                                 snapshot_name)
1330 1337
 
@@ -3919,11 +3926,18 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
3919 3926
         snapshot_list = [fake_snapshot, fake_snapshot_2, fake_snapshot_3]
3920 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 3932
         replica_list, snapshot_list = self._get_fake_replicas_and_snapshots()
3925 3933
         fake_replica, fake_replica_2, fake_replica_3 = replica_list
3926 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 3941
         share_name = self.library._get_backend_share_name(
3928 3942
             fake_snapshot['share_id'])
3929 3943
         snapshot_name = self.library._get_backend_snapshot_name(

+ 4
- 0
releasenotes/notes/bug-1694768-fix-netapp-cdot-revert-to-snapshot-5e1be65260454988.yaml View File

@@ -0,0 +1,4 @@
1
+---
2
+fixes:
3
+  - Fixed the NetApp ONTAP driver to handle reverting to replicated
4
+    and migrated snapshots.

Loading…
Cancel
Save