-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New spec "ls -lZ /var/lib/rsyslog" and the parser (#3618)
* feat: New spec "ls -lZ /var/lib/rsyslog" and the parser Signed-off-by: Huanhuan Li <[email protected]> * Update to full path import Signed-off-by: Huanhuan Li <[email protected]>
- Loading branch information
Showing
6 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. automodule:: insights.parsers.ls_var_lib_rsyslog | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
LsVarLibRsyslog - command ``ls -lZ /var/lib/rsyslog`` | ||
====================================================== | ||
""" | ||
|
||
|
||
from insights.core import CommandParser, FileListing | ||
from insights.core.plugins import parser | ||
from insights.specs import Specs | ||
|
||
|
||
@parser(Specs.ls_var_lib_rsyslog) | ||
class LsVarLibRsyslog(CommandParser, FileListing): | ||
""" | ||
Parses output of ``ls -lZ /var/lib/rsyslog`` command. | ||
Sample output:: | ||
total 4 | ||
-rw-------. 1 root root system_u:object_r:syslogd_var_lib_t:s0 127 Nov 30 03:40 imjournal.state | ||
Examples: | ||
>>> rsyslog_obj.dir_contains('/var/lib/rsyslog', 'imjournal.state') | ||
True | ||
>>> imjournal_entry = rsyslog_obj.dir_entry('/var/lib/rsyslog', 'imjournal.state') | ||
>>> imjournal_entry['se_type'] | ||
'syslogd_var_lib_t' | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import doctest | ||
|
||
from insights.parsers import ls_var_lib_rsyslog | ||
from insights.tests import context_wrap | ||
|
||
|
||
LS_VAR_LIB_RSYSLOG_1 = """ | ||
total 4 | ||
-rw-------. 1 root root system_u:object_r:syslogd_var_lib_t:s0 127 Nov 30 03:40 imjournal.state | ||
""" | ||
|
||
LS_VAR_LIB_RSYSLOG_2 = """ | ||
total 4 | ||
-rw-------. root root system_u:object_r:syslogd_var_lib_t:s0 imjournal.state | ||
""" | ||
|
||
|
||
def test_ls_var_lib_rsyslog(): | ||
rsyslog_obj = ls_var_lib_rsyslog.LsVarLibRsyslog(context_wrap(LS_VAR_LIB_RSYSLOG_2, path="insights_commands/ls_-lZ_.var.lib.rsyslog")) | ||
assert rsyslog_obj.files_of('/var/lib/rsyslog') == ['imjournal.state'] | ||
journal_obj = rsyslog_obj.dir_entry('/var/lib/rsyslog', 'imjournal.state') | ||
assert journal_obj is not None | ||
assert journal_obj['se_type'] == 'syslogd_var_lib_t' | ||
assert journal_obj['owner'] == 'root' | ||
|
||
|
||
def test_ls_var_lib_pcp_doc_examples(): | ||
env = { | ||
'rsyslog_obj': ls_var_lib_rsyslog.LsVarLibRsyslog(context_wrap(LS_VAR_LIB_RSYSLOG_1, path="insights_commands/ls_-lZ_.var.lib.rsyslog")), | ||
} | ||
failed, total = doctest.testmod(ls_var_lib_rsyslog, globs=env) | ||
assert failed == 0 |