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. Closes-Bug: #2059399 Change-Id: Icd7f1b52a10659ee1cfeef3accbbb725d4046a13
This commit is contained in:
parent
d8987589ae
commit
080d3ba669
@ -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()
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
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)
|
||||
source_snapshot=snap_name,
|
||||
des_cluster=source_cluster)
|
||||
|
||||
@na_utils.trace
|
||||
def restore_backup_continue(self, context, backup,
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
NetApp driver `bug #2059399
|
||||
<https://bugs.launchpad.net/manila/+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.
|
Loading…
Reference in New Issue
Block a user