Accepted Solution

Python: List files on vserver

Hi community,

I was trying to use the Python API to query a list of files on a specific volume on a specific vserver, so far i have been successfully able to do that using the powershell command:

Read-NcDirectory /vol/volume0 -VserverContext nfs_test | where {$_.Type -match "directory" -and $_.Name -notmatch "\."} | Read-NcDirectory

However, when I try to accomplish a similar task using the python API:

import sys


from NaServer import *

s = NaServer("", 1 , 20)





s.set_admin_user("admin", "password")


api = NaElement("file-list-directory-iter")



xo = s.invoke_elem(api)

if (xo.results_status() == "failed") :

    print ("Error:\n")

    print (xo.sprintf())

    sys.exit (1)

print "Received:\n"

print xo.sprintf()

I get the following output:


<results status="failed" errno="13005" reason="Unable to find API: file-list-directory-iter-start"></results>

Has anyone been able to accomplish this? My main task is to verify all .vmdk and .qcow files inside a specific volume and check its QoS policy, if there's none I must be able to add one.

Any tips? Any hints? Anything?

Re: Python: List files on vserver

The iter-start APIs calls aren't there any more, just file-list-directory-iter.

See the element next-tag.

I use the  ZExplore utility to find clues on these issues.

I hope this response has been helpful to you.

At your service,

Eugene E. Kashpureff, Sr.

Independent NetApp Consultant, K&H Research

Senior NetApp Instructor, IT Learning Solutions

(P.S. I appreciate points for helpful or correct answers.)

Re: Python: List files on vserver

I also tried the file-list-directory-iter, but I get the same error:


<results status="failed" errno="13005" reason="Unable to find API: file-list-directory-iter"></results>

I must also add that I'm with a clustered mode infrastructure.

Re: Python: List files on vserver

The API is indeed called file-list-directory-iter. Note that it is a Vserver-specific API, so you need to either:

  1. Set the desired Vserver using s.set_vserver(vserver_name), OR
  2. Connect to the Vserver management IP rather than the cluster management IP.