diff --git a/docs/shared_parsers_catalog/ls_run_systemd.rst b/docs/shared_parsers_catalog/ls_run_systemd.rst new file mode 100644 index 000000000..f2b9e8a76 --- /dev/null +++ b/docs/shared_parsers_catalog/ls_run_systemd.rst @@ -0,0 +1,3 @@ +.. automodule:: insights.parsers.ls_run_systemd + :members: + :show-inheritance: diff --git a/docs/shared_parsers_catalog/ls_run_systemd_generator.rst b/docs/shared_parsers_catalog/ls_run_systemd_generator.rst deleted file mode 100644 index bf246301f..000000000 --- a/docs/shared_parsers_catalog/ls_run_systemd_generator.rst +++ /dev/null @@ -1,3 +0,0 @@ -.. automodule:: insights.parsers.ls_run_systemd_generator - :members: - :show-inheritance: diff --git a/insights/parsers/ls_run_systemd.py b/insights/parsers/ls_run_systemd.py new file mode 100644 index 000000000..9386bcecc --- /dev/null +++ b/insights/parsers/ls_run_systemd.py @@ -0,0 +1,77 @@ +""" +LsRunSystemd - command ``ls -lanRL /run/systemd`` +================================================= + +The ``ls -lanRL /run/systemd`` command provides information for the listing of the ``/run/systemd`` directory. + +Sample input is shown in the Examples. See ``FileListing`` class for +additional information. + +Sample output of ``ls -lanRL /run/systemd`` command is:: + + /run/systemd: + total 0 + drwxr-xr-x. 16 0 0 400 May 25 09:03 . + drwxr-xr-x. 33 0 0 940 May 25 09:03 .. + srwx------. 1 0 0 0 May 25 09:03 cgroups-agent + srw-------. 1 0 0 0 May 25 09:03 coredump + drwxr-xr-x. 4 0 0 140 May 25 09:03 generator + d---------. 3 0 0 160 May 25 09:03 inaccessible + srwxrwxrwx. 1 0 0 0 May 25 09:03 notify + srwxrwxrwx. 1 0 0 0 May 25 09:03 private + drwxr-xr-x. 2 0 0 40 May 25 09:03 system + drwxr-xr-x. 2 0 0 100 May 25 09:17 transient + + /run/systemd/generator: + total 12 + drwxr-xr-x. 4 0 0 140 May 25 09:03 . + drwxr-xr-x. 16 0 0 400 May 25 09:03 .. + -rw-r--r--. 1 0 0 254 May 25 09:03 boot.mount + -rw-r--r--. 1 0 0 230 May 25 09:03 dev-mapper-rhel\x2dswap.swap + drwxr-xr-x. 2 0 0 80 May 25 09:03 local-fs.target.requires + -rw-r--r--. 1 0 0 217 May 25 09:03 -.mount + drwxr-xr-x. 2 0 0 60 May 25 09:03 swap.target.requires + + /run/systemd/generator/local-fs.target.requires: + total 8 + drwxr-xr-x. 2 0 0 80 May 25 09:03 . + drwxr-xr-x. 4 0 0 140 May 25 09:03 .. + -rw-r--r--. 1 0 0 254 May 25 09:03 boot.mount + -rw-r--r--. 1 0 0 217 May 25 09:03 -.mount + + /run/systemd/generator/swap.target.requires: + total 4 + drwxr-xr-x. 2 0 0 60 May 25 09:03 . + drwxr-xr-x. 4 0 0 140 May 25 09:03 .. + -rw-r--r--. 1 0 0 230 May 25 09:03 dev-mapper-rhel\x2dswap.swap + + /run/systemd/system: + total 0 + drwxr-xr-x. 2 0 0 40 May 25 09:03 . + drwxr-xr-x. 16 0 0 400 May 25 09:03 .. + + /run/systemd/transient: + total 12 + drwxr-xr-x. 2 0 0 100 May 25 09:17 . + drwxr-xr-x. 16 0 0 400 May 25 09:03 .. + -rw-r--r--. 1 0 0 275 May 25 09:04 session-6.scope + -rw-r--r--. 1 0 0 275 May 25 09:17 session-7.scope + -rw-r--r--. 1 0 0 275 May 25 09:17 session-8.scope + +Examples: + >>> type(ls_run_systemd) + + >>> ls_run_systemd.files_of("/run/systemd/generator") == ['boot.mount', 'dev-mapper-rhel-swap.swap', '-.mount'] + True + >>> ls_run_systemd.dir_entry("/run/systemd/generator", "-.mount")["perms"] + 'rw-r--r--.' +""" + +from insights import parser, CommandParser, FileListing +from insights.specs import Specs + + +@parser(Specs.ls_run_systemd) +class LsRunSystemd(CommandParser, FileListing): + """Parses output of ``ls -lanRL /run/systemd`` command.""" + pass diff --git a/insights/parsers/ls_run_systemd_generator.py b/insights/parsers/ls_run_systemd_generator.py deleted file mode 100644 index 135204b2e..000000000 --- a/insights/parsers/ls_run_systemd_generator.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -LsRunSystemdGenerator - command ``ls -lan /run/systemd/generator`` -================================================================== - -The ``ls -lan /run/systemd/generator`` command provides information for only -the ``/run/systemd/generator`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 28 - drwxr-xr-x. 6 0 0 260 Aug 5 07:35 . - drwxr-xr-x. 18 0 0 440 Aug 5 07:35 .. - -rw-r--r--. 1 0 0 254 Aug 5 07:35 boot.mount - -rw-r--r--. 1 0 0 259 Aug 5 07:35 boot\x2dfake.mount - -rw-r--r--. 1 0 0 176 Aug 5 07:35 dev-mapper-rhel\x2dswap.swap - drwxr-xr-x. 2 0 0 100 Aug 5 07:35 local-fs.target.requires - -rw-r--r--. 1 0 0 217 Aug 5 07:35 -.mount - drwxr-xr-x. 2 0 0 60 Aug 5 07:35 nfs-server.service.d - drwxr-xr-x. 2 0 0 100 Aug 5 07:35 remote-fs.target.requires - -rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt_nfs3.mount - -rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt\x2dnfs1.mount - -rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt\x2dnfs2.mount - drwxr-xr-x. 2 0 0 60 Aug 5 07:35 swap.target.requires - -Examples: - - >>> ls.files_of("/run/systemd/generator") == ['boot.mount', 'boot-fake.mount', 'dev-mapper-rhel-swap.swap', '-.mount', 'root-mnt_nfs3.mount', 'root-mnt-nfs1.mount', 'root-mnt-nfs2.mount'] - True - >>> ls.dir_entry("/run/systemd/generator", '-.mount')['perms'] - 'rw-r--r--.' -""" - -from insights import parser, CommandParser, FileListing -from insights.specs import Specs - - -@parser(Specs.ls_run_systemd_generator) -class LsRunSystemdGenerator(CommandParser, FileListing): - """Parses output of ``ls -lan /run/systemd/generator`` command.""" - pass diff --git a/insights/specs/__init__.py b/insights/specs/__init__.py index bcb0b77cc..73bd1ad20 100644 --- a/insights/specs/__init__.py +++ b/insights/specs/__init__.py @@ -327,13 +327,16 @@ class Specs(SpecSet): ls_ocp_cni_openshift_sdn = RegistryPoint() ls_origin_local_volumes_pods = RegistryPoint() ls_osroot = RegistryPoint() - ls_run_systemd_generator = RegistryPoint() + ls_run_systemd = RegistryPoint() ls_R_var_lib_nova_instances = RegistryPoint() ls_sys_firmware = RegistryPoint() ls_usr_bin = RegistryPoint(filterable=True) ls_usr_lib64 = RegistryPoint(filterable=True) ls_usr_lib_systemd = RegistryPoint() + ls_usr_local_lib_systemd = RegistryPoint() + ls_usr_local_share_systemd = RegistryPoint() ls_usr_sbin = RegistryPoint(filterable=True) + ls_usr_share_systemd = RegistryPoint() ls_var_cache_pulp = RegistryPoint() ls_var_lib_mongodb = RegistryPoint() ls_var_lib_nova_instances = RegistryPoint() diff --git a/insights/specs/default.py b/insights/specs/default.py index aca069ba0..d198da19a 100644 --- a/insights/specs/default.py +++ b/insights/specs/default.py @@ -380,13 +380,16 @@ def httpd_cmd(broker): ls_ocp_cni_openshift_sdn = simple_command("/bin/ls -l /var/lib/cni/networks/openshift-sdn") ls_origin_local_volumes_pods = simple_command("/bin/ls -l /var/lib/origin/openshift.local.volumes/pods") ls_osroot = simple_command("/bin/ls -lan /") - ls_run_systemd_generator = simple_command("/bin/ls -lan /run/systemd/generator") + ls_run_systemd = simple_command("/bin/ls -lanRL /run/systemd") ls_R_var_lib_nova_instances = simple_command("/bin/ls -laR /var/lib/nova/instances") ls_sys_firmware = simple_command("/bin/ls -lanR /sys/firmware") ls_tmp = simple_command("/bin/ls -la /tmp") ls_usr_bin = simple_command("/bin/ls -lan /usr/bin") ls_usr_lib64 = simple_command("/bin/ls -lan /usr/lib64") ls_usr_lib_systemd = simple_command("/bin/ls -lanRL /usr/lib/systemd") + ls_usr_local_lib_systemd = simple_command("/bin/ls -lanRL /usr/local/lib/systemd") + ls_usr_local_share_systemd = simple_command("/bin/ls -lanRL /usr/local/share/systemd") + ls_usr_share_systemd = simple_command("/bin/ls -lanRL /usr/share/systemd") ls_var_cache_pulp = simple_command("/bin/ls -lan /var/cache/pulp") ls_var_lib_mongodb = simple_command("/bin/ls -la /var/lib/mongodb") ls_var_lib_nova_instances = simple_command("/bin/ls -laRZ /var/lib/nova/instances") diff --git a/insights/specs/insights_archive.py b/insights/specs/insights_archive.py index 75823df7b..9009c8894 100644 --- a/insights/specs/insights_archive.py +++ b/insights/specs/insights_archive.py @@ -122,7 +122,7 @@ class InsightsArchiveSpecs(Specs): ls_ocp_cni_openshift_sdn = simple_file("insights_commands/ls_-l_.var.lib.cni.networks.openshift-sdn") ls_origin_local_volumes_pods = simple_file("insights_commands/ls_-l_.var.lib.origin.openshift.local.volumes.pods") ls_osroot = simple_file("insights_commands/ls_-lan") - ls_run_systemd_generator = simple_file("insights_commands/ls_-lan_.run.systemd.generator") + ls_run_systemd = simple_file("insights_commands/ls_-lanRL_.run.systemd") ls_R_var_lib_nova_instances = simple_file("insights_commands/ls_-laR_.var.lib.nova.instances") ls_sys_firmware = simple_file("insights_commands/ls_-lanR_.sys.firmware") ls_tmp = simple_file("insights_commands/ls_-la_.tmp") diff --git a/insights/tests/parsers/test_ls_run_systemd.py b/insights/tests/parsers/test_ls_run_systemd.py new file mode 100644 index 000000000..ee79fd71a --- /dev/null +++ b/insights/tests/parsers/test_ls_run_systemd.py @@ -0,0 +1,83 @@ +import doctest + +from insights.parsers import ls_run_systemd +from insights.parsers.ls_run_systemd import LsRunSystemd +from insights.tests import context_wrap + + +# command output is shortened +LS_RUN_SYSTEMD = """ +/run/systemd: +total 0 +drwxr-xr-x. 16 0 0 400 May 25 09:03 . +drwxr-xr-x. 33 0 0 940 May 25 09:03 .. +srwx------. 1 0 0 0 May 25 09:03 cgroups-agent +srw-------. 1 0 0 0 May 25 09:03 coredump +drwxr-xr-x. 4 0 0 140 May 25 09:03 generator +d---------. 3 0 0 160 May 25 09:03 inaccessible +srwxrwxrwx. 1 0 0 0 May 25 09:03 notify +srwxrwxrwx. 1 0 0 0 May 25 09:03 private +drwxr-xr-x. 2 0 0 40 May 25 09:03 system +drwxr-xr-x. 2 0 0 100 May 25 09:17 transient + +/run/systemd/generator: +total 12 +drwxr-xr-x. 4 0 0 140 May 25 09:03 . +drwxr-xr-x. 16 0 0 400 May 25 09:03 .. +-rw-r--r--. 1 0 0 254 May 25 09:03 boot.mount +-rw-r--r--. 1 0 0 230 May 25 09:03 dev-mapper-rhel\x2dswap.swap +drwxr-xr-x. 2 0 0 80 May 25 09:03 local-fs.target.requires +-rw-r--r--. 1 0 0 217 May 25 09:03 -.mount +drwxr-xr-x. 2 0 0 60 May 25 09:03 swap.target.requires + +/run/systemd/generator/local-fs.target.requires: +total 8 +drwxr-xr-x. 2 0 0 80 May 25 09:03 . +drwxr-xr-x. 4 0 0 140 May 25 09:03 .. +-rw-r--r--. 1 0 0 254 May 25 09:03 boot.mount +-rw-r--r--. 1 0 0 217 May 25 09:03 -.mount + +/run/systemd/generator/swap.target.requires: +total 4 +drwxr-xr-x. 2 0 0 60 May 25 09:03 . +drwxr-xr-x. 4 0 0 140 May 25 09:03 .. +-rw-r--r--. 1 0 0 230 May 25 09:03 dev-mapper-rhel\x2dswap.swap + +/run/systemd/system: +total 0 +drwxr-xr-x. 2 0 0 40 May 25 09:03 . +drwxr-xr-x. 16 0 0 400 May 25 09:03 .. + +/run/systemd/transient: +total 12 +drwxr-xr-x. 2 0 0 100 May 25 09:17 . +drwxr-xr-x. 16 0 0 400 May 25 09:03 .. +-rw-r--r--. 1 0 0 275 May 25 09:04 session-6.scope +-rw-r--r--. 1 0 0 275 May 25 09:17 session-7.scope +-rw-r--r--. 1 0 0 275 May 25 09:17 session-8.scope +""".strip() + + +def test_ls_run_systemd(): + run_systemd = LsRunSystemd(context_wrap(LS_RUN_SYSTEMD)) + assert run_systemd + assert len(run_systemd.listings) == 6 + assert run_systemd.dirs_of("/run/systemd/generator") == [ + '.', '..', 'local-fs.target.requires', 'swap.target.requires' + ] + assert run_systemd.files_of("/run/systemd/generator") == [ + 'boot.mount', 'dev-mapper-rhel-swap.swap', '-.mount' + ] + assert run_systemd.listing_of("/run/systemd/generator")['-.mount'] == { + 'date': 'May 25 09:03', 'dir': '/run/systemd/generator', 'group': '0', 'links': 1, + 'name': '-.mount', 'owner': '0', 'perms': 'rw-r--r--.', + 'raw_entry': '-rw-r--r--. 1 0 0 217 May 25 09:03 -.mount', 'size': 217, 'type': '-' + } + + +def test_ls_osroot_doc_examples(): + env = { + 'ls_run_systemd': LsRunSystemd(context_wrap(LS_RUN_SYSTEMD)) + } + failed, total = doctest.testmod(ls_run_systemd, globs=env) + assert failed == 0 diff --git a/insights/tests/parsers/test_ls_run_systemd_generator.py b/insights/tests/parsers/test_ls_run_systemd_generator.py deleted file mode 100644 index 1985b8fac..000000000 --- a/insights/tests/parsers/test_ls_run_systemd_generator.py +++ /dev/null @@ -1,46 +0,0 @@ -import doctest - -from insights.parsers import ls_run_systemd_generator -from insights.parsers.ls_run_systemd_generator import LsRunSystemdGenerator -from insights.tests import context_wrap - -LS_RUN_SYSTEMD_GENERATOR = """ -total 28 -drwxr-xr-x. 6 0 0 260 Aug 5 07:35 . -drwxr-xr-x. 18 0 0 440 Aug 5 07:35 .. --rw-r--r--. 1 0 0 254 Aug 5 07:35 boot.mount --rw-r--r--. 1 0 0 259 Aug 5 07:35 boot\x2dfake.mount --rw-r--r--. 1 0 0 176 Aug 5 07:35 dev-mapper-rhel\x2dswap.swap -drwxr-xr-x. 2 0 0 100 Aug 5 07:35 local-fs.target.requires --rw-r--r--. 1 0 0 217 Aug 5 07:35 -.mount -drwxr-xr-x. 2 0 0 60 Aug 5 07:35 nfs-server.service.d -drwxr-xr-x. 2 0 0 100 Aug 5 07:35 remote-fs.target.requires --rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt_nfs3.mount --rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt\x2dnfs1.mount --rw-r--r--. 1 0 0 261 Aug 5 07:35 root-mnt\x2dnfs2.mount -drwxr-xr-x. 2 0 0 60 Aug 5 07:35 swap.target.requires -""".strip() - -PATH_OF_LS_RUN_SYSTEMD_GENERATOR = "insights_commands/ls_-lan_.run.systemd.generator" - - -def test_ls_run_systemd_generator(): - ls = LsRunSystemdGenerator(context_wrap(LS_RUN_SYSTEMD_GENERATOR, - path=PATH_OF_LS_RUN_SYSTEMD_GENERATOR)) - dir_path = "/run/systemd/generator" - assert dir_path in ls - assert len(ls.files_of(dir_path)) == 7 - assert ls.files_of(dir_path) == ['boot.mount', 'boot-fake.mount', 'dev-mapper-rhel-swap.swap', - '-.mount', 'root-mnt_nfs3.mount', 'root-mnt-nfs1.mount', 'root-mnt-nfs2.mount'] - assert ls.dirs_of(dir_path) == ['.', '..', 'local-fs.target.requires', 'nfs-server.service.d', - 'remote-fs.target.requires', 'swap.target.requires'] - assert ls.listing_of(dir_path)['-.mount'] == {'type': '-', 'perms': 'rw-r--r--.', 'links': 1, 'owner': '0', 'group': '0', 'size': 217, 'date': 'Aug 5 07:35', 'name': '-.mount', 'raw_entry': '-rw-r--r--. 1 0 0 217 Aug 5 07:35 -.mount', 'dir': dir_path} - - -def test_ls_osroot_doc_examples(): - env = { - 'ls': LsRunSystemdGenerator(context_wrap(LS_RUN_SYSTEMD_GENERATOR, - path=PATH_OF_LS_RUN_SYSTEMD_GENERATOR)), - } - failed, total = doctest.testmod(ls_run_systemd_generator, globs=env) - assert failed == 0