DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
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, "Juraj Linkeš" <juraj.linkes@pantheon.tech>
Subject: [PATCH v8 7/9] dts: add node base class
Date: Fri,  4 Nov 2022 11:05:21 +0000	[thread overview]
Message-ID: <20221104110523.511367-8-juraj.linkes@pantheon.tech> (raw)
In-Reply-To: <20221104110523.511367-1-juraj.linkes@pantheon.tech>

The base class implements basic node management methods - connect and
execute commands.

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 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


  parent reply	other threads:[~2022-11-04 11:06 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 10:35 [PATCH v6 00/10] dts: ssh connection to a node Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 01/10] dts: add project tools config Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 02/10] dts: add developer tools Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 03/10] dts: add config parser module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 04/10] dts: add basic logging facility Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 05/10] dts: add remote session abstraction Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 06/10] dts: add ssh session module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 07/10] dts: add node base class Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 08/10] dts: add dts workflow module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 09/10] dts: add dts executable script Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 10/10] maintainers: add dts maintainers Juraj Linkeš
2022-10-13 10:45 ` [PATCH v6 00/10] dts: ssh connection to a node Bruce Richardson
2022-10-31 19:01 ` Thomas Monjalon
2022-11-02 12:58   ` Owen Hilyard
2022-11-02 13:15     ` Thomas Monjalon
2022-11-03 15:19 ` [PATCH v7 0/9] " Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 1/9] dts: add project tools config Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 2/9] dts: add developer tools Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 3/9] dts: add config parser module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 4/9] dts: add basic logging facility Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 5/9] dts: add remote session abstraction Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 6/9] dts: add ssh session module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 7/9] dts: add node base class Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 8/9] dts: add dts workflow module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 9/9] dts: add dts executable script Juraj Linkeš
2022-11-04 11:05   ` [PATCH v8 0/9] dts: ssh connection to a node Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 1/9] dts: add project tools config Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 2/9] dts: add developer tools Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 3/9] dts: add config parser module Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 4/9] dts: add basic logging facility Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 5/9] dts: add remote session abstraction Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 6/9] dts: add ssh session module Juraj Linkeš
2022-11-04 11:05     ` Juraj Linkeš [this message]
2022-11-04 11:05     ` [PATCH v8 8/9] dts: add dts workflow module Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 9/9] dts: add dts executable script Juraj Linkeš
2022-11-09 16:11     ` [PATCH v8 0/9] dts: ssh connection to a node Thomas Monjalon
2022-11-09 16:23       ` Honnappa Nagarahalli
2022-11-09 17:05         ` Owen Hilyard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104110523.511367-8-juraj.linkes@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=kda@semihalf.com \
    --cc=lijuan.tu@intel.com \
    --cc=ohilyard@iol.unh.edu \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).