forked from TrueCloudLab/frostfs-testcases
Add logic to prepend ssh command with sudo.
This commit is contained in:
parent
5a2c528324
commit
4e49931c19
1 changed files with 4 additions and 0 deletions
|
@ -82,6 +82,8 @@ class HostClient:
|
||||||
|
|
||||||
@log_command
|
@log_command
|
||||||
def exec_with_confirmation(self, cmd: str, confirmation: list, verify=True, timeout=10) -> SSHCommand:
|
def exec_with_confirmation(self, cmd: str, confirmation: list, verify=True, timeout=10) -> SSHCommand:
|
||||||
|
if self.login and self.login != "root":
|
||||||
|
cmd = f"sudo {cmd}"
|
||||||
ssh_stdin, ssh_stdout, ssh_stderr = self.ssh_client.exec_command(cmd, timeout=timeout)
|
ssh_stdin, ssh_stdout, ssh_stderr = self.ssh_client.exec_command(cmd, timeout=timeout)
|
||||||
for line in confirmation:
|
for line in confirmation:
|
||||||
if not line.endswith('\n'):
|
if not line.endswith('\n'):
|
||||||
|
@ -195,6 +197,8 @@ class HostClient:
|
||||||
def _inner_exec(self, cmd: str, timeout: int) -> SSHCommand:
|
def _inner_exec(self, cmd: str, timeout: int) -> SSHCommand:
|
||||||
if not self.ssh_client:
|
if not self.ssh_client:
|
||||||
self.create_connection()
|
self.create_connection()
|
||||||
|
if self.login and self.login != "root":
|
||||||
|
cmd = f"sudo {cmd}"
|
||||||
for _ in range(self.SSH_CONNECTION_ATTEMPTS):
|
for _ in range(self.SSH_CONNECTION_ATTEMPTS):
|
||||||
try:
|
try:
|
||||||
_, stdout, stderr = self.ssh_client.exec_command(cmd, timeout=timeout)
|
_, stdout, stderr = self.ssh_client.exec_command(cmd, timeout=timeout)
|
||||||
|
|
Loading…
Reference in a new issue