NetApp ONTAP: Add revert to snapshot functions on REST client
This patch adds the function rename_file and its unit test, other functions used in the 'revert to snapshot' operation were migrated in a previous patch. Change-Id: I36076414de9d1d31429ffd63817631fedd5df7cc partially-implements: blueprint netapp-ontap-rest-api-client
This commit is contained in:
parent
1c3972752f
commit
b0b35a874f
@ -3688,3 +3688,22 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
|
||||
f'/cluster/jobs/{job_uuid}', 'get', query=query,
|
||||
enable_tunneling=False)
|
||||
self.assertEqual(expected_result, result)
|
||||
|
||||
def test_rename_file(self):
|
||||
volume = fake_client.VOLUME_ITEM_SIMPLE_RESPONSE_REST
|
||||
orig_file_name = f'/vol/{fake_client.VOLUME_NAMES[0]}/cinder-vol'
|
||||
new_file_name = f'/vol/{fake_client.VOLUME_NAMES[0]}/new-cinder-vol'
|
||||
body = {'path': new_file_name.split('/')[3]}
|
||||
|
||||
self.mock_object(self.client, 'send_request')
|
||||
self.mock_object(self.client, '_get_volume_by_args',
|
||||
return_value=volume)
|
||||
|
||||
self.client.rename_file(orig_file_name, new_file_name)
|
||||
|
||||
orig_file_name = orig_file_name.split('/')[3]
|
||||
self.client.send_request.assert_called_once_with(
|
||||
f'/storage/volumes/{volume["uuid"]}/files/{orig_file_name}',
|
||||
'patch', body=body)
|
||||
self.client._get_volume_by_args.assert_called_once_with(
|
||||
vol_name=fake_client.VOLUME_NAMES[0])
|
||||
|
@ -2497,3 +2497,25 @@ class RestClient(object):
|
||||
}
|
||||
|
||||
return copy_status
|
||||
|
||||
def rename_file(self, orig_file_name, new_file_name):
|
||||
"""Rename a volume file."""
|
||||
LOG.debug("Renaming the file %(original)s to %(new)s.",
|
||||
{'original': orig_file_name, 'new': new_file_name})
|
||||
|
||||
unique_volume = self._get_volume_by_args(
|
||||
vol_name=orig_file_name.split('/')[2])
|
||||
|
||||
# Get the relative path
|
||||
orig_file_name = '/'.join(orig_file_name.split('/')[3:])
|
||||
new_file_name = '/'.join(new_file_name.split('/')[3:])
|
||||
|
||||
# Path requires "%2E" to represent "." and "%2F" to represent "/".
|
||||
orig_file_name = orig_file_name.replace('.', '%2E').replace('/', '%2F')
|
||||
new_file_name = new_file_name.replace('.', '%2E').replace('/', '%2F')
|
||||
|
||||
body = {'path': new_file_name}
|
||||
|
||||
self.send_request(
|
||||
f'/storage/volumes/{unique_volume["uuid"]}/files/{orig_file_name}',
|
||||
'patch', body=body)
|
||||
|
@ -3,8 +3,17 @@ features:
|
||||
- |
|
||||
NetApp drivers: NFS, iSCSI and FCP drivers have now the option to request
|
||||
ONTAP operations through REST API. The new option `netapp_use_legacy_client`
|
||||
switch between the old ZAPI client approach and new REST client. It is
|
||||
switches between the old ZAPI client approach and new REST client. It is
|
||||
default to `True`, meaning that the drivers will keep working as before
|
||||
using ZAPI operations. If desired, this option can be set to `False` connecting
|
||||
with new REST client that performs REST API operations if it is available,
|
||||
otherwise falls back to ZAPI.
|
||||
using ZAPI operations. If desired, this option can be set to `False` interacting
|
||||
with the storage using the new REST client. However, this new client still
|
||||
relies on ZAPI calls for consistency group snapshot operation.
|
||||
|
||||
The drivers can only be configured with REST client when using ONTAP storage
|
||||
9.11.1 or newer.
|
||||
|
||||
NOTE: Enabling ONTAP REST client changes the behavior of QoS specs. Earlier,
|
||||
QoS values could be represented in BPS (bytes per second), but now REST client
|
||||
only supports integer values represented in MBPS (Megabytes per second).
|
||||
It means that though the user specifies the value in BPS, it will be converted
|
||||
to MBPS and rounded up.
|
||||
|
Loading…
Reference in New Issue
Block a user