2016-07-08 03:20 AM
I'm trying to write a python script to satisfy below requirement:
1. It should be able to find out a list of volumes containing non-qtree data, with an exception of filenames starting with a 'dot'. E.g. It won't list a volume that has only one file named '.bash_profile' as non-qtree data.
2. The script can be run on a number of filers.
I'm really stuck at listing non-qtree data with the exception above.
Any help will be highly appreciated. I'm using python, but any other language is fine as well.
2016-07-08 08:12 AM
Not sure to understand what you are trying to check.
Volumes are qtree as well, so files directly on / are potentially in qtrees.
For me, non-qtree data are more: "directories created as standard (mkdir in unix for example)" but relayed to directories not files.
Here an example what I would do:
from netapp.NaServer import *
s = NaServer("filer", 1, 21)
apivol = NaElement("volume-list-info")
outputvol = s.invoke_elem(apivol)
volumes = outputvol.child_get("volumes")
resultsvol = volumes.children_get()
## loop through volumes
for resultvol in resultsvol:
volname = resultvol.child_get_string("name")
apiqtree = NaElement("qtree-list")
outputqtree = s.invoke_elem(apiqtree)
qtrees = outputqtree.child_get("qtrees")
qtreestree = qtrees.children_get()
qtreesarray = 
# Loop througn qtrees
for resultqtree in qtreestree:
qtreename = resultqtree.child_get_string("qtree")
apidir = NaElement("file-list-directory-iter-start")
apidir.child_add_string("path", '/vol/' + volname)
outputdir = s.invoke_elem(apidir)
tagdir = outputdir.child_get_string("tag")
apidir = NaElement("file-list-directory-iter-next")
outputdir = s.invoke_elem(apidir)
dirs = outputdir.child_get("files")
dirstree = dirs.children_get()
for resultdir in dirstree:
filetype = resultdir.child_get_string("file-type")
filename = resultdir.child_get_string("name")
if filetype == 'directory':
if filename in qtreesarray:
print('qtree:' + filename)
print('nonqtree:' + filename)
2016-07-10 11:04 PM - edited 2016-07-13 10:46 PM
Thank you so much for your help and it almost meets the requirement. Just below 2 items needs to be sorted out:
1. The script should consider anything in the volume but not in a qtree, as non-qtree data:
2. The current script shows every qtree twice, once as 'non-qtree' and then again as 'qtree'. it shows like below:
Ideally it should show the qtree/directory only once - either as 'qtree' or 'non-qtree'.
3. At present I can get this by comparing the outputs of "qtree status <volume name>" and "priv set advanced; ls/vol/<volume name>". But I feel like that's a crude way and can be done better by leveraging the APIs.
I really appreciate your help and patience to put the script together.
2016-07-19 04:45 AM
Looks like I'm not getting the desired output because it considers both, 'qtree' and 'directory' as "directory". I ran below script on a volume containing a 'qtree', a 'directory' and a 'file', the output had "file-type=directory" for both 'qtree' and 'directory'.
api = NaElement("file-list-directory-iter-start")
xo = s.invoke_elem(api)
if (xo.results_status() == "failed") :
So is there any other way to differentiate a 'directory' from a 'qtree'?
2016-07-19 05:32 AM
Directories and qtree are same when you invoke "file-list-directory-iter", so use "qtree-list" to exclude qtree of this first list.
From there you can deduct directories only.