+ cmd = u"bridge_domain_dump"
+ args = dict(
+ bd_id=int(bd_id)
+ )
+ err_msg = f"Failed to get L2FIB dump on host {node[u'host']}"
+
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd, **args).get_details(err_msg)
+
+ retval = details if bd_id == Constants.BITWISE_NON_ZERO else None
+
+ for bridge_domain in details:
+ if bridge_domain[u"bd_id"] == bd_id:
+ retval = bridge_domain
+
+ return retval
+
+ @staticmethod
+ def l2_vlan_tag_rewrite(
+ node, interface, tag_rewrite_method, push_dot1q=True, tag1_id=None,
+ tag2_id=None):
+ """Rewrite tags in ethernet frame.
+
+ :param node: Node to rewrite tags.
+ :param interface: Interface on which rewrite tags.
+ :param tag_rewrite_method: Method of tag rewrite.
+ :param push_dot1q: Optional parameter to disable to push dot1q tag
+ instead of dot1ad.
+ :param tag1_id: Optional tag1 ID for VLAN.
+ :param tag2_id: Optional tag2 ID for VLAN.
+ :type node: dict
+ :type interface: str or int
+ :type tag_rewrite_method: str
+ :type push_dot1q: bool
+ :type tag1_id: int
+ :type tag2_id: int
+ """
+ tag1_id = int(tag1_id) if tag1_id else 0
+ tag2_id = int(tag2_id) if tag2_id else 0
+
+ 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"])