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$