diff options
author | Tibor Frank <tifrank@cisco.com> | 2016-09-26 18:27:57 +0200 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2016-10-10 11:27:48 +0000 |
commit | 74a354349cf13e8874259faec5473b7bbf25d6e5 (patch) | |
tree | e70fc7e5afb22ac7d40608db5682219c1464b6b8 /resources/libraries/python | |
parent | a7568a2eabf0872d25260c14ec084cb3d5ffb0f3 (diff) |
CSIT-392: ip4-lispgpe-ip4
- ip4-lispgpe-ip4 - main fib, vrf, virt2lisp
Change-Id: I28c81e91689021693ce76352878fa21e953a4ef6
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r-- | resources/libraries/python/IPUtil.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index ed38272645..f3c037fdf0 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -139,6 +139,26 @@ class IPUtil(object): raise RuntimeError( 'Could not set IP for interface, reason:{}'.format(stderr)) + @staticmethod + def set_linux_interface_route(node, interface, route, namespace=None): + """Set route via interface in linux. + + :param node: Node where to execute command. + :param interface: Interface in namespace. + :param route: Route to be added via interface. + :param namespace: Execute command in namespace. Optional parameter. + :type node: dict + :type interface: str + :type route: str + :type namespace: str + """ + if namespace is not None: + cmd = 'ip netns exec {} ip route add {} dev {}'.format( + namespace, route, interface) + else: + cmd = 'ip route add {} dev {}'.format(route, interface) + exec_cmd_no_error(node, cmd, sudo=True) + def convert_ipv4_netmask_prefix(network): """Convert network mask to equivalent network prefix length or vice versa. |