Making xml query in Python script -
module_rm = "resource-mgr" def get_data_name(self, path): dataclass = "logicalrouterinterface" dataprop = "dn" msg = """<?xml version=\"1.0\" encoding=\"utf-8\"?> <configresolveclass cookie="""+ self.authenticate()+ """ inhierarchical="false" classid=""" + "\"" + dataclass + "\"" + """> <infilter> <eq class=""" + "\"" + dataclass + "\"" + """ property=""" + "\"" + dataprop + "\"" + """ value=""" + "\"" + path + "\"" + """ /> </infilter> </configresolveclass>""" xml_response = self.send_xml(msg, module_rm) root = et.fromstring( xml_response ) dataint = root.findall("./outconfigs/" + dataclass) print "number of matching datainterface ", len(dataint)
the variable path contains value "org-root/org-tcs/org-edgerouter-csr1" dataclass i.e "logicalrouterinterface", dataprop i.e. "dn" exact value "org-root/org-tcs/org-edgerouter-csr1/router-intf-data2" dont know exact value know part of value. query returns no matching interface needs exact value. pls modify search based on partial value.
i noticed input xml (msg
) missing quote cookie=
. might work after fixing it:
<configresolveclass cookie=\""""+ self.authenticate()+ """\" inhierarchical="false" classid=""" + "\"" + dataclass + "\"" + """>
Comments
Post a Comment