#qtree.delete() if empty

1 messages · Page 1 of 1 (latest)

tame nimbus
lilac comet
#

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

tame nimbus
#

@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.

unborn musk
#

.

#

Let's step back and discuss qtrees.

  • Directories in a volume are not qtrees. Qtrees are an ONTAP concept that presents like a directory via a NAS protocol.
  • Users of storage don't "create qtrees by mistake" as users generally do not have access to ONTAP to create a qtree.
  • qtrees allow a storage admin to act against it via ONTAP in a few ways that include but are not limited to: replicating only the qtree and not the whole volume, qtree-level quota management.

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:

  • Get qtrees
  • For each qtree:
    • list contents of the qtree.path (or whatever)
    • If contents of qtree.path is None/null/whatever
      • Delete qtree API

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

lilac comet
#

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 🤷‍♂️

tame nimbus
# unborn musk Let's step back and discuss qtrees. - Directories in a volume are not qtrees. Qt...

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.

unborn musk
#

I will say “qtree.path” is not necessarily a specific or real thing. It was pseudo-code that is likely to exist.

tame nimbus
#

@unborn musk thanks for clarifying it.

#

@lilac comet the mount option require the root access 😦