+ cmd = 'bridge_domain_dump'
+ args = dict(bd_id=int(bd_id))
+ err_msg = 'Failed to get L2FIB dump on host {host}'.format(
+ host=node['host'])
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd, **args).get_details(err_msg)
+
+ if bd_id == Constants.BITWISE_NON_ZERO:
+ return details
+ for bridge_domain in details:
+ if bridge_domain['bd_id'] == bd_id:
+ return bridge_domain
+
+ @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, 'L2_VTR_{}'.format(
+ tag_rewrite_method.replace('-', '_').upper()))
+
+ if isinstance(interface, basestring):
+ 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 = '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 = 'Failed to set VLAN TAG rewrite on host {host}'.format(
+ 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 = 'l2_fib_table_dump'
+ args = dict(bd_id=int(bd_id))
+ err_msg = 'Failed to get L2FIB dump on host {host}'.format(
+ 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['mac'] = L2Util.bin_to_mac(fib_item['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
+ """