diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index 35a30b3755..1e1e9a1e7c 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -6258,7 +6258,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): def snapmirror_restore_vol(self, source_path=None, dest_path=None, source_vserver=None, dest_vserver=None, source_volume=None, dest_volume=None, - source_snapshot=None): + des_cluster=None, source_snapshot=None): """Restore snapshot copy from destination volume to source volume""" self._ensure_snapmirror_v2() diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py b/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py index 744b3fb1b0..6bc20740a0 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py @@ -5402,15 +5402,9 @@ class NetAppRestClient(object): def snapmirror_restore_vol(self, source_path=None, dest_path=None, source_vserver=None, dest_vserver=None, source_volume=None, dest_volume=None, - source_snapshot=None): + des_cluster=None, source_snapshot=None): """Restore snapshot copy from destination volume to source volume""" - snapmirror_info = self.get_snapmirror_destinations(dest_path, - source_path, - dest_vserver, - source_vserver, - dest_volume, - source_volume, - ) + snapmirror_info = self.get_snapmirrors(dest_path, source_path) if not snapmirror_info: msg = _("There is no relationship between source " "'%(source_path)s' and destination cluster" @@ -5420,7 +5414,8 @@ class NetAppRestClient(object): } raise exception.NetAppException(msg % msg_args) uuid = snapmirror_info[0].get('uuid') - body = {"destination": {"path": dest_path}, + body = {"destination": {"path": dest_path, + "cluster": {"name": des_cluster}}, "source_snapshot": source_snapshot} try: self.send_request(f"/snapmirror/relationships/{uuid}/restore", 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 0b0b928bd8..d0497dff17 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -4636,13 +4636,25 @@ class NetAppCmodeFileStorageLibrary(object): raise exception.NetAppException("Not able to find vserver " " and volume from SnpMirror" " relationship.") + backend_name = self._get_backend(backup) + des_vserver_client = self._get_api_client_for_backend( + backend_name, + vserver=des_vserver, + ) + vserver_client = src_vserver_client + backend_config = data_motion.get_backend_configuration( + backend_name) + if not backend_config.netapp_use_legacy_client: + vserver_client = des_vserver_client snap_name = self._get_backup_snapshot_name(backup, share_instance['id']) source_path = src_vserver + ":" + src_vol_name des_path = des_vserver + ":" + des_vol - src_vserver_client.snapmirror_restore_vol(source_path=des_path, - dest_path=source_path, - source_snapshot=snap_name) + source_cluster = src_vserver_client.get_cluster_name() + vserver_client.snapmirror_restore_vol(source_path=des_path, + dest_path=source_path, + source_snapshot=snap_name, + des_cluster=source_cluster) @na_utils.trace def restore_backup_continue(self, context, backup, diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py index 677ae022b8..552fee4b25 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py @@ -6901,7 +6901,8 @@ class NetAppRestCmodeClientTestCase(test.TestCase): def test_snapmirror_restore_vol(self): uuid = fake.VOLUME_ITEM_SIMPLE_RESPONSE_REST["uuid"] body = { - "destination": {"path": fake.SM_DEST_PATH}, + "destination": {"path": fake.SM_DEST_PATH, + "cluster": {"name": fake.CLUSTER_NAME}}, "source_snapshot": fake.SNAPSHOT_NAME } snapmirror_info = [{'destination-vserver': "fake_des_vserver", @@ -6909,12 +6910,13 @@ class NetAppRestCmodeClientTestCase(test.TestCase): 'relationship-status': "idle", 'uuid': uuid}] - self.mock_object(self.client, 'get_snapmirror_destinations', + self.mock_object(self.client, 'get_snapmirrors', mock.Mock(return_value=snapmirror_info)) self.mock_object(self.client, 'send_request') self.client.snapmirror_restore_vol(source_path=fake.SM_SOURCE_PATH, dest_path=fake.SM_DEST_PATH, - source_snapshot=fake.SNAPSHOT_NAME) + source_snapshot=fake.SNAPSHOT_NAME, + des_cluster=fake.CLUSTER_NAME) self.client.send_request.assert_called_once_with( f'/snapmirror/relationships/{uuid}/restore', 'post', body=body) 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 a29ced815f..17b471117c 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 @@ -7902,7 +7902,9 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): vserver_client.snapmirror_restore_vol.assert_called_once_with( source_path=mock.ANY, dest_path=mock.ANY, - source_snapshot=mock.ANY) + source_snapshot=mock.ANY, + des_cluster=mock.ANY, + ) def test_restore_backup_continue(self): vserver_client = mock.Mock() diff --git a/releasenotes/notes/bug-2059399-fix-backup-restore-failing-for-rest-bc060fcf893ae0f6.yaml b/releasenotes/notes/bug-2059399-fix-backup-restore-failing-for-rest-bc060fcf893ae0f6.yaml new file mode 100644 index 0000000000..38a3b0fb41 --- /dev/null +++ b/releasenotes/notes/bug-2059399-fix-backup-restore-failing-for-rest-bc060fcf893ae0f6.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + NetApp driver `bug #2059399 + `_: + Fix the backup restore issue for NetApp driver for REST client. + Backup restore is failing across the ONTAP cluster for REST client. + Added the logic to use to destination vserver client for REST client + to restore the backup and modify the restore lib for cmode REST + client accordingly.