From 59b41579915c3750e3b98e7e859053a1c3bdee0b Mon Sep 17 00:00:00 2001 From: "d.anurin" Date: Wed, 12 Jul 2023 09:41:17 +0300 Subject: [PATCH] Added sudo parameter for getting shell with elevated rights or not --- src/frostfs_testlib/hosting/docker_host.py | 4 ++-- src/frostfs_testlib/hosting/interfaces.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frostfs_testlib/hosting/docker_host.py b/src/frostfs_testlib/hosting/docker_host.py index 3934d9f..94ee2ff 100644 --- a/src/frostfs_testlib/hosting/docker_host.py +++ b/src/frostfs_testlib/hosting/docker_host.py @@ -61,10 +61,10 @@ class ServiceAttributes(ParsedAttributes): class DockerHost(Host): """Manages services hosted in Docker containers running on a local or remote machine.""" - def get_shell(self) -> Shell: + def get_shell(self, sudo: bool = True) -> Shell: host_attributes = HostAttributes.parse(self._config.attributes) command_inspectors = [] - if host_attributes.sudo_shell: + if sudo: command_inspectors.append(SudoInspector()) if not host_attributes.ssh_login: diff --git a/src/frostfs_testlib/hosting/interfaces.py b/src/frostfs_testlib/hosting/interfaces.py index cdd3379..b4f67fb 100644 --- a/src/frostfs_testlib/hosting/interfaces.py +++ b/src/frostfs_testlib/hosting/interfaces.py @@ -65,9 +65,12 @@ class Host(ABC): return cli_config @abstractmethod - def get_shell(self) -> Shell: + def get_shell(self, sudo: bool = True) -> Shell: """Returns shell to this host. + Args: + sudo: if True, run all commands in shell with elevated rights + Returns: Shell that executes commands on this host. """