Software Development Kit (SDK) and API Discussions

VOLUME-GET-ITER (SDK 5.7) DOESNT SHOWS ALL VOLUMES UNDER CLUSTER(9.1)

Joyn_netapp
4,291 Views

Hi Guys,

 

I am using Netapp SDK 5.7 and below is the python code. If I try to list all of the volumes under the cluster it shows only 50+ or sometimes 200+ volumes. I could confirm that the cluster(version 9.1) has 1000+ volumes.How could I list all the volumes?

 

 

 

s = NaServer("x.x.x.x", 1 , 31)
s.set_server_type("FILER")
s.set_transport_type("HTTPS")
s.set_port(443)
s.set_style("LOGIN")
s.set_admin_user("someuser", "somepassword")



result = s.invoke('volume-get-iter' , 'max-records', 1000)
print(result.sprintf())  



for volume in result.child_get('attributes-list').children_get():
       volumename = volume.child_get('volume-id-attributes').child_get_string('name') 
       print(volumename)


#Below are the last few output lines of sprintf() 

		</volume-attributes>
	</attributes-list>
	<next-tag>&lt;volume-get-iter-key-td&gt;
        &lt;key-0&gt;vserver1&lt;/key-0&gt;
        &lt;key-1&gt;vol101&lt;/key-1&gt;
&lt;/volume-get-iter-key-td&gt;
</next-tag>
	<num-records>250</num-records>  

</result>

 

Looks to me "next-tag" says there is a volume vol101 being followed up and this time it prints 250 volumes(this number changes everytime running the script). How can I print all of the volumes from the cluster? Why max-records parameter doesnt helps here?

 

I dont know how to make use of  "next-tag" and "tag"  in the code. Could someone please explain me with an example. Thanks in advance.

 

 

Regards,

 

Joy

1 ACCEPTED SOLUTION

francoisbnc
4,229 Views

you can do something ike this

 

from netappzap import NaServer
from netappzap import NaElement

s = NaServer("xxxxxx", 1, 31)
s.set_server_type("FILER")
s.set_transport_type("HTTP")
s.set_port(80)
s.set_style("LOGIN")
s.set_admin_user("xxxxx", "xxxxxx")

# first loop
tag = 'first'

while tag:
    api = NaElement("volume-get-iter")
    api.child_add_string("max-records", "5")
    if tag != 'first':
        api.child_add_string("tag", tag)

    output = s.invoke_elem(api)

    volumesattributes = output.child_get('attributes-list').children_get()
    for volume in volumesattributes:
        volumename = volume.child_get('volume-id-attributes').child_get_string('name')
        print(volumename)
    tag = output.child_get_string("next-tag")

View solution in original post

2 REPLIES 2

francoisbnc
4,230 Views

you can do something ike this

 

from netappzap import NaServer
from netappzap import NaElement

s = NaServer("xxxxxx", 1, 31)
s.set_server_type("FILER")
s.set_transport_type("HTTP")
s.set_port(80)
s.set_style("LOGIN")
s.set_admin_user("xxxxx", "xxxxxx")

# first loop
tag = 'first'

while tag:
    api = NaElement("volume-get-iter")
    api.child_add_string("max-records", "5")
    if tag != 'first':
        api.child_add_string("tag", tag)

    output = s.invoke_elem(api)

    volumesattributes = output.child_get('attributes-list').children_get()
    for volume in volumesattributes:
        volumename = volume.child_get('volume-id-attributes').child_get_string('name')
        print(volumename)
    tag = output.child_get_string("next-tag")

Joyn_netapp
4,216 Views

Thanks Francoisbnc! . This explains alot.

Public