From Python netapp-ontap library which calls the REST API.
"/Move" moves files between flex volumes? I don't need to do that, I just need to move files within the same volume.
The docs say you can do this with the REST API like this to move /alice/bob/bb.txt to /alice/bob/charlie/bb.txt
curl -k --request PATCH \
--url https://server.domain/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob%2Fbb.txt \
--header 'Accept: application/json' \
--header 'Authorization: Basic ******************' \
--header 'User-Agent: httpyac' \
--data '{
"path" : "/alice/bob/charlie/bb.txt"
}'
This works.
And there is an example in the docs, and the comments within the netapp python library that tells you to do this from python like this:
from netapp_ontap import HostConnection
from netapp_ontap.resources import FileInfo
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = FileInfo(
"7da9eb81-6daa-4323-9eab-7bbce73da0f2", path="alice/bob/bb.txt"
)
resource.path = "alice/bob/charlie.txt"
resource.patch()
BUT this fails with
Caused by HTTPError('500 Server Error: Internal Server Error for url: https://server.domain:443/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob'): Failed to rename "/alice/bob" to
"/alice/bob/charlie". Reason: Invalid argument
The library correctly detects that path has changed and makes the body of the REST API request, but it fails to append the filename to the URL and thus is trying to rename the directory containing the file, rather than the file itself.
By the way, in the docs the import also should read
from netapp_ontap.host_connection import HostConnection
So I think this is a bug in the netapp-ontap Python Library