forked from TrueCloudLab/frostfs-testlib
31 lines
904 B
Python
31 lines
904 B
Python
|
from typing import Optional
|
||
|
|
||
|
from frostfs_testlib.hosting.interfaces import Host
|
||
|
from frostfs_testlib.shell.interfaces import CommandOptions, Shell
|
||
|
|
||
|
|
||
|
class GenericCli(object):
|
||
|
def __init__(self, cli_name: str, host: Host) -> None:
|
||
|
self.host = host
|
||
|
self.cli_name = cli_name
|
||
|
|
||
|
def __call__(
|
||
|
self,
|
||
|
args: Optional[str] = "",
|
||
|
pipes: Optional[str] = "",
|
||
|
shell: Optional[Shell] = None,
|
||
|
options: Optional[CommandOptions] = None,
|
||
|
):
|
||
|
if not shell:
|
||
|
shell = self.host.get_shell()
|
||
|
|
||
|
cli_config = self.host.get_cli_config(self.cli_name, True)
|
||
|
extra_args = ""
|
||
|
exec_path = self.cli_name
|
||
|
if cli_config:
|
||
|
extra_args = " ".join(cli_config.extra_args)
|
||
|
exec_path = cli_config.exec_path
|
||
|
|
||
|
cmd = f"{exec_path} {args} {extra_args} {pipes}"
|
||
|
return shell.exec(cmd, options)
|