From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20AE3456A2; Wed, 24 Jul 2024 16:09:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB6C94344E; Wed, 24 Jul 2024 16:09:31 +0200 (CEST) Received: from mail-il1-f227.google.com (mail-il1-f227.google.com [209.85.166.227]) by mails.dpdk.org (Postfix) with ESMTP id B07DD43440 for ; Wed, 24 Jul 2024 16:09:30 +0200 (CEST) Received: by mail-il1-f227.google.com with SMTP id e9e14a558f8ab-395e9f2ebc0so35324395ab.0 for ; Wed, 24 Jul 2024 07:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721830170; x=1722434970; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ap735j3cLYE3m1ei6abxO38EK1Sj/3VyuWAOmiZB5+8=; b=P+wAvtosor9sBaRiuiksOcBVn0Y3KVRC5Af3azVaaUh0o68x7kbpDJBDLV/1am0Yca P22yg8Uy0APmD6Onmvkxj2GrJenIKnLkJbPkRYOBO4Y0tsnlghHAkU+0dUOIA6B6P8N8 nLcU/4e8oCF8E+htZYnKInSBGYFUU+x4+xbXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721830170; x=1722434970; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ap735j3cLYE3m1ei6abxO38EK1Sj/3VyuWAOmiZB5+8=; b=dw2B1ZSi6wos7u47ELr3TkRXmUnbhnR9YEsoILwSaxZ3Xehg/SfMm9Y/PaRvwi9qJH TNxM/oq3RVBVTdisl1SxhH6xSnAupgzmpKhOycrbJC4wiZWpJ/xeZ8Py9YzDniGXuC7U q4BcICExmXH/l+Eh4s+PiES7Mj6800btddYdKanhd01+3/pGJ6oz22T9b/VLN4pzKRKo FME/8xVILFpMgCFXJc+BXHSNyygwxMVuA0wwAaxn8o17H9V924Q0uyevSvsZG7sUPWCE 52C2C89bVKOWfd3PhPesc0e27X7n45T2IlTpjS9q1TYGxrNcp9gk6+wmEAPQUouTm/NQ zasQ== X-Gm-Message-State: AOJu0Yy0g8ZBnI2FPoEGxId6IuSOjBxQPkp8wPk+KTFxduqxvem8VTAb caM/iWnNtqZV298m9CWI024D1wsROW2P4nBFpYiVRr+PYSOgOGi/67AbZ59JNpOX/4ZKlU7o/Z6 wh10JW+vNDoLxkZ7KQXfhJDPwo7O9h5hJPqUmeXWRhsnSUR22 X-Google-Smtp-Source: AGHT+IFIzL4sEAIiUl3n+kf50VDj+hqDF2EpIYJg8hA6OhqdqSTpoKFoLf5JyZEbmPeJJYSCRXS4m7hEDvM6 X-Received: by 2002:a92:c544:0:b0:379:40e0:b0b8 with SMTP id e9e14a558f8ab-39a194b8a42mr25939155ab.20.1721830169797; Wed, 24 Jul 2024 07:09:29 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-39a186a7f53sm788215ab.33.2024.07.24.07.09.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2024 07:09:29 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 5ECF060526E2; Wed, 24 Jul 2024 10:09:28 -0400 (EDT) From: jspewock@iol.unh.edu To: Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu, Luca.Vizzarro@arm.com, paul.szczepanek@arm.com, wathsala.vithanage@arm.com, probb@iol.unh.edu, thomas@monjalon.net, yoan.picchi@foss.arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Jeremy Spewock , Luca Vizzarro Subject: [PATCH v5 2/3] dts: Add missing docstring from XML-RPC server Date: Wed, 24 Jul 2024 10:08:37 -0400 Message-ID: <20240724140838.171012-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724140838.171012-1-jspewock@iol.unh.edu> References: <20240501161623.26672-1-jspewock@iol.unh.edu> <20240724140838.171012-1-jspewock@iol.unh.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock When this XML-RPC server implementation was added, the docstring had to be shortened in order to reduce the chances of this race condition being encountered. Now that this race condition issue is resolved, the full docstring can be restored. Signed-off-by: Jeremy Spewock Reviewed-by: Juraj Linkeš Reviewed-by: Luca Vizzarro Reviewed-by: Nicholas Pratte --- .../testbed_model/traffic_generator/scapy.py | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/dts/framework/testbed_model/traffic_generator/scapy.py b/dts/framework/testbed_model/traffic_generator/scapy.py index 7f0cc2bc18..08e1f4ae7e 100644 --- a/dts/framework/testbed_model/traffic_generator/scapy.py +++ b/dts/framework/testbed_model/traffic_generator/scapy.py @@ -128,9 +128,53 @@ def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: s class QuittableXMLRPCServer(SimpleXMLRPCServer): - """Basic XML-RPC server. + r"""Basic XML-RPC server. The server may be augmented by functions serializable by the :mod:`marshal` module. + + Example: + :: + + def hello_world(): + # to be sent to the XML-RPC server + print("Hello World!") + + # start the XML-RPC server on the remote node + # this is done by starting a Python shell on the remote node + from framework.remote_session import PythonShell + # the example assumes you're already connected to a tg_node + session = tg_node.create_interactive_shell(PythonShell, timeout=5, privileged=True) + + # then importing the modules needed to run the server + # and the modules for any functions later added to the server + session.send_command("import xmlrpc") + session.send_command("from xmlrpc.server import SimpleXMLRPCServer") + + # sending the source code of this class to the Python shell + from xmlrpc.server import SimpleXMLRPCServer + src = inspect.getsource(QuittableXMLRPCServer) + src = "\n".join([l for l in src.splitlines() if not l.isspace() and l != ""]) + spacing = "\n" * 4 + session.send_command(spacing + src + spacing) + + # then starting the server with: + command = "s = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));s.serve_forever()" + session.send_command(command, "XMLRPC OK") + + # now the server is running on the remote node and we can add functions to it + # first connect to the server from the execution node + import xmlrpc.client + server_url = f"http://{tg_node.config.hostname}:8000" + rpc_server_proxy = xmlrpc.client.ServerProxy(server_url) + + # get the function bytes to send + import marshal + function_bytes = marshal.dumps(hello_world.__code__) + rpc_server_proxy.add_rpc_function(hello_world.__name__, function_bytes) + + # now we can execute the function on the server + xmlrpc_binary_recv: xmlrpc.client.Binary = rpc_server_proxy.hello_world() + print(str(xmlrpc_binary_recv)) """ def __init__(self, *args, **kwargs): -- 2.45.2