- 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 = 'create_vhost_user_if'
+ err_msg = 'Failed to create Vhost-user interface on host {host}'.format(
+ host=node['host'])
+ args = dict(
+ sock_filename=str(socket)
+ )
+ 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, '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