Added sudo parameter for getting shell with elevated rights or not
This commit is contained in:
parent
917dc6f6d8
commit
59b4157991
2 changed files with 6 additions and 3 deletions
|
@ -61,10 +61,10 @@ class ServiceAttributes(ParsedAttributes):
|
||||||
class DockerHost(Host):
|
class DockerHost(Host):
|
||||||
"""Manages services hosted in Docker containers running on a local or remote machine."""
|
"""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)
|
host_attributes = HostAttributes.parse(self._config.attributes)
|
||||||
command_inspectors = []
|
command_inspectors = []
|
||||||
if host_attributes.sudo_shell:
|
if sudo:
|
||||||
command_inspectors.append(SudoInspector())
|
command_inspectors.append(SudoInspector())
|
||||||
|
|
||||||
if not host_attributes.ssh_login:
|
if not host_attributes.ssh_login:
|
||||||
|
|
|
@ -65,9 +65,12 @@ class Host(ABC):
|
||||||
return cli_config
|
return cli_config
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_shell(self) -> Shell:
|
def get_shell(self, sudo: bool = True) -> Shell:
|
||||||
"""Returns shell to this host.
|
"""Returns shell to this host.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
sudo: if True, run all commands in shell with elevated rights
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Shell that executes commands on this host.
|
Shell that executes commands on this host.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue