forked from TrueCloudLab/frostfs-testlib
Add GenericCli utility
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
4f3814690e
commit
751381cd60
8 changed files with 80 additions and 71 deletions
|
@ -1,4 +1,5 @@
|
|||
from frostfs_testlib.cli.frostfs_adm import FrostfsAdm
|
||||
from frostfs_testlib.cli.frostfs_authmate import FrostfsAuthmate
|
||||
from frostfs_testlib.cli.frostfs_cli import FrostfsCli
|
||||
from frostfs_testlib.cli.generic_cli import GenericCli
|
||||
from frostfs_testlib.cli.neogo import NeoGo, NetworkType
|
||||
|
|
30
src/frostfs_testlib/cli/generic_cli.py
Normal file
30
src/frostfs_testlib/cli/generic_cli.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue