X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FL2Util.py;h=52d138552b25bc828d1e4f49b246feb6d215fca9;hb=4b84a3d0620c827aa9bc9c36776af50a88a180f4;hp=7954193b6074949ff5dd8614f6eb0454b926c82b;hpb=4c6fe5602edcbd9857a846e5b13a21d5c671a2c8;p=csit.git diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index 7954193b60..52d138552b 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -43,9 +43,9 @@ class L2Util(object): to string format (01:02:03:04:05:06). :param mac_int: MAC address in integer representation. - :type mac_int: str + :type mac_int: int :returns: String representation of MAC address. - :rtype: int + :rtype: str """ return ':'.join(wrap("{:012x}".format(mac_int), width=2)) @@ -132,7 +132,6 @@ class L2Util(object): :type sw_if_index: int :type bd_id: int :type shg: int - :returns: None """ VatExecutor.cmd_from_template(node, "l2_bd_add_sw_if_index.vat", bd_id=bd_id, sw_if_index=sw_if_index, @@ -217,6 +216,36 @@ class L2Util(object): interface1=sw_iface2, interface2=sw_iface1) + @staticmethod + def vpp_setup_bidirectional_l2_patch(node, interface1, interface2): + """Create bidirectional l2 patch between 2 interfaces on vpp node. + + :param node: Node to add bidirectional l2 patch. + :param interface1: First interface name or sw_if_index. + :param interface2: Second interface name or sw_if_index. + :type node: dict + :type interface1: str or int + :type interface2: str or int + """ + + 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_patch.vat', + interface1=sw_iface1, + interface2=sw_iface2) + vat.vat_terminal_exec_cmd_from_template('l2_patch.vat', + interface1=sw_iface2, + interface2=sw_iface1) + @staticmethod def linux_add_bridge(node, br_name, if_1, if_2, set_up=True): """Bridge two interfaces on linux node. @@ -254,7 +283,7 @@ class L2Util(object): :param br_name: Bridge name. :param set_down: Change bridge interface state to down before delbr command. Optional. Default: True. - :type node: str + :type node: dict :type br_name: str :type set_down: bool """