- out = VatExecutor.cmd_from_template(node, "create_vhost_user_if.vat",
- sock=socket)
- if out[0].get('retval') == 0:
- return out[0].get('sw_if_index')
- else:
- raise RuntimeError('Create Vhost-user interface failed on node '
- '"{}"'.format(node['host']))
+ cmd = u"create_vhost_user_if"
+ err_msg = f"Failed to create Vhost-user interface " \
+ f"on host {node[u'host']}"
+ args = dict(
+ is_server=bool(is_server),
+ sock_filename=str(socket),
+ enable_gso=bool(enable_gso)
+ )
+
+ with PapiSocketExecutor(node) as papi_exec:
+ sw_if_index = papi_exec.add(cmd, **args).get_sw_if_index(err_msg)
+
+ # Update the Topology:
+ if_key = Topology.add_new_port(node, u"vhost")
+ Topology.update_interface_sw_if_index(node, if_key, sw_if_index)
+
+ ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_index)
+ Topology.update_interface_name(node, if_key, ifc_name)
+
+ ifc_mac = InterfaceUtil.vpp_get_interface_mac(node, sw_if_index)
+ Topology.update_interface_mac_address(node, if_key, ifc_mac)
+
+ Topology.update_interface_vhost_socket(node, if_key, socket)
+
+ return sw_if_index