cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2366
Views
0
Helpful
4
Replies

Netconf XPATH - multicast (PIM, IGMP)

TMPI825834
Level 1
Level 1

Hi there,

 

Trying to get some config and oper data via Netconf using XPATH based filters for multicast elements - IGMP, PIM, mroute tables etc.

I can't figure out the xpath into multicast ... trying getting the tree using pyang against the cisco provided .yang files ... gets me nowhere. (ex. Cisco-IOS-XE-multicast.yang, Cisco-IOS-XE-igmp.yang)

 

Anyone using XPATH based filters for netconf get ... ?

Thank you,

 

Mihai

4 Replies 4

yawming
Cisco Employee
Cisco Employee

Not really … it has the xpath example for hostname, I know how to script the get operations for netconf etc.
What I can’t figure out is how to build the XPATH filters for multicast …
Thx.

Ps: here is a snippet of my script

netconf_reply=m.get(filter=('xpath','/ip/multicast'))
print ("#" * 80)

#netconf_reply=m.get(filter=('xpath',netconf_filter))

#netconf_reply = m.get(filter=('xpath','/interfaces-state/interface[name='GigabitEthernet1']/oper-status'))
# /if:interfaces-state/if:interface/if:oper-status
# /bgp-state-data/neighbors/neighbor/session-state
# /bgp-state-data/neighbors/neighbor[neighbor-id="10.10.33.2"]/prefix-activity/received/current-prefixes
# /bgp-state-data/bgp-route-vrfs/bgp-route-vrf[vrf="default"]/bgp-route-afs/bgp-route-af[afi-safi="ipv4-unicast"]/bgp-route-neighbors/bgp-route-neighbor[nbr-id="10.10.33.2"]/bgp-neighbor-route-filters/bgp-neighbor-route-filter[nbr-fltr="bgp-nrf-post-received"]/bgp-neighbor-route-entries/bgp-neighbor-route-entry/prefix
# /bgp-state-data/bgp-route-vrfs/bgp-route-vrf[vrf="default"]/bgp-route-afs/bgp-route-af[afi-safi="ipv4-unicast"]/bgp-route-filters/bgp-route-filter[route-filter="bgp-rf-all"]/bgp-route-entries/bgp-route-entry/available-paths
# /bgp-state-data/bgp-route-vrfs/bgp-route-vrf[vrf="default"]/bgp-route-afs/bgp-route-af[afi-safi="ipv4-unicast"]/bgp-route-filters/bgp-route-filter[route-filter="bgp-rf-all"]/bgp-route-entries/bgp-route-entry[prefix="8.8.81.0/24"]/bgp-path-entries/bgp-path-entry/weight
# /bgp-state-data/bgp-route-vrfs/bgp-route-vrf/bgp-route-afs/bgp-route-af/bgp-route-filters/bgp-route-filter/bgp-route-entries/bgp-route-entry/bgp-path-entries/bgp-path-entry/as-path
# /bgp-state-data/bgp-route-vrfs/bgp-route-vrf[vrf="default"]/bgp-route-afs/bgp-route-af[afi-safi="ipv4-unicast"]/bgp-route-filters/bgp-route-filter[route-filter="bgp-rf-all"]/bgp-route-entries//bgp-route-entry[prefix="4.4.5.0/24"]/bgp-path-entries/bgp-path-entry[nexthop="10.10.25.5"]/path-status/bestpath'))

#print(netconf_reply)
# Process the XML and store in useful dictionaries
#nr = xmltodict.parse(netconf_reply.xml)["rpc-reply"]["data"]["bgp-state-data"]["bgp-route-vrfs"]

nr = xmltodict.parse(netconf_reply.xml)["rpc-reply"]["data"]
pp.pprint(nr)

#nr = xmltodict.parse(netconf_reply.xml)
#pprint.pprint(nr["bgp-state-data"]["bgp-route-vrfs"]["bgp-route-afs"])

#print ("=" * 80)
#print (type(nr))
#print ("findkey=",findkey(nr,'ospf-neighbor'))

Is something like this you are trying to get ?

xmlDom = xml.dom.minidom.parseString( str( m.get_config( source='running', filter=('xpath', 'native/ip/multicast'))))

 

 

<?xml version="1.0" ?>

<rpc-reply message-id="urn:uuid:a9e323f3-c028-11e8-8524-8c8590ab85a6" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">

  <data>

    <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">

      <ip>

        <multicast>

          <multipath xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-multicast"/>

        </multicast>

      </ip>

    </native>

  </data>

</rpc-reply>

Here is an example of XPATH filter used to retrieve ipv4 unicast …. Trying to figure out the XPATH filter to retrieve let’s say the mcast route table ☺
Thank you.

netconf_reply=m.get(filter=('xpath','/routing-state/routing-instance[name="default"]/ribs/rib/routes'))


(nap) C02WX141HTD5:Cisco mihaiiancu$ python ncc0.py

################################################################################

OrderedDict([('routing-state',

OrderedDict([('@xmlns',

'urn:ietf:params:xml:ns:yang:ietf-routing'),

('routing-instance',

OrderedDict([('name', 'default'),

('ribs',

OrderedDict([('rib',

[OrderedDict([('name',

'ipv4-default'),

('routes',

OrderedDict([('route',

[OrderedDict([('destination-prefix',

'0.0.0.0'),

('route-preference',

'1'),

('metric',

'1'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.173.124.1')])),

('source-protocol',

'static'),

('active',

None)]),

OrderedDict([('destination-prefix',

'1.1.121.0'),

('route-preference',

'110'),

('metric',

'110'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.121'),

('next-hop-address',

'10.10.12.5')])),

('source-protocol',

OrderedDict([('@xmlns:ospf',

'urn:ietf:params:xml:ns:yang:ietf-ospf'),

('#text',

'ospf:ospfv2')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'3.3.0.0'),

('route-preference',

'20'),

('metric',

'20'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.33.3')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'3.3.1.0'),

('route-preference',

'200'),

('metric',

'200'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.12.1')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'3.3.2.0'),

('route-preference',

'20'),

('metric',

'20'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.33.3')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'3.3.3.0'),

('route-preference',

'20'),

('metric',

'20'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.33.3')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'4.4.1.0'),

('route-preference',

'200'),

('metric',

'200'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.12.1')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'4.4.2.0'),

('route-preference',

'200'),

('metric',

'200'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.12.1')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'4.4.3.0'),

('route-preference',

'200'),

('metric',

'200'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.12.1')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'4.4.5.0'),

('route-preference',

'200'),

('metric',

'200'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.12.1')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'4.4.8.0'),

('route-preference',

'20'),

('metric',

'20'),

('next-hop',

OrderedDict([('outgoing-interface',

None),

('next-hop-address',

'10.10.25.5')])),

('source-protocol',

OrderedDict([('@xmlns:rt-ext',

'urn:cisco:params:xml:ns:yang:cisco-routing-ext'),

('#text',

'rt-ext:bgp')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'8.8.8.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'Loopback8'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'8.8.8.8'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'Loopback8'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'8.8.81.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'Loopback81'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'8.8.81.81'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'Loopback81'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.12.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.120'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.12.2'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.120'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.12.4'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.121'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.12.6'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.121'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.13.4'),

('route-preference',

'110'),

('metric',

'110'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet2.121'),

('next-hop-address',

'10.10.12.5')])),

('source-protocol',

OrderedDict([('@xmlns:ospf',

'urn:ietf:params:xml:ns:yang:ietf-ospf'),

('#text',

'ospf:ospfv2')])),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.25.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet4'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.25.2'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet4'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.33.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet3'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.10.33.2'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet3'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.173.124.0'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet1'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)]),

OrderedDict([('destination-prefix',

'10.173.124.219'),

('route-preference',

'0'),

('metric',

'0'),

('next-hop',

OrderedDict([('outgoing-interface',

'GigabitEthernet1'),

('next-hop-address',

'0.0.0.0')])),

('source-protocol',

'direct'),

('active',

None)])])]))]),

OrderedDict([('name',

'ipv6-default')])])]))]))]))])









R2









(nap) C02WX141HTD5:Cisco mihaiiancu$