Software Development Kit (SDK) and API Discussions

Python: List files on vserver

ROMEROJNR
6,549 Views

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

sys.path.append("C:\sdk\lib\python\NetApp")

from NaServer import *

s = NaServer("10.0.0.1", 1 , 20)

s.set_server_type("FILER")

s.set_transport_type("HTTPS")

s.set_port(443)

s.set_style("LOGIN")

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

  

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

api.child_add_string("encoded",True)

api.child_add_string("path","/vol/volume0")

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:

Error:

<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?

1 ACCEPTED SOLUTION

zulanch
6,549 Views

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.

-Ben

View solution in original post

3 REPLIES 3

ekashpureff
6,549 Views

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 http://www.linkedin.com/in/eugenekashpureff

Senior NetApp Instructor, IT Learning Solutions http://sg.itls.asia/netapp

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

ROMEROJNR
6,549 Views

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

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.

zulanch
6,550 Views

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.

-Ben

Public