05-10-2017 10:43 PM
kindly let us know xml filter is correct or wrong for the corresponding cli
we are using ncclient to get xml output from cisco router
RP/0/RP0/CPU0:dedsdf1001jl1#show bgp ipv4 labeled-unicast neighbors 10.80.68.67 advertised-routes
Wed May 10 05:07:24.387 EDT
Network Next Hop From AS Path
10.0.6.0/32 10.60.63.61 10.61.0.229 ?
10.0.6.1/32 10.60.63.61 10.61.0.229 ?
def read(host, user, password):
try:
with manager.connect(host=host, username=user, password=password, look_for_keys=False,timeout=100) as m:
bgp_filter = '''
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">
<instances>
<instance>
<instance-name>default</instance-name>
<instance-active>
<default-vrf>
<afs>
<af>
<af-name>ipv4-labeled-unicast</af-name>
<advertised-path-xr>
<advertised-path>
<neighbor-address/>
<path-information>
<bgp-prefix>
<prefix>
<afi/>
<ipv4-address/>
</prefix>
</bgp-prefix>
<neighbor-address>
<afi/>
<ipv4-address/>
</neighbor-address>
<next-hop>
<afi/>
<ipv4-address/>
</next-hop>
</path-information>
</advertised-path>
</advertised-path-xr>
</af>
</afs>
</default-vrf>
</instance-active>
</instance>
</instances>
</bgp>
'''
cisco_bgp = m.get(('subtree', bgp_filter))
print (cisco_bgp)
We are not getting exact next-hop out put with the above xml-filter . kindly let us know the same
Thanks
Jay
Solved! Go to Solution.
05-24-2017 08:58 AM
Hi Jay,
The request looks correct to me, but there is a different table for advertised paths (which includes ad paths). Below is a sample request. Could you please try this:
<get>
<filter type="subtree">
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">
<instances>
<instance>
<instance-name>default</instance-name>
<instance-active>
<default-vrf>
<afs>
<af>
<af-name>ipv4-unicast</af-name>
<advertised-paths>
<advertised-path>
<paths>
<neighbor-address-xr/>
<path-information>
<bgp-prefix>
<prefix>
<afi/>
<ipv4-address/>
</prefix>
</bgp-prefix>
<neighbor-address>
<afi/>
<ipv4-address/>
</neighbor-address>
<next-hop>
<afi/>
<ipv4-address/>
</next-hop>
</path-information>
</paths>
</advertised-path>
</advertised-paths>
</af>
</afs>
</default-vrf>
</instance-active>
</instance>
</instances>
</bgp>
</filter>
</get>
---------- OUTPUT ----
----------- Received from NETCONF agent --------------
#1340
<?xml version="1.0"?>
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<data>
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">
<instances>
<instance>
<instance-name>default</instance-name>
<instance-active>
<default-vrf>
<afs>
<af>
<af-name>ipv4-unicast</af-name>
<advertised-paths>
<advertised-path>
<rd>0000000000000000</rd>
<network>0d000100</network>
<prefix-length>24</prefix-length>
<neighbor-address>10.10.10.1</neighbor-address>
<paths>
<neighbor-address-xr>
<afi>ipv4</afi>
<ipv4-address>10.10.10.1</ipv4-address>
</neighbor-address-xr>
<path-information>
<bgp-prefix>
<prefix>
<afi>ipv4</afi>
<ipv4-address>13.0.1.0</ipv4-address>
</prefix>
</bgp-prefix>
<neighbor-address>
<afi>ipv4</afi>
<ipv4-address>0.0.0.0</ipv4-address>
</neighbor-address>
<next-hop>
<afi>ipv4</afi>
<ipv4-address>10.10.10.2</ipv4-address>
</next-hop>
</path-information>
</paths>
</advertised-path>
#165
</advertised-paths>
</af>
</afs>
</default-vrf>
</instance-active>
</instance>
</instances>
</bgp>
</data>
</rpc-reply>
##
05-24-2017 08:58 AM
Hi Jay,
The request looks correct to me, but there is a different table for advertised paths (which includes ad paths). Below is a sample request. Could you please try this:
<get>
<filter type="subtree">
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">
<instances>
<instance>
<instance-name>default</instance-name>
<instance-active>
<default-vrf>
<afs>
<af>
<af-name>ipv4-unicast</af-name>
<advertised-paths>
<advertised-path>
<paths>
<neighbor-address-xr/>
<path-information>
<bgp-prefix>
<prefix>
<afi/>
<ipv4-address/>
</prefix>
</bgp-prefix>
<neighbor-address>
<afi/>
<ipv4-address/>
</neighbor-address>
<next-hop>
<afi/>
<ipv4-address/>
</next-hop>
</path-information>
</paths>
</advertised-path>
</advertised-paths>
</af>
</afs>
</default-vrf>
</instance-active>
</instance>
</instances>
</bgp>
</filter>
</get>
---------- OUTPUT ----
----------- Received from NETCONF agent --------------
#1340
<?xml version="1.0"?>
<rpc-reply message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<data>
<bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper">
<instances>
<instance>
<instance-name>default</instance-name>
<instance-active>
<default-vrf>
<afs>
<af>
<af-name>ipv4-unicast</af-name>
<advertised-paths>
<advertised-path>
<rd>0000000000000000</rd>
<network>0d000100</network>
<prefix-length>24</prefix-length>
<neighbor-address>10.10.10.1</neighbor-address>
<paths>
<neighbor-address-xr>
<afi>ipv4</afi>
<ipv4-address>10.10.10.1</ipv4-address>
</neighbor-address-xr>
<path-information>
<bgp-prefix>
<prefix>
<afi>ipv4</afi>
<ipv4-address>13.0.1.0</ipv4-address>
</prefix>
</bgp-prefix>
<neighbor-address>
<afi>ipv4</afi>
<ipv4-address>0.0.0.0</ipv4-address>
</neighbor-address>
<next-hop>
<afi>ipv4</afi>
<ipv4-address>10.10.10.2</ipv4-address>
</next-hop>
</path-information>
</paths>
</advertised-path>
#165
</advertised-paths>
</af>
</afs>
</default-vrf>
</instance-active>
</instance>
</instances>
</bgp>
</data>
</rpc-reply>
##
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide