Files
infix/test/infamy/route.py
T
Mattias WalströmandJoachim Wiberg 4e7bdc58d4 Add OSPFv2 support
A very limited part of the YANG model is implemented so far, basicly it is OSPFv2 with multiple areas and you can change timers
for the interfaces. Limited operational support.

admin@infix-00-00-00:/config/> edit routing control-plane-protocol ietf-ospf:ospfv2 name default
admin@infix-00-00-00:/config/routing/control-plane-protocol/ietf-ospf:ospfv2/name/default/> set ospf area 0.0.0.0 interface e0 enabled true
admin@infix-00-00-00:/config/routing/control-plane-protocol/ietf-ospf:ospfv2/name/default/> leave
2023-12-18 17:28:00 +01:00

29 lines
1005 B
Python

def _get_routes(target, protocol):
xpath="/ietf-routing:routing/ribs"
rib = target.get_data(xpath)["routing"]["ribs"]["rib"]
for r in rib:
if r["name"] != protocol:
continue
return r.get("routes", {}).get("route",{})
return {}
def _exist_route(target, prefix, nexthop, version,source_protocol):
routes = _get_routes(target, version)
for r in routes:
if r["destination-prefix"] != prefix:
continue
if source_protocol and r.get("source-protocol") != source_protocol:
continue
nh = r["next-hop"]
if nexthop and nh["next-hop-address"] != nexthop:
continue
return True
return False
def ipv4_route_exist(target, prefix, nexthop=None,source_protocol=None):
return _exist_route(target, prefix, nexthop, "ipv4",source_protocol)
def ipv6_route_exist(target, prefix, nexthop=None,source_protocol=None):
return _exist_route(target, prefix, nexthop, "ipv6",source_protocol)