From patchwork Thu Oct 13 10:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Juraj_Linke=C5=A1?= X-Patchwork-Id: 118133 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 532A6A00C2; Thu, 13 Oct 2022 12:36:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2A8942EAA; Thu, 13 Oct 2022 12:35:31 +0200 (CEST) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id 1C62442E8B for ; Thu, 13 Oct 2022 12:35:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id 4DF6116560F; Thu, 13 Oct 2022 12:35:27 +0200 (CEST) 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 JbxXyBPBU18T; Thu, 13 Oct 2022 12:35:26 +0200 (CEST) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 1A9FA165606; Thu, 13 Oct 2022 12:35:21 +0200 (CEST) From: =?utf-8?q?Juraj_Linke=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_Linke=C5=A1?= Subject: [PATCH v6 07/10] dts: add node base class Date: Thu, 13 Oct 2022 10:35:14 +0000 Message-Id: <20221013103517.3443997-8-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221013103517.3443997-1-juraj.linkes@pantheon.tech> References: <20221013103517.3443997-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 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 | 8 ++++ dts/framework/testbed_model/node.py | 63 +++++++++++++++++++++++++ 2 files changed, 71 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..7e8a1f7489 --- /dev/null +++ b/dts/framework/testbed_model/__init__.py @@ -0,0 +1,8 @@ +# 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..81b7f3ab83 --- /dev/null +++ b/dts/framework/testbed_model/node.py @@ -0,0 +1,63 @@ +# 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()