xref: /dpdk/dts/framework/remote_session/__init__.py (revision 2b2f5a8aafb2970ac24747241d60614dcd771b14)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2023 PANTHEON.tech s.r.o.
3# Copyright(c) 2023 University of New Hampshire
4
5"""Remote interactive and non-interactive sessions.
6
7This package provides modules for managing remote connections to a remote host (node).
8
9The non-interactive sessions send commands and return their output and exit code.
10
11The interactive sessions open an interactive shell which is continuously open,
12allowing it to send and receive data within that particular shell.
13"""
14
15from framework.config import NodeConfiguration
16from framework.logger import DTSLogger
17
18from .interactive_remote_session import InteractiveRemoteSession
19from .remote_session import RemoteSession
20from .ssh_session import SSHSession
21
22
23def create_remote_session(
24    node_config: NodeConfiguration, name: str, logger: DTSLogger
25) -> RemoteSession:
26    """Factory for non-interactive remote sessions.
27
28    The function returns an SSH session, but will be extended if support
29    for other protocols is added.
30
31    Args:
32        node_config: The test run configuration of the node to connect to.
33        name: The name of the session.
34        logger: The logger instance this session will use.
35
36    Returns:
37        The SSH remote session.
38    """
39    return SSHSession(node_config, name, logger)
40
41
42def create_interactive_session(
43    node_config: NodeConfiguration, logger: DTSLogger
44) -> InteractiveRemoteSession:
45    """Factory for interactive remote sessions.
46
47    The function returns an interactive SSH session, but will be extended if support
48    for other protocols is added.
49
50    Args:
51        node_config: The test run configuration of the node to connect to.
52        logger: The logger instance this session will use.
53
54    Returns:
55        The interactive SSH remote session.
56    """
57    return InteractiveRemoteSession(node_config, logger)
58