def encap_route(m, vrf, subnet, if_or_name, ip=ipv4, src=None): if type(if_or_name) is str: devname = m.get_interface(if_or_name).get_devname() else: devname = if_or_name.get_devname() if src is not None: srcstr = " src %s" % src else: srcstr = "" return route(m, vrf, "%s dev %s%s" % (ip(test_ip(subnet, 0)), devname, srcstr))
def add_forward_route(m, vrf, remote_ip, via=ipv4(test_ip(99, 2, []))): route(m, vrf, "%s/32 via %s" % (remote_ip, via)).__enter__()