X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FRouting.py;h=7bb41cbfad0bef813eab535ba026bc735c60838b;hb=5db24a985316c70a707f2a11b30dd00f7a98dca7;hp=b22516a7c430086a38aab2d0ff0d62611627b19f;hpb=e6cb3709bd670738471fff40ce13dcb5aff8692f;p=csit.git diff --git a/resources/libraries/python/Routing.py b/resources/libraries/python/Routing.py index b22516a7c4..7bb41cbfad 100644 --- a/resources/libraries/python/Routing.py +++ b/resources/libraries/python/Routing.py @@ -13,8 +13,8 @@ """Routing utilities library.""" -from VatExecutor import VatTerminal -from topology import Topology +from resources.libraries.python.VatExecutor import VatTerminal +from resources.libraries.python.topology import Topology class Routing(object): @@ -29,17 +29,38 @@ class Routing(object): :param prefix_len: Route destination network prefix length. :param gateway: Route gateway address. :param interface: Route interface. - :type node: str + :type node: dict :type network: str :type prefix_len: int :type gateway: str :type interface: str """ sw_if_index = Topology.get_interface_sw_index(node, interface) - vat = VatTerminal(node) - vat.vat_terminal_exec_cmd_from_template('add_route.vat', - network=network, - prefix_length=prefix_len, - gateway=gateway, - sw_if_index=sw_if_index) - vat.vat_terminal_close() + with VatTerminal(node) as vat: + vat.vat_terminal_exec_cmd_from_template('add_route.vat', + network=network, + prefix_length=prefix_len, + gateway=gateway, + sw_if_index=sw_if_index) + + @staticmethod + def add_fib_table(node, network, prefix_len, fib_id, place): + """Create new FIB table according to ID. + + :param node: Node to add FIB on. + :param network: IP address to add to the FIB table. + :param prefix_len: IP address prefix length. + :param fib_id: FIB table ID. + :param place: Possible variants are local, drop. + :type node: dict + :type network: str + :type prefix_len: int + :type fib_id: int + :type place: str + """ + with VatTerminal(node) as vat: + vat.vat_terminal_exec_cmd_from_template('add_fib_table.vat', + network=network, + prefix_length=prefix_len, + fib_number=fib_id, + where=place)