+ cmd = 'sw_interface_set_l2_xconnect'
+ args1 = dict(rx_sw_if_index=sw_iface1,
+ tx_sw_if_index=sw_iface2,
+ enable=1)
+ args2 = dict(rx_sw_if_index=sw_iface2,
+ tx_sw_if_index=sw_iface1,
+ enable=1)
+
+ err_msg = 'Failed to add L2 cross-connect between two interfaces on' \
+ ' host {host}'.format(host=node['host'])
+
+ with PapiExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg).\
+ verify_replies(err_msg=err_msg)
+
+ @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
+
+ cmd = 'l2_patch_add_del'
+ args1 = dict(rx_sw_if_index=sw_iface1,
+ tx_sw_if_index=sw_iface2,
+ is_add=1)
+ args2 = dict(rx_sw_if_index=sw_iface2,
+ tx_sw_if_index=sw_iface1,
+ is_add=1)
+
+ err_msg = 'Failed to add L2 patch between two interfaces on' \
+ ' host {host}'.format(host=node['host'])
+
+ with PapiExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg).\
+ verify_replies(err_msg=err_msg)