Skip to content

Commit

Permalink
Tools: journalctl added
Browse files Browse the repository at this point in the history
  • Loading branch information
patriki01 committed Oct 23, 2023
1 parent c09aee2 commit 64ab31c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions sssd_test_framework/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import jc
from pytest_mh import MultihostHost, MultihostUtility
from pytest_mh.cli import CLIBuilder, CLIBuilderArgs
from pytest_mh.ssh import SSHProcess, SSHProcessResult
from pytest_mh.utils.fs import LinuxFileSystem

Expand Down Expand Up @@ -586,6 +587,53 @@ def teardown(self):

super().teardown()

def journalctl(
self,
*,
unit: str | None = None,
lines: int | None = None,
since: str | None = None,
reverse: bool = False,
no_pager: bool = False,
grep: str | None = None,
output: str | None = None,
identifier: str | None = None,
) -> SSHProcessResult:
"""
Execute journalctl with given arguments
:param unit: Show messages for the specified systemd unit, defaults to None
:type unit: str | None, optional
:param lines: Show the most recent journal events and limit the number of events shown, defaults to None
:type lines: int | None, optional
:param since: Start showing entries on or newer than the specified date, defaults to None
:type since: str | None, optional
:param reverse: Reverse output so that the newest entries are displayed first, defaults to False
:type reverse: bool, optional
:param no_pager: Do not pipe output into a pager, defaults to False
:type no_pager: bool, optional
:param grep: Filter output to entries where the MESSAGE= field matches the specified regular expression, defaults to None
:type grep: str | None, optional
:param output: Controls the formatting of the journal entries, defaults to None
:type output: str | None, optional
:param identifier: Show messages for the specified syslog identifier SYSLOG_IDENTIFIER, defaults to None
:type identifier: str | None, optional
:return: SSH process result
:rtype: SSHProcessResult
"""
cli: CLIBuilder = CLIBuilder(self.host.ssh)
args: CLIBuilderArgs = {
"unit": (cli.option.VALUE, unit),
"lines": (cli.option.VALUE, lines),
"since": (cli.option.VALUE, since),
"reverse": (cli.option.SWITCH, reverse),
"no-pager": (cli.option.SWITCH, no_pager),
"grep": (cli.option.VALUE, grep),
"output": (cli.option.VALUE, output),
"identifier": (cli.option.VALUE, identifier),
}
return self.host.ssh.exec(["journalctl"] + cli.args(args))


class KillCommand(object):
def __init__(self, host: MultihostHost, process: SSHProcess, pid: int) -> None:
Expand Down

0 comments on commit 64ab31c

Please sign in to comment.