Software Development Kit (SDK) and API Discussions

SDK 5.1 Python

NIGOSHIKE
3,976 Views

Hi,

I am trying to use volume-get-iter (without max-records set) with Python SDK, a snippet of the code is as follows and is very similar to the vollist.pl that is given out with the PERL SDK:

tag = "NULL"

while tag:

   vol_get_iter = NaElement("volume-get-iter")

   if tag != "NULL":

      vol_get_iter.child_add_string("tag",tag)

   out = s.invoke_elem(vol_get_iter)

   tag = out.child_get_string("next-tag")

   vol_list = out.child_get("attributes-list").children_get()

The issue with the above is if I have more than 20 volumes in my c-mode cluster it only outputs 20, and the tag for the "next-tag" is not being set.

2 REPLIES 2

EFRASER
3,976 Views

I think I'm having the same problem with the tag not being set correctly with SDK 5.1.

It is possible to retrieve up to 100 records at a time by setting the max-records to 100 like:

vol_get_iter.child_add_string("max-records",100)

But that's hardly a proper fix.

I hope someone from Netapp can chime in on this...

Evan.

zulanch
3,976 Views

Hi Evan,

If your problem is with the Python SDK as well, there are a few gotchas you need to be aware of. First, you must XML escape the next-tag value before executing the next iteration. Second, if you're reusing the same NaElement API object to execute the next iteration, you must update the value of the tag NaElement using the NaElement.set_content() method on the third and subsequent iterations, as calling api.child_add_string("tag", next_tag) a second time will append a new copy of the tag child object under the API object rather than updating the value of the existing tag object.

See if the abbreviated code example below gets you going. If you're still running into problems, please post some more details and a short code example so we can help further.

api = NaElement("volume-get-iter")

output = server.invoke_elem(api)

print "OUTPUT:\n%s\n\n" % (output.sprintf())

next_tag = output.child_get_string("next-tag")

while next_tag is not None:

   next_tag = xml.sax.saxutils.escape(next_tag)

   if api.child_get("tag") is None:

      api.child_add_string("tag", next_tag)

   else:

      api.child_get("tag").set_content(next_tag)

   output = server.invoke_elem(api)

   print "OUTPUT:\n%s\n\n" % (output.sprintf())

   next_tag = output.child_get_string("next-tag")

Thanks,

Ben

Public