Software Development Kit (SDK) and API Discussions
Software Development Kit (SDK) and API Discussions
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><volume-get-iter-key-td> <key-0>vserver1</key-0> <key-1>vol101</key-1> </volume-get-iter-key-td> </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
Solved! See The Solution
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")
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")
Thanks Francoisbnc! . This explains alot.