I have this IOS-XR configuration:
router bgp 7
bgp router-id 10.0.0.7
address-family ipv4 unicast
!
neighbor 10.0.0.70
remote-as 7
update-source Loopback0
route-policy MANGLE_IN in
route-policy MANGLE_OUT out
next-hop-self
!
neighbor 192.168.1.254
remote-as 9
route-policy EBGP_IN in
route-policy EBGP_OUT out
I need to see if a neighbor is configured with next-hop-self
.
I can use this to get the route-policy or remote-as, but how do I check whether the neighbor is configured with next-hop-self?
I’m using this python code:
from ciscoconfparse import CiscoConfParse
config = CiscoConfParse('config.txt')
result = config.find_parents_w_child('neighbor 10.0.0.70', 'next-hop-self')
print(result)
This prints an empty list: []
, but I expected to see [' next-hop-self']
This will do what you want, but you need ciscoconfparse2 and find_child_objects()
:
from ciscoconfparse2 import CiscoConfParse
config = CiscoConfParse('config.txt')
result = config.find_child_objects(['router bgp',
'neighbor 10.0.0.70',
'route-policy',
'next-hop-self'])[0]
print(str(result))
BTW, next-hop-self
is not a direct child of neighbor 10.0.0.70
, but that was not the most basic problem you have.