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 22A4DA00C5; Fri, 4 Nov 2022 12:06:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15DD242D46; Fri, 4 Nov 2022 12:05:41 +0100 (CET) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id 478D442D3B for ; Fri, 4 Nov 2022 12:05:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id 6AD421BA5B7; Fri, 4 Nov 2022 12:05:38 +0100 (CET) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n3uaic1TpF_Z; Fri, 4 Nov 2022 12:05:37 +0100 (CET) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 5EB701BA5B1; Fri, 4 Nov 2022 12:05:29 +0100 (CET) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, ohilyard@iol.unh.edu, lijuan.tu@intel.com, kda@semihalf.com, bruce.richardson@intel.com Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH v8 7/9] dts: add node base class Date: Fri, 4 Nov 2022 11:05:21 +0000 Message-Id: <20221104110523.511367-8-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104110523.511367-1-juraj.linkes@pantheon.tech> References: <20221103151934.450887-1-juraj.linkes@pantheon.tech> <20221104110523.511367-1-juraj.linkes@pantheon.tech> 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 The base class implements basic node management methods - connect and execute commands. Signed-off-by: Owen Hilyard Signed-off-by: Juraj Linkeš --- dts/framework/testbed_model/__init__.py | 7 +++ dts/framework/testbed_model/node.py | 62 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 dts/framework/testbed_model/__init__.py create mode 100644 dts/framework/testbed_model/node.py diff --git a/dts/framework/testbed_model/__init__.py b/dts/framework/testbed_model/__init__.py new file mode 100644 index 0000000000..c5512e5812 --- /dev/null +++ b/dts/framework/testbed_model/__init__.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 University of New Hampshire + +""" +This module contains the classes used to model the physical traffic generator, +system under test and any other components that need to be interacted with. +""" diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py new file mode 100644 index 0000000000..8437975416 --- /dev/null +++ b/dts/framework/testbed_model/node.py @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2014 Intel Corporation +# Copyright(c) 2022 PANTHEON.tech s.r.o. +# Copyright(c) 2022 University of New Hampshire + +""" +A node is a generic host that DTS connects to and manages. +""" + +from framework.config import NodeConfiguration +from framework.logger import DTSLOG, getLogger +from framework.remote_session import RemoteSession, create_remote_session +from framework.settings import SETTINGS + + +class Node(object): + """ + Basic module for node management. This module implements methods that + manage a node, such as information gathering (of CPU/PCI/NIC) and + environment setup. + """ + + name: str + main_session: RemoteSession + logger: DTSLOG + _config: NodeConfiguration + _other_sessions: list[RemoteSession] + + def __init__(self, node_config: NodeConfiguration): + self._config = node_config + self._other_sessions = [] + + self.name = node_config.name + self.logger = getLogger(self.name) + self.logger.info(f"Created node: {self.name}") + self.main_session = create_remote_session(self._config, self.name, self.logger) + + def send_command(self, cmds: str, timeout: float = SETTINGS.timeout) -> str: + """ + Send commands to node and return string before timeout. + """ + + return self.main_session.send_command(cmds, timeout) + + def create_session(self, name: str) -> RemoteSession: + connection = create_remote_session( + self._config, + name, + getLogger(name, node=self.name), + ) + self._other_sessions.append(connection) + return connection + + def node_exit(self) -> None: + """ + Recover all resource before node exit + """ + if self.main_session: + self.main_session.close() + for session in self._other_sessions: + session.close() + self.logger.logger_exit() -- 2.30.2