+ def _memif_dump(node):
+ """Get the memif dump on the given node.
+
+ :param node: Given node to get Memif dump from.
+ :type node: dict
+ :returns: List of memif interfaces extracted from Papi response.
+ :rtype: list
+ """
+ with PapiExecutor(node) as papi_exec:
+ dump = papi_exec.add("memif_dump").get_dump()
+
+ data = list()
+ for item in dump.reply[0]["api_reply"]:
+ item["memif_details"]["if_name"] = \
+ item["memif_details"]["if_name"].rstrip('\x00')
+ item["memif_details"]["hw_addr"] = \
+ L2Util.bin_to_mac(item["memif_details"]["hw_addr"])
+ data.append(item)
+
+ logging.debug("MEMIF data:\n{data}".format(data=data))
+
+ return data
+
+ @staticmethod
+ def _memif_socket_filename_add_del(node, is_add, filename, sid):
+ """Create Memif socket on the given node.
+
+ :param node: Given node to create Memif socket on.
+ :param is_add: If True, socket is added, otherwise deleted.
+ :param filename: Memif interface socket filename.
+ :param sid: Socket ID.
+ :type node: dict
+ :type is_add: bool
+ :type filename: str
+ :type sid: str
+ :returns: Verified data from PAPI response. In this case, the response
+ includes only retval.
+ :rtype: dict
+ """
+ cmd = 'memif_socket_filename_add_del'
+ err_msg = 'Failed to create memif socket on host {host}'.format(
+ host=node['host'])
+ args = dict(
+ is_add=int(is_add),
+ socket_id=int(sid),
+ socket_filename=str('/tmp/' + filename)
+ )
+ with PapiExecutor(node) as papi_exec:
+ data = papi_exec.add(cmd, **args).get_replies(err_msg).\
+ verify_reply(err_msg=err_msg)
+ return data
+
+ @staticmethod
+ def _memif_create(node, mid, sid, rxq=1, txq=1, role=1):