- 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 PapiExecutor(node) as papi_exec:
+ data = papi_exec.add(cmd, **args).get_replies(err_msg).\
+ verify_reply(err_msg=err_msg)
+
+ # Extract sw_if_idx:
+ sw_if_idx = data["sw_if_index"]
+
+ # Update the Topology:
+ if_key = Topology.add_new_port(node, 'vhost')
+ Topology.update_interface_sw_if_index(node, if_key, sw_if_idx)
+
+ ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_idx)
+ Topology.update_interface_name(node, if_key, ifc_name)
+
+ ifc_mac = InterfaceUtil.vpp_get_interface_mac(node, sw_if_idx)
+ Topology.update_interface_mac_address(node, if_key, ifc_mac)
+
+ Topology.update_interface_vhost_socket(node, if_key, socket)
+
+ return sw_if_idx