Is there a way to execute qtree deletion only if empty. I am using api to delete but want to prevent deletion if it is not empty.
https://docs.netapp.com/us-en/ontap-restapi-97/ontap/delete-storage-qtrees-.html
1 messages · Page 1 of 1 (latest)
Is there a way to execute qtree deletion only if empty. I am using api to delete but want to prevent deletion if it is not empty.
https://docs.netapp.com/us-en/ontap-restapi-97/ontap/delete-storage-qtrees-.html
you can just mount the volume where the qtree is in (via CIFS/NFS), check if there's anything in it, and rm -r it if it's empty
@lilac comet Thanks for your response! Yes, that’s one option. In my script, I’m trying to prevent deletion if a file or directory exists within a qtree. Sometimes, users create qtrees by mistake, so it’s fine to delete them if they’re empty. I was exploring whether there’s an API option to handle this scenario.
.
Let's step back and discuss qtrees.
Concerning the question: There is a API to list the contents of a directory that I have not personally tested against a qtree, but I imagine it would work.
You can do something like this:
Let see, we're discussing in the API channel of which most people here are using Python...
This is a lab environment available to customers:
https://labondemand.netapp.com/lab/ontap-PY-auto-hol
And the same for partners and employees:
https://labondemand.netapp.com/lab/ontappyauto
Directories in a volume are not qtrees.
no one claimed that 🙂 But you can delete qtrees just like any other (regular) directory, you don't need an API for that. I'm not even sure why they added the "qtree delete" API in the first place. Just delete them from the client 🤷♂️
I have developed a script utilizing the ONTAP API that enables managers to create qtrees with defined user and tree quota limits. To enhance its functionality, I plan to add a delete option, allowing users to remove and recreate qtrees in case of naming errors or other adjustments. However, I will ensure that the delete option is disabled if the qtree contains data to prevent accidental data loss. I will try qtree.path option thanks for the suggestion.
I will say “qtree.path” is not necessarily a specific or real thing. It was pseudo-code that is likely to exist.