import abc
from enum import Enum, auto
from fortrace.core.virsh_domain import VirshDomain
from fortrace.utility.logger_helper import setup_logger
logger = setup_logger(__name__)
[docs]
class ServerFeedback(Enum):
FILE_NOT_FOUND = auto()
USER_HAS_NO_FILES = (
auto()
) # use this, if generated_files for the user is empty but a file retrieve is requested
[docs]
class GenericServerInteraction(abc.ABC):
"""Generic interface for the Generator to perform interactions with services offered by servers.
Attributes:
_login_data: dict containing username <-> password entries
"""
_login_data: dict[str, str]
def __init__(self, server: VirshDomain, config: dict):
"""Create an object for the generator component to simulate a server interaction
Args:
server: handle to the running server domain (pty should be free to use)
config: configuration of the server domain (plain config, no subsection of it)
"""
self._domain = server
self._config = config
self._server_config = self._config["domain"]["server"]
self._login_data = {}
def _extract_login_data(self):
# TODO: this seems to be redundant -> use dict directly?
for user in self._server_config.get("users", {}):
self._login_data[user["username"]] = user["password"]