- command = 'connect'
- if mac is not None:
- args = 'tapname {} mac {}'.format(tap_name, mac)
- else:
- args = 'tapname {}'.format(tap_name)
- with VatTerminal(node) as vat:
- resp = vat.vat_terminal_exec_cmd_from_template('tap.vat',
- tap_command=command,
- tap_arguments=args)
- sw_if_idx = resp[0]['sw_if_index']
- if_key = Topology.add_new_port(node, 'tap')
- Topology.update_interface_sw_if_index(node, if_key, sw_if_idx)
- ifc_name = Tap.vpp_get_tap_interface_name(node, sw_if_idx)
- Topology.update_interface_name(node, if_key, ifc_name)
+ cmd = u"tap_create_v2"
+ args = dict(
+ id=Constants.BITWISE_NON_ZERO,
+ use_random_mac=bool(mac is None),
+ mac_address=L2Util.mac_to_bin(mac) if mac else None,
+ num_rx_queues=int(num_rx_queues),
+ tx_ring_sz=int(txq_size),
+ rx_ring_sz=int(rxq_size),
+ host_mtu_set=False,
+ host_mac_addr_set=False,
+ host_ip4_prefix_set=False,
+ host_ip6_prefix_set=False,
+ host_ip4_gw_set=False,
+ host_ip6_gw_set=False,
+ host_namespace_set=bool(host_namespace),
+ host_namespace=host_namespace,
+ host_if_name_set=True,
+ host_if_name=tap_name,
+ host_bridge_set=False,
+ tap_flags=tap_feature_mask
+ )
+ err_msg = f"Failed to create tap interface {tap_name} " \
+ f"on host {node[u'host']}"
+
+ with PapiSocketExecutor(node) as papi_exec:
+ sw_if_index = papi_exec.add(cmd, **args).get_sw_if_index(err_msg)
+
+ if_key = Topology.add_new_port(node, u"tap")
+ Topology.update_interface_sw_if_index(node, if_key, sw_if_index)
+ Topology.update_interface_name(node, if_key, tap_name)