X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FL2Util.py;h=4dc230cf16f25fea2f0d97ac9f3c8f0d09335830;hb=2bd0f8299dffb7818d87081f2f7b06d38a8ab620;hp=a89130814c3f5c4664e12154bfbceb662031b5c2;hpb=8adf454177cc4df3335a26cc7567add8a40870c4;p=csit.git diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index a89130814c..4dc230cf16 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -159,19 +159,27 @@ class L2Util(object): """Create bidirectional cross-connect between 2 interfaces on vpp node. :param node: Node to add bidirectional cross-connect - :param interface1: first interface - :param interface2: second interface + :param interface1: first interface name or sw_if_index + :param interface2: second interface name or sw_if_index :type node: dict - :type interface1: str - :type interface2: str + :type interface1: str or int + :type interface2: str or int """ - sw_iface1 = Topology().get_interface_sw_index(node, interface1) - sw_iface2 = Topology().get_interface_sw_index(node, interface2) - vat = VatTerminal(node) - vat.vat_terminal_exec_cmd_from_template('l2_xconnect.vat', - interface1=sw_iface1, - interface2=sw_iface2) - vat.vat_terminal_exec_cmd_from_template('l2_xconnect.vat', - interface1=sw_iface2, - interface2=sw_iface1) - vat.vat_terminal_close() + + if isinstance(interface1, basestring): + sw_iface1 = Topology().get_interface_sw_index(node, interface1) + else: + sw_iface1 = interface1 + + if isinstance(interface2, basestring): + sw_iface2 = Topology().get_interface_sw_index(node, interface2) + else: + sw_iface2 = interface2 + + with VatTerminal(node) as vat: + vat.vat_terminal_exec_cmd_from_template('l2_xconnect.vat', + interface1=sw_iface1, + interface2=sw_iface2) + vat.vat_terminal_exec_cmd_from_template('l2_xconnect.vat', + interface1=sw_iface2, + interface2=sw_iface1)