+ @staticmethod
+ def vpp_add_l2_bridge_domain(node, bd_id, port_1, port_2, learn=True):
+ """Add L2 bridge domain with 2 interfaces to the VPP node.
+
+ :param node: Node to add L2BD on.
+ :param bd_id: Bridge domain ID.
+ :param port_1: First interface name added to L2BD.
+ :param port_2: Second interface name added to L2BD.
+ :param learn: Enable/disable MAC learn.
+ :type node: dict
+ :type bd_id: int
+ :type port_1: str
+ :type port_2: str
+ :type learn: bool
+ """
+ sw_if_index1 = Topology.get_interface_sw_index(node, port_1)
+ sw_if_index2 = Topology.get_interface_sw_index(node, port_2)
+ VatExecutor.cmd_from_template(node,
+ 'l2_bridge_domain.vat',
+ sw_if_id1=sw_if_index1,
+ sw_if_id2=sw_if_index2,
+ bd_id=bd_id,
+ learn=int(learn))
+
+ @staticmethod
+ def vpp_setup_bidirectional_cross_connect(node, interface1, interface2):
+ """Create bidirectional cross-connect between 2 interfaces on vpp node.
+
+ :param node: Node to add bidirectional cross-connect
+ :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_xconnect.vat',
+ interface1=sw_iface1,
+ interface2=sw_iface2)
+ vat.vat_terminal_exec_cmd_from_template('l2_xconnect.vat',
+ interface1=sw_iface2,
+ interface2=sw_iface1)
+
+ @staticmethod
+ def linux_add_bridge(node, br_name, if_1, if_2):
+ """Bridge two interfaces on linux node.
+
+ :param node: Node to add bridge on.
+ :param br_name: Bridge name.
+ :param if_1: First interface to be added to the bridge.
+ :param if_2: Second interface to be added to the bridge.
+ :type node: dict
+ :type br_name: str
+ :type if_1: str
+ :type if_2: str
+ """
+ cmd = 'brctl addbr {0}'.format(br_name)
+ exec_cmd_no_error(node, cmd, sudo=True)
+ cmd = 'brctl addif {0} {1}'.format(br_name, if_1)
+ exec_cmd_no_error(node, cmd, sudo=True)
+ cmd = 'brctl addif {0} {1}'.format(br_name, if_2)
+ exec_cmd_no_error(node, cmd, sudo=True)
+
+ @staticmethod
+ def linux_del_bridge(node, br_name):
+ """Delete bridge from linux node.
+
+ :param node: Node to delete bridge from.
+ :param br_name: Bridge name.
+ .. note:: The network interface corresponding to the bridge must be
+ down before it can be deleted!
+ """
+ cmd = 'brctl delbr {0}'.format(br_name)
+ exec_cmd_no_error(node, cmd, sudo=True)
+
+ @staticmethod
+ def vpp_get_bridge_domain_data(node, bd_id=None):
+ """Get all bridge domain data from a VPP node. If a domain ID number is
+ provided, return only data for the matching bridge domain.
+
+ :param node: VPP node to get bridge domain data from.
+ :param bd_id: Numeric ID of a specific bridge domain.
+ :type node: dict
+ :type bd_id: int
+ :return: List of dictionaries containing data for each bridge domain, or
+ a single dictionary for the specified bridge domain.
+ :rtype: list or dict
+ """
+ with VatTerminal(node) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template("l2_bd_dump.vat")
+
+ data = response[0]
+
+ if bd_id is not None:
+ for bridge_domain in data:
+ if bridge_domain["bd_id"] == bd_id:
+
+ return bridge_domain
+
+ return data