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
|
@ -10,9 +10,7 @@ class ParsedAttributes:
|
|||
def parse(cls, attributes: dict[str, Any]):
|
||||
# Pick attributes supported by the class
|
||||
field_names = set(field.name for field in fields(cls))
|
||||
supported_attributes = {
|
||||
key: value for key, value in attributes.items() if key in field_names
|
||||
}
|
||||
supported_attributes = {key: value for key, value in attributes.items() if key in field_names}
|
||||
return cls(**supported_attributes)
|
||||
|
||||
|
||||
|
@ -29,6 +27,7 @@ class CLIConfig:
|
|||
name: str
|
||||
exec_path: str
|
||||
attributes: dict[str, str] = field(default_factory=dict)
|
||||
extra_args: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -54,7 +54,7 @@ class Host(ABC):
|
|||
raise ValueError(f"Unknown service name: '{service_name}'")
|
||||
return service_config
|
||||
|
||||
def get_cli_config(self, cli_name: str) -> CLIConfig:
|
||||
def get_cli_config(self, cli_name: str, allow_empty: bool = False) -> CLIConfig:
|
||||
"""Returns config of CLI tool with specified name.
|
||||
|
||||
The CLI must be located on this host.
|
||||
|
@ -66,7 +66,7 @@ class Host(ABC):
|
|||
Config of the CLI tool.
|
||||
"""
|
||||
cli_config = self._cli_config_by_name.get(cli_name)
|
||||
if cli_config is None:
|
||||
if cli_config is None and not allow_empty:
|
||||
raise ValueError(f"Unknown CLI name: '{cli_name}'")
|
||||
return cli_config
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue