Hi Junos Experts,
I'm testing a script to extract ISIS database from Junos as follows
dev.open()
dev.timeout = 60
result = dev.rpc.get_isis_database_information (normalize=True, detail=True)
for entry in result.xpath("isis-database[level='2']/isis- database-entry"):
lspid = entry.findtext("lsp-id")
node=lspid[:-3]
if not node.endswith(".00"):
node="_"+node;
if not node in graph['nodes']:
graph['nodes'].append(node)
for neighbor in entry.xpath("isis-neighbor"):
neighborid = neighbor.findtext("is-neighbor-id")
metric = neighbor.findtext("metric")
topology = neighbor.findtext("isis-topology-id")
if topology=="" or topology=="IPV4 Unicast":
if not neighborid.endswith(".00"):
neighborid="_"+neighborid;
if not neighborid in graph['nodes']:
graph['nodes'].append(neighborid)
graph['links'].append([node, neighborid, metric])
dev.close()
When I run the script it return me error as below
Traceback (most recent call last):
File "pyezjunipertest.py", line 39, in <module>
for entry in result.xpath("isis-database[level='2']/isis- database-entry"):
File "lxml.etree.pyx", line 1509, in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:50717)
File "xpath.pxi", line 318, in lxml.etree.XPathElementEvaluator.__call__ (src/lxml/lxml.etree.c:145969)
File "xpath.pxi", line 238, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:144977)
File "xpath.pxi", line 224, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:144832)
lxml.etree.XPathEvalError: Invalid expression
and this is the snippet of xml ouput from router terminal console
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1R7/junos">
<isis-database-information xmlns="http://xml.juniper.net/junos/15.1R7/junos-routing" junos:style="brief">
<isis-database>
<level>1</level>
<lsp-count>0</lsp-count>
</isis-database>
<isis-database>
<level>2</level>
<isis-database-entry>
<lsp-id>core1-re0.00-00</lsp-id>
<sequence-number>0x35022</sequence-number>
<checksum>0x925c</checksum>
<remaining-lifetime>736</remaining-lifetime>
<lsp-attributes>L1 L2</lsp-attributes>
</isis-database-entry>
<isis-database-entry>
<lsp-id>core2-re0.00-00</lsp-id>
<sequence-number>0x347e2</sequence-number>
<checksum>0x322e</checksum>
<remaining-lifetime>1175</remaining-lifetime>
<lsp-attributes>L1 L2</lsp-attributes>
</isis-database-entry>
May I know would could be the issue here? I really appreciate some one could assist me further
Thank you.