+ vtr_oper = getattr(
+ L2VtrOp, f"L2_VTR_{tag_rewrite_method.replace(u'-', u'_').upper()}"
+ )
+
+ if isinstance(interface, str):
+ iface_key = Topology.get_interface_by_name(node, interface)
+ sw_if_index = Topology.get_interface_sw_index(node, iface_key)
+ else:
+ sw_if_index = interface
+
+ cmd = u"l2_interface_vlan_tag_rewrite"
+ args = dict(
+ sw_if_index=sw_if_index,
+ vtr_op=int(vtr_oper),
+ push_dot1q=int(push_dot1q),
+ tag1=tag1_id,
+ tag2=tag2_id
+ )
+ err_msg = f"Failed to set VLAN TAG rewrite on host {node['host']}"
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+
+ @staticmethod
+ def get_l2_fib_table(node, bd_id):
+ """Retrieves the L2 FIB table.
+
+ :param node: VPP node.
+ :param bd_id: Index of the bridge domain.
+ :type node: dict
+ :type bd_id: int
+ :returns: L2 FIB table.
+ :rtype: list
+ """
+ cmd = u"l2_fib_table_dump"
+ args = dict(
+ bd_id=int(bd_id)
+ )
+ err_msg = f"Failed to get L2FIB dump on host {node['host']}"
+
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd, **args).get_details(err_msg)
+
+ for fib_item in details:
+ fib_item[u"mac"] = L2Util.bin_to_mac(fib_item[u"mac"])
+
+ return details
+
+ @staticmethod
+ def get_l2_fib_entry_by_mac(node, bd_index, mac):
+ """Retrieves the L2 FIB entry specified by MAC address using PAPI.
+
+ :param node: VPP node.
+ :param bd_index: Index of the bridge domain.
+ :param mac: MAC address used as the key in L2 FIB data structure.
+ :type node: dict
+ :type bd_index: int
+ :type mac: str
+ :returns: L2 FIB entry
+ :rtype: dict
+ """
+ bd_data = L2Util.vpp_get_bridge_domain_data(node)
+ bd_id = bd_data[bd_index-1][u"bd_id"]