Software Development Kit (SDK) and API Discussions

NMSDK error: Zapi::parse_xml - Expected <netapp> element but got reason" errno="13001

neha_T
5,512 Views

i am using NetApp python NMSDK 9.4

 

when i try to get information of lun , some time it is passing and most of the time i am getting below error

 

Zapi::parse_xml - Expected <netapp> element but got reason" errno="13001

<results status="failed" reason="Zapi::parse_xml - Expected <netapp> element but got volume-errors" errno="13001"></results>

 

how can i resolve this

-Neha

1 ACCEPTED SOLUTION

francoisbnc
5,400 Views

Naserver Class is perhaps not thread safe. Try to create Naserver for each call.

View solution in original post

9 REPLIES 9

gaurav_verma
5,497 Views

Check if you are using the correct version of API with correct ONTAP version. 

You specify API version here. 

s = NaServer("XXXXXXXXX", 1 , 130)  this is for API version 1.130. 

 

To check API version for that ONTAP use 

api = NaElement("system-get-ontapi-version")

 

 

neha_T
5,190 Views

@gaurav_verma

is there any way through NMSDK script through which i can get the API-version

i am using below script but to get the output API version is required.

import sys
sys.path.append("<path_to_nmsdk_root>/lib/python/NetApp")
from NaServer import *


s = NaServer("--ip--", 1 , 130) --> apiversion is specified
s.set_server_type("FILER")
s.set_transport_type("HTTPS")
s.set_port(443)
s.set_style("LOGIN")
s.set_admin_user("vsadmin", "<password>")
api = NaElement("system-get-ontapi-version")

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())

 

How can i get apiversion? 

gaurav_verma
5,168 Views

@neha_T

You can use any API version but still this API "system-get-ontapi-version" will give you correct API version. 

 

api = NaElement("system-get-ontapi-version")

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())

francoisbnc
5,483 Views

May I have details of your code?

Best

neha_T
5,455 Views

@francoisbnc @gaurav_verma

i have written a function which get the lun info for specified "serial-number".

it is working fine, but when i tried to fetch multiple lun-info in multi-threaded environment. some threads are successful to fetch info. while some fail with the error i mention:

@gaurav_verma i have specified the on-tap version also:  server = NaServer(ip, 1 , 32)

<snip>

def get_lun_by_serial_no(self, serial_no😞
try:
api = NaElement("lun-get-iter")
xi = NaElement("desired-attributes")
api.child_add(xi)
xi1 = NaElement("lun-info")
xi.child_add(xi1)
xi1.child_add_string("path","<path>")
xi1.child_add_string("serial-number","<serial-number>")
xi1.child_add_string("volume","<volume>")
xi1.child_add_string("size","<size>")
xi1.child_add_string("vserver","<vserver>")
xi1.child_add_string("uuid","<uuid>")
xi2 = NaElement("query")
api.child_add(xi2)
xi3 = NaElement("lun-info")
xi2.child_add(xi3)
 
xi3.child_add_string("serial-number",serial_no)
xo = self.serverobj.invoke_elem(api)
 
xmldata = xo.sprintf()
data = self.get_xml_to_dict_data(xmldata)
if (xo.results_status() == "failed") :
 
message = self.client_conn.format_exception(data)
raise Exception(message)
if data.get('num-records') != '0':
return data["attributes-list"]["lun-info"]
return []
except Exception as e:
message = "lib Fail to get luns: " + e
raise Exception(message)
 

<snip>

 

Error:

results status="failed" reason="Zapi::parse_xml - Expected <netapp> element but got volume-error" errno="13001">

 

francoisbnc
5,414 Views

Did you tried to limit the number of threads you launch and start with a small number.

The Netapp api queue is limited, perhaps you reach this limit.

Try as well to create self.serverobj in the function as a local object Naserver,  In your case you use the same Naserver for each thread.

neha_T
5,412 Views

@francoisbnc

yes i m using semaphore of count 10

for NaServer object i am using below senario:

class NetAppClientConnect():
def __init__(self, ip, username, password😞
self.ip = ip
self.user = username
self.password = password
 
def getNaServerobj(self😞
try:
server = NaServer(self.ip, 1 , 32)
server.set_server_type("FILER")
server.set_transport_type("HTTPS")
server.set_port(443)
server.set_style("LOGIN")
server.set_admin_user(self.user, self.password)
return server
except Exception as e:
logger.error("Fail to get NaServer object")
raise Exception(str(e))
 
all functions calls be like.
class NetAppRestApiLib():
def __init__(self, ip, username, password😞
self.ip = ip
self.user = username
self.password = password
self.client_conn = NetAppClientConnect(
self.ip, self.user, self.password)
self.serverobj = self.client_conn.getNaServerobj()
 
def get_lun(self😞
try:
api = NaElement("lun-get-iter")
xi = NaElement("desired-attributes")
api.child_add(xi)
xi1 = NaElement("lun-info")
----
-
xo = self.serverobj.invoke_elem(api) ---- > for all i m using this self.serverobj
 
should i try something else????

francoisbnc
5,401 Views

Naserver Class is perhaps not thread safe. Try to create Naserver for each call.

neha_T
5,374 Views

yes it worked when i try to create NaServer object for each api call

Public