sssd_test_framework.utils.tools
Run various standard Linux commands on remote host.
Classes
|
Interface to getent command. |
|
Result of |
|
Result of |
|
Result of |
|
Result of |
|
|
|
Run various standard commands on remote host. |
|
Result of |
|
Result of |
|
Result of |
|
Interface to ssh-keygen command. |
|
Result of |
|
Result of 'getsubids'. |
|
Unix group. |
|
Generic Unix object. |
|
Unix user. |
- class sssd_test_framework.utils.tools.GetentUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Interface to getent command.
- Parameters:
host (MultihostHost) – Remote host.
- passwd(name: str | int, *, service: str | None = None) PasswdEntry | None
Call
getent passwd $name- Parameters:
name (str | int) – User name or id.
service (str | None) – Service used, defaults to None
- Returns:
passwd data, None if not found
- Return type:
PasswdEntry | None
- group(name: str | int, *, service: str | None = None) GroupEntry | None
Call
getent group $name- Parameters:
name (str | int) – Group name or id.
service (str | None) – Service used, defaults to None
- Returns:
group data, None if not found
- Return type:
PasswdEntry | None
- initgroups(name: str, *, service: str | None = None) InitgroupsEntry
Call
getent initgroups $nameIf
namedoes not exist, group list is empty. This is standard behavior ofgetent initgroups- Parameters:
name (str) – User name.
service (str | None) – Service used, defaults to None
- Returns:
Initgroups data
- Return type:
InitgroupsEntry
- netgroup(name: str, *, service: str | None = None) NetgroupEntry | None
Call
getent netgroup $name- Parameters:
name (str) – Netgroup name.
service (str | None) – Service used, defaults to None
- Returns:
Netgroup data, None if not found
- Return type:
NetgroupEntry | None
- hosts(name: str, *, service: str | None = None) HostsEntry
Call
getent hosts $name- Parameters:
name (str) – Hostname.
service (str | None) – Service used, defaults to None
- Returns:
Hosts data, None if not found
- Return type:
HostsEntry | None
- networks(name: str, *, service: str | None = None) NetworksEntry
Call
getent networks $name- Parameters:
name (str) – Network.
service (str | None) – Service used, defaults to None
- Returns:
Network data, None if not found
- Return type:
NetworksEntry | None
- services(name: str, *, service: str | None = None) ServicesEntry
Call
getent services $name- Parameters:
name (str) – Service.
service (str | None) – Service used, defaults to None
- Returns:
Service data, None if not found
- Return type:
ServicesEntry | None
- class sssd_test_framework.utils.tools.GroupEntry(name: str | None, password: str | None, gid: int | None, members: list[str])
Bases:
objectResult of
getent group- name: str | None
Group name.
- password: str | None
Group password.
- gid: int | None
Group id.
- members: list[str]
Group members.
- classmethod FromDict(d: dict[str, str | int | list[str] | None]) GroupEntry
- classmethod FromOutput(stdout: str) GroupEntry
- class sssd_test_framework.utils.tools.LinuxToolsUtils(*args, **kwargs)
Bases:
MultihostUtility[MultihostHost]Run various standard commands on remote host.
- Parameters:
host (MultihostHost) – Remote host.
- getent: GetentUtils
Run
getentcommand.
- getsubid(name: str, group: bool = False) SubIDEntry | None
Call
getsubids $name- Parameters:
name (str) – User name.
group (bool, defaults to False) – Get group range switch, optional
- Returns:
SubIDEntry data, None if not found
- Type:
SubIDEntry | None
- id(name: str | int) IdEntry | None
Run
idcommand.- Parameters:
name (str | int) – User name or id.
- Returns:
id data, None if not found
- Return type:
IdEntry | None
- grep(pattern: str, paths: str | list[str], args: list[str] | None = None) bool
Run
grepcommand.- Parameters:
pattern (str) – Pattern to match.
paths (str | list[str]) – Paths to search.
args (list[str] | None, optional) – Additional arguments to
grepcommand, defaults to None.
- Returns:
True if grep returned 0, False otherwise.
- Return type:
bool
- dnf(args: list[Any] | None = None) ProcessResult
Execute dnf commands with given arguments.
- Parameters:
args (list[Any] | None, optional) – Arguments to
dnf, defaults to None- Returns:
SSH Process result
- Return type:
ProcessResult
- faillock(args: list[Any]) ProcessResult
Execute faillock command. :param args: Arguments to
faillock:type args: list[Any] :return: SSH Process result :rtype: ProcessResult
- property sshkey: SSHKeyUtils
Execute ssh-keygen command. :return: SSHKeyUtils object. :rtype: SSHKeyUtils
- wait_for_condition(condition: str, body: str = '', timeout: int = 60) ProcessResult
Wait at maximum
timeoutseconds until theconditionis true. Executebodyafter each attempt. The condition is a bash expression, usually it is a single bash command that must succeed before a test can continue.Note
Internally, this expands to
timeout {time}s bash -c 'until {condition}; do : {body}; done'.Example usage@pytest.mark.topology(KnownTopology.LDAP) def test_just_condition(client: Client): client.sssd.domain["ldap_uri"] = "ldap://typo" client.sssd.start(debug_level=None, raise_on_error=False) assert client.sssd.default_domain r = client.tools.wait_for_condition(condition=f"sssctl domain-status {client.sssd.default_domain}") assert r.rc == 0 assert "LDAP: not connected" in r.stdout
- Parameters:
condition (str) – Command that is awaited
body (str, optional) – Body to be executed while waiting for condition, defaults to “”
timeout (int, optional) – How long should we try the command in seconds, defaults to 60
- Returns:
Proccess result
- Return type:
ProcessResult
- class sssd_test_framework.utils.tools.PasswdEntry(name: str | None, password: str | None, uid: int | None, gid: int | None, gecos: str | None, home: str | None, shell: str | None)
Bases:
objectResult of
getent passwd- name: str | None
User name.
- password: str | None
User password.
- uid: int | None
User id.
- gid: int | None
Group id.
- gecos: str | None
GECOS.
- home: str | None
Home directory.
- shell: str | None
Login shell.
- classmethod FromDict(d: dict[str, str | int | None]) PasswdEntry
- classmethod FromOutput(stdout: str) PasswdEntry
- class sssd_test_framework.utils.tools.UnixGroup(id: int | None, name: str | None)
Bases:
UnixObjectUnix group.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.
- class sssd_test_framework.utils.tools.UnixObject(id: int | None, name: str | None)
Bases:
objectGeneric Unix object.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.
- id: int | None
ID.
- name: str | None
Name.
- class sssd_test_framework.utils.tools.UnixUser(id: int | None, name: str | None)
Bases:
UnixObjectUnix user.
- Parameters:
id (int | None) – Object ID.
name (str | None) – Object name.