From 9da59dad2939b1b3f1d2f803dc504791e956c62f Mon Sep 17 00:00:00 2001 From: Xiangce Liu Date: Mon, 16 Dec 2024 11:41:33 +0800 Subject: [PATCH] chore: remove planned deprecations for bumping 3.5.0 - RHINENG-14089 - remove the relevant tests and doc entries - and commit update done by black pre-commit hooks - it will break some exiting tests in rules, hence, tests need to be updated accordingly Signed-off-by: Xiangce Liu --- docs/api.rst | 26 +- .../dse_ldif_simple.rst | 3 - docs/shared_parsers_catalog/ldif_config.rst | 3 - docs/shared_parsers_catalog/ls_disk.rst | 3 - .../ls_docker_volumes.rst | 3 - docs/shared_parsers_catalog/ls_edac_mc.rst | 3 - docs/shared_parsers_catalog/ls_etc.rst | 3 - .../ls_ipa_idoverride_memberof.rst | 3 - docs/shared_parsers_catalog/ls_krb5_sssd.rst | 3 - .../ls_lib_firmware.rst | 3 - .../ls_ocp_cni_openshift_sdn.rst | 3 - .../ls_origin_local_volumes_pods.rst | 3 - docs/shared_parsers_catalog/ls_osroot.rst | 3 - .../ls_rsyslog_errorfile.rst | 3 - .../ls_systemd_units.rst | 3 - docs/shared_parsers_catalog/ls_tmp.rst | 3 - docs/shared_parsers_catalog/ls_usr_bin.rst | 3 - docs/shared_parsers_catalog/ls_usr_lib64.rst | 3 - docs/shared_parsers_catalog/ls_usr_sbin.rst | 3 - .../ls_var_cache_pulp.rst | 3 - .../ls_var_lib_mongodb.rst | 3 - .../ls_var_lib_nova_instances.rst | 3 - .../shared_parsers_catalog/ls_var_lib_pcp.rst | 3 - .../shared_parsers_catalog/ls_var_lib_rpm.rst | 3 - .../ls_var_lib_rsyslog.rst | 3 - docs/shared_parsers_catalog/ls_var_log.rst | 3 - .../ls_var_opt_mssql.rst | 3 - .../ls_var_opt_mssql_log.rst | 3 - docs/shared_parsers_catalog/ls_var_run.rst | 3 - .../ls_var_spool_clientmq.rst | 3 - .../ls_var_spool_postfix_maildrop.rst | 3 - docs/shared_parsers_catalog/ls_var_tmp.rst | 3 - .../ls_var_www_perms.rst | 3 - insights/__init__.py | 7 +- insights/core/__init__.py | 176 --- insights/core/spec_factory.py | 69 -- insights/parsers/dse_ldif_simple.py | 94 -- insights/parsers/ldif_config.py | 139 --- insights/parsers/ls_disk.py | 76 -- insights/parsers/ls_docker_volumes.py | 56 - insights/parsers/ls_edac_mc.py | 43 - insights/parsers/ls_etc.py | 129 -- .../parsers/ls_ipa_idoverride_memberof.py | 41 - insights/parsers/ls_krb5_sssd.py | 43 - insights/parsers/ls_lib_firmware.py | 67 - insights/parsers/ls_ocp_cni_openshift_sdn.py | 45 - .../parsers/ls_origin_local_volumes_pods.py | 45 - insights/parsers/ls_osroot.py | 64 - insights/parsers/ls_systemd_units.py | 92 -- insights/parsers/ls_tmp.py | 65 - insights/parsers/ls_usr_bin.py | 66 - insights/parsers/ls_usr_lib64.py | 52 - insights/parsers/ls_usr_sbin.py | 82 -- insights/parsers/ls_var_cache_pulp.py | 46 - insights/parsers/ls_var_lib_mongodb.py | 48 - insights/parsers/ls_var_lib_nova_instances.py | 135 -- insights/parsers/ls_var_lib_pcp.py | 47 - insights/parsers/ls_var_lib_rpm.py | 45 - insights/parsers/ls_var_lib_rsyslog.py | 36 - insights/parsers/ls_var_log.py | 64 - insights/parsers/ls_var_opt_mssql.py | 37 - insights/parsers/ls_var_opt_mssql_log.py | 32 - insights/parsers/ls_var_run.py | 52 - insights/parsers/ls_var_spool_clientmq.py | 47 - .../parsers/ls_var_spool_postfix_maildrop.py | 48 - insights/parsers/ls_var_tmp.py | 52 - insights/parsers/ls_var_www_perms.py | 55 - insights/parsers/rpm_v_packages.py | 78 +- insights/specs/__init__.py | 37 +- insights/specs/core3_archive.py | 7 +- insights/specs/default.py | 53 +- insights/specs/insights_archive.py | 259 ++-- .../{ => core}/test_get_dependency_specs.py | 68 +- .../tests/parsers/test_dse_ldif_simple.py | 207 ---- insights/tests/parsers/test_ldif_config.py | 227 ---- insights/tests/parsers/test_ls_disk.py | 75 -- .../tests/parsers/test_ls_docker_volumes.py | 54 - insights/tests/parsers/test_ls_edac_mc.py | 29 - insights/tests/parsers/test_ls_etc.py | 265 ---- .../tests/parsers/test_ls_file_permissions.py | 260 ++++ .../test_ls_ipa_idoverride_memberof.py | 27 - insights/tests/parsers/test_ls_krb5_sssd.py | 29 - .../tests/parsers/test_ls_lib_firmware.py | 89 -- .../parsers/test_ls_ocp_nci_openshift_sdn.py | 35 - .../test_ls_origin_local_volumes_pods.py | 34 - insights/tests/parsers/test_ls_osroot.py | 51 - .../parsers/test_ls_rsyslog_errorfile.py | 41 - .../tests/parsers/test_ls_systemd_units.py | 1084 ----------------- insights/tests/parsers/test_ls_tmp.py | 48 - insights/tests/parsers/test_ls_usr_bin.py | 52 - insights/tests/parsers/test_ls_usr_lib64.py | 42 - insights/tests/parsers/test_ls_usr_sbin.py | 52 - .../tests/parsers/test_ls_var_cache_pulp.py | 31 - .../tests/parsers/test_ls_var_lib_mongodb.py | 31 - .../parsers/test_ls_var_lib_nova_instances.py | 87 -- insights/tests/parsers/test_ls_var_lib_pcp.py | 29 - insights/tests/parsers/test_ls_var_lib_rpm.py | 62 - .../tests/parsers/test_ls_var_lib_rsyslog.py | 32 - insights/tests/parsers/test_ls_var_log.py | 150 --- .../tests/parsers/test_ls_var_opt_mssql.py | 57 - .../parsers/test_ls_var_opt_mssql_log.py | 32 - insights/tests/parsers/test_ls_var_run.py | 44 - .../parsers/test_ls_var_spool_clientmq.py | 31 - .../test_ls_var_spool_postfix_maildrop.py | 28 - insights/tests/parsers/test_ls_var_tmp.py | 40 - .../tests/parsers/test_ls_var_www_perms.py | 71 -- insights/tests/parsers/test_rpm_v_packages.py | 83 +- insights/tests/test_file_listing.py | 317 ----- insights/tests/test_file_permissions.py | 128 -- 109 files changed, 527 insertions(+), 6246 deletions(-) delete mode 100644 docs/shared_parsers_catalog/dse_ldif_simple.rst delete mode 100644 docs/shared_parsers_catalog/ldif_config.rst delete mode 100644 docs/shared_parsers_catalog/ls_disk.rst delete mode 100644 docs/shared_parsers_catalog/ls_docker_volumes.rst delete mode 100644 docs/shared_parsers_catalog/ls_edac_mc.rst delete mode 100644 docs/shared_parsers_catalog/ls_etc.rst delete mode 100644 docs/shared_parsers_catalog/ls_ipa_idoverride_memberof.rst delete mode 100644 docs/shared_parsers_catalog/ls_krb5_sssd.rst delete mode 100644 docs/shared_parsers_catalog/ls_lib_firmware.rst delete mode 100644 docs/shared_parsers_catalog/ls_ocp_cni_openshift_sdn.rst delete mode 100644 docs/shared_parsers_catalog/ls_origin_local_volumes_pods.rst delete mode 100644 docs/shared_parsers_catalog/ls_osroot.rst delete mode 100644 docs/shared_parsers_catalog/ls_rsyslog_errorfile.rst delete mode 100644 docs/shared_parsers_catalog/ls_systemd_units.rst delete mode 100644 docs/shared_parsers_catalog/ls_tmp.rst delete mode 100644 docs/shared_parsers_catalog/ls_usr_bin.rst delete mode 100644 docs/shared_parsers_catalog/ls_usr_lib64.rst delete mode 100644 docs/shared_parsers_catalog/ls_usr_sbin.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_cache_pulp.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_lib_mongodb.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_lib_nova_instances.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_lib_pcp.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_lib_rpm.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_lib_rsyslog.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_log.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_opt_mssql.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_opt_mssql_log.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_run.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_spool_clientmq.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_spool_postfix_maildrop.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_tmp.rst delete mode 100644 docs/shared_parsers_catalog/ls_var_www_perms.rst delete mode 100644 insights/parsers/dse_ldif_simple.py delete mode 100644 insights/parsers/ldif_config.py delete mode 100644 insights/parsers/ls_disk.py delete mode 100644 insights/parsers/ls_docker_volumes.py delete mode 100644 insights/parsers/ls_edac_mc.py delete mode 100644 insights/parsers/ls_etc.py delete mode 100644 insights/parsers/ls_ipa_idoverride_memberof.py delete mode 100644 insights/parsers/ls_krb5_sssd.py delete mode 100644 insights/parsers/ls_lib_firmware.py delete mode 100644 insights/parsers/ls_ocp_cni_openshift_sdn.py delete mode 100644 insights/parsers/ls_origin_local_volumes_pods.py delete mode 100644 insights/parsers/ls_osroot.py delete mode 100644 insights/parsers/ls_systemd_units.py delete mode 100644 insights/parsers/ls_tmp.py delete mode 100644 insights/parsers/ls_usr_bin.py delete mode 100644 insights/parsers/ls_usr_lib64.py delete mode 100644 insights/parsers/ls_usr_sbin.py delete mode 100644 insights/parsers/ls_var_cache_pulp.py delete mode 100644 insights/parsers/ls_var_lib_mongodb.py delete mode 100644 insights/parsers/ls_var_lib_nova_instances.py delete mode 100644 insights/parsers/ls_var_lib_pcp.py delete mode 100644 insights/parsers/ls_var_lib_rpm.py delete mode 100644 insights/parsers/ls_var_lib_rsyslog.py delete mode 100644 insights/parsers/ls_var_log.py delete mode 100644 insights/parsers/ls_var_opt_mssql.py delete mode 100644 insights/parsers/ls_var_opt_mssql_log.py delete mode 100644 insights/parsers/ls_var_run.py delete mode 100644 insights/parsers/ls_var_spool_clientmq.py delete mode 100644 insights/parsers/ls_var_spool_postfix_maildrop.py delete mode 100644 insights/parsers/ls_var_tmp.py delete mode 100644 insights/parsers/ls_var_www_perms.py rename insights/tests/{ => core}/test_get_dependency_specs.py (66%) delete mode 100644 insights/tests/parsers/test_dse_ldif_simple.py delete mode 100644 insights/tests/parsers/test_ldif_config.py delete mode 100644 insights/tests/parsers/test_ls_disk.py delete mode 100644 insights/tests/parsers/test_ls_docker_volumes.py delete mode 100644 insights/tests/parsers/test_ls_edac_mc.py delete mode 100644 insights/tests/parsers/test_ls_etc.py create mode 100644 insights/tests/parsers/test_ls_file_permissions.py delete mode 100644 insights/tests/parsers/test_ls_ipa_idoverride_memberof.py delete mode 100644 insights/tests/parsers/test_ls_krb5_sssd.py delete mode 100644 insights/tests/parsers/test_ls_lib_firmware.py delete mode 100644 insights/tests/parsers/test_ls_ocp_nci_openshift_sdn.py delete mode 100644 insights/tests/parsers/test_ls_origin_local_volumes_pods.py delete mode 100644 insights/tests/parsers/test_ls_osroot.py delete mode 100644 insights/tests/parsers/test_ls_rsyslog_errorfile.py delete mode 100644 insights/tests/parsers/test_ls_systemd_units.py delete mode 100644 insights/tests/parsers/test_ls_tmp.py delete mode 100644 insights/tests/parsers/test_ls_usr_bin.py delete mode 100644 insights/tests/parsers/test_ls_usr_lib64.py delete mode 100644 insights/tests/parsers/test_ls_usr_sbin.py delete mode 100644 insights/tests/parsers/test_ls_var_cache_pulp.py delete mode 100644 insights/tests/parsers/test_ls_var_lib_mongodb.py delete mode 100644 insights/tests/parsers/test_ls_var_lib_nova_instances.py delete mode 100644 insights/tests/parsers/test_ls_var_lib_pcp.py delete mode 100644 insights/tests/parsers/test_ls_var_lib_rpm.py delete mode 100644 insights/tests/parsers/test_ls_var_lib_rsyslog.py delete mode 100644 insights/tests/parsers/test_ls_var_log.py delete mode 100644 insights/tests/parsers/test_ls_var_opt_mssql.py delete mode 100644 insights/tests/parsers/test_ls_var_opt_mssql_log.py delete mode 100644 insights/tests/parsers/test_ls_var_run.py delete mode 100644 insights/tests/parsers/test_ls_var_spool_clientmq.py delete mode 100644 insights/tests/parsers/test_ls_var_spool_postfix_maildrop.py delete mode 100644 insights/tests/parsers/test_ls_var_tmp.py delete mode 100644 insights/tests/parsers/test_ls_var_www_perms.py delete mode 100644 insights/tests/test_file_listing.py delete mode 100644 insights/tests/test_file_permissions.py diff --git a/docs/api.rst b/docs/api.rst index 981e465ed4..be931e7dd4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -92,7 +92,7 @@ that are executed. Contexts enable different collection methods for data for each unique context, and also provide a default set of data sources that are common among one or more contexts. All available contexts are defined in the module :py:mod:`insights.core.context`. - + .. _datasources-ref: Data Sources @@ -115,7 +115,7 @@ The Insights client stores that information as a file in an archive. When the client uploads that information to the Red Hat Insights service it is processed in the :py:class:`insights.core.context.HostArchiveContext`. Because the ``fdisk -l`` data is now in a file in the archive the data sources -defined in :py:class:`insights.specs.insights_archive.InsightsArchiveSpecs` are +defined in :py:class:`insights.specs.insights_archive.InsightsArchiveSpecs` are used instead. In this case Insights will collect the data from a file named ``insights_commands/fdisk_-l``. @@ -163,13 +163,13 @@ of data sources are listed below. :py:func:`insights.core.spec_factory.simple_file` simple_file collects the contents of files, for example:: - + auditd_conf = simple_file("/etc/audit/auditd.conf") audit_log = simple_file("/var/log/audit/audit.log") :py:func:`insights.core.spec_factory.simple_command` simple_command collects the output from a command, for example:: - + blkid = simple_command("/sbin/blkid -c /dev/null") brctl_show = simple_command("/usr/sbin/brctl show") @@ -178,7 +178,7 @@ of data sources are listed below. glob_file also can take a list of patterns as well as an ignore keyword arg that is a regular expression telling it which of the matching files to throw out, for example:: - + httpd_conf = glob_file(["/etc/httpd/conf/httpd.conf", "/etc/httpd/conf.d/*.conf"]) ifcfg = glob_file("/etc/sysconfig/network-scripts/ifcfg-*") rabbitmq_logs = glob_file("/var/log/rabbitmq/rabbit@*.log", ignore=".*rabbit@.*(? ./grub.conf - | brw-rw----. 1 0 6 253, 10 Aug 4 16:56 dm-10 - | crw-------. 1 0 0 10, 236 Jul 25 10:00 control - - Examples: - >>> file_listing - - >>> '/example_dir' in file_listing - True - >>> file_listing.dir_contains('/example_dir', 'menu.lst') - True - >>> dir = file_listing.listing_of('/example_dir') - >>> dir['.']['type'] - 'd' - >>> dir['config-3.10.0-229.14.q.el7.x86_64']['size'] - 123891 - >>> dir['dm-10']['major'] - 253 - >>> dir['menu.lst']['link'] - './grub.conf' - """ - - def __init__(self, context): - # Try to pull out the directory path from the command line, in case - # we're doing an ls on only one directory (which then doesn't list - # the directory name in the output). Obviously if we don't have the - # '-R' flag we should grab this but it's probably not worth parsing - # the flags to ls for this. - deprecated( - FileListing, "Please use the :class:`insights.parsers.ls.FileListing instead.", "3.5.0" - ) - self.first_path = None - path_re = re.compile(r'ls_-\w+(?P.*)$') - match = path_re.search(context.path) - if match: - fpath = match.group('path') - self.first_path = '/' if not fpath else fpath.replace('.', '/').replace('_', ' ') - super(FileListing, self).__init__(context) - - def parse_content(self, content): - """ - Called automatically to process the directory listing(s) contained in - the content. - """ - self.listings = ls_parser.parse(content, self.first_path) - - # No longer need the first path found, if any. - delattr(self, 'first_path') - - # Now some helpers to make some things easier: - def __contains__(self, directory): - """ - Does the given directory appear in this set of directory listings? - """ - return directory in self.listings - - def files_of(self, directory): - """ - The list of non-special files (i.e. not block or character files) - in the given directory. - """ - return self.listings[directory]['files'] - - def dirs_of(self, directory): - """ - The list of subdirectories in the given directory. - """ - return self.listings[directory]['dirs'] - - def specials_of(self, directory): - """ - The list of block and character special files in the given directory. - """ - return self.listings[directory]['specials'] - - def total_of(self, directory): - """ - The total blocks of storage consumed by entries in this directory. - """ - return self.listings[directory]['total'] - - def listing_of(self, directory): - """ - The listing of this directory, in a dictionary by entry name. All - entries contain the original line as is in the 'raw_entry' key. - Entries that can be parsed then have fields as described in the class - description above. - """ - return self.listings[directory]['entries'] - - def dir_contains(self, directory, name): - """ - Does this directory contain this entry name? - """ - return name in self.listings[directory]['entries'] - - def dir_entry(self, directory, name): - """ - The parsed data for the given entry name in the given directory. - """ - return self.listings[directory]['entries'][name] - - def path_entry(self, path): - """ - The parsed data given a path, which is separated into its directory - and entry name. - """ - if path[0] != '/': - return None - path_parts = path.split('/') - # Note that here the first element will be '' because it's before the - # first separator. That's OK, the join puts it back together. - directory = '/'.join(path_parts[:-1]) - name = path_parts[-1] - if directory not in self.listings: - return None - if name not in self.listings[directory]['entries']: - return None - return self.listings[directory]['entries'][name] diff --git a/insights/core/spec_factory.py b/insights/core/spec_factory.py index 269e91e91e..a0992ae307 100644 --- a/insights/core/spec_factory.py +++ b/insights/core/spec_factory.py @@ -23,7 +23,6 @@ from insights.core.plugins import component, datasource, is_datasource from insights.core.serde import deserializer, serializer from insights.util import fs, streams, which -from insights.util import deprecated from insights.util.mangle import mangle_command log = logging.getLogger(__name__) @@ -229,52 +228,6 @@ def __repr__(self): return '%s("%r")' % (self.__class__.__name__, self.path) -class MetadataProvider(FileProvider): - """ - .. warning:: - This Class is deprecated and will be removed from 3.5.0. - Please collect built-in file by using datasource spec directly, see - :mod:`insights.specs.datasources.client_metadata`. - - Class used for insights-core built-in files. These files should not - be filtered, redacted or blocked. - """ - - def __init__(self, relative_path, root="/", save_as=None, ds=None, ctx=None, cleaner=None): - deprecated( - MetadataProvider, - "Please collect the built-in file via datasource spec instead.", - "3.5.0", - ) - super(MetadataProvider, self).__init__(relative_path, root, save_as, ds, ctx, cleaner) - - def _stream(self): - """ - Returns a generator of lines instead of a list of lines. - """ - if self._exception: - raise self._exception - try: - with safe_open(self.path, "r", encoding=encoding, errors="surrogateescape") as f: - yield f - except StopIteration: - raise - except Exception as ex: - self._exception = ex - raise ContentException(str(ex)) - - def validate(self): - # Validate built-in metedata files only when insights-run - if not isinstance(self.ctx, HostContext): - super(MetadataProvider, self).validate() - # But DO NOT validate them when core-collecting - - def load(self): - self.loaded = True - with safe_open(self.path, "r", encoding=encoding, errors="surrogateescape") as f: - return [l.rstrip("\n") for l in f] - - class RawFileProvider(FileProvider): """ Class used in datasources that returns the contents of a file a single @@ -1683,28 +1636,6 @@ def deserialize_datasource_provider(_type, data, root, ctx, ds): return res -@serializer(MetadataProvider) -def serialize_metadata_provider(obj, root): - # Built-in metadata files are put in the root instead of '/data' - root = os.path.dirname(root) if os.path.basename(root) == 'data' else root - rel = obj.relative_path - if obj.save_as: - rel = obj.save_as - if obj.save_as.endswith("/"): - rel = os.path.join(rel, os.path.basename(obj.relative_path)) - dst = os.path.join(root, obj.relative_path) - obj.write(dst) - return {"relative_path": rel, "save_as": obj.save_as} - - -@deserializer(MetadataProvider) -def deserialize_metadata_provider(_type, data, root, ctx, ds): - # Built-in metadata files are put in the root instead of '/data' - root = os.path.dirname(root) if os.path.basename(root) == 'data' else root - res = SerializedOutputProvider(data["relative_path"], root=root, ctx=ctx, ds=ds) - return res - - @serializer(ContainerFileProvider) def serialize_container_file_output(obj, root): rel = os.path.join("insights_containers", obj.relative_path) diff --git a/insights/parsers/dse_ldif_simple.py b/insights/parsers/dse_ldif_simple.py deleted file mode 100644 index 52e0b960c9..0000000000 --- a/insights/parsers/dse_ldif_simple.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -""" -DseLdifSimple - file ``/etc/dirsrv/*/dse.ldif`` -=============================================== -""" - - -from insights import Parser, parser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.dse_ldif) -class DseLdifSimple(Parser, dict): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.dse_ldif.DseLDIF` instead. - - Parse the attributes out of the filtered lines of the dse.ldif file into - dict[attribute name] = attribute value. - - Please note the difference between the LDIF format and this parser. - - The file dse.ldif is in the LDIF format (see ``man 5 ldif``). LDIF contains - multi-row records where each record is identified by a ``dn:`` line ("dn" - as in "distinguished name") and the record's other lines are attributes. - Attributes may also have base64-encoded values, multiline values, and - file-stored values. - - The parser processes lines independently without tracking what the line is - and which record it belongs to. Only plaintext single-line values are - supported. - - This allows for filterable, efficient, and privacy-preserving processing of - attributes whose names are valid only in a single distinguished name, and - whose values are single-line plaintext only. - - Sample input data:: - - dn: cn=config - nsslapd-securePort: 636 - nsslapd-security: on - - dn: cn=encryption,cn=config - sslVersionMin: SSLv3 - sslVersionMax: TLS1.1 - nsSSL3: on - - Examples: - >>> type(dse_ldif_simple) - - >>> dse_ldif_simple["nsslapd-security"] - 'on' - >>> "sslVersionMin" in dse_ldif_simple - True - >>> dict(dse_ldif_simple)["nsSSL3"] - 'on' - - """ - - def __init__(self, *args, **kwargs): - deprecated(DseLdifSimple, "Please use the :class:`insights.parsers.dse_ldif.DseLDIF` instead.", "3.5.0") - super(DseLdifSimple, self).__init__(*args, **kwargs) - - def parse_content(self, content): - data = {} - for line in content: - if line.startswith("#"): - # lines beginning with # are ignored - continue - if ":" not in line: - # only attribute: value lines supported - continue - if line.startswith(" "): - # multi-line values not supported - continue - attr_name, attr_value = line.split(":", 1) - if attr_value.startswith(":"): - # base64-encrypted values not supported - continue - if attr_value.startswith("<"): - # file-backed values not supported - continue - - # Whitespace at either side of the value has no effect. - attr_value = attr_value.strip() - - # If the same attribute is declared multiple times, the first - # instance takes into effect, the rest is ignored by the 386 - # Directory Server. - if attr_name not in data: - data[attr_name] = attr_value - self.update(data) diff --git a/insights/parsers/ldif_config.py b/insights/parsers/ldif_config.py deleted file mode 100644 index 7fc4280652..0000000000 --- a/insights/parsers/ldif_config.py +++ /dev/null @@ -1,139 +0,0 @@ -""" -LDIF Configuration - file ``/etc/dirsrv/slapd-*/dse.ldif`` -========================================================== -""" -from insights.core import Parser -from insights.core.exceptions import SkipComponent -from insights.core.plugins import parser -from insights.parsers import keyword_search -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ldif_config) -class LDIFParser(Parser, list): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.dse_ldif.DseLDIF` instead. - - Parse the content of the directory server configuration of the - ``/etc/dirsrv/slapd-*/dse.ldif`` file. - - The file dse.ldif is in the LDIF format. LDIF contains multi-row records - where each record is identified by a ``dn:`` line ("dn" as in "distinguished - name") and the record's other lines are attributes. The value may be specified - as UTF-8 text or as base64 encoded data, or a URI may be provided to the - location of the attribute value. - - .. note:: - 1. This parser unwraps the multiple 'aci:' lines to a single line. - 2. This parser only keeps the last value of a multiple keys and - discrads the others before it. - - Sample output:: - - dn: - aci: (targetattr != "aci")(version 3.0; aci "rootdse anon read access"; allow( - read,search,compare) userdn="ldap:///anyone";) - aci: (target = "ldap:///cn=automember rebuild membership,cn=tasks,cn=config")( - ,cn=permissions,cn=pbac,dc=idm";) - createTimestamp: 20201026161200Z - creatorsName: cn=server,cn=plugins,cn=config - modifiersName: cn=Directory Manager - modifyTimestamp: 20210608144722Z - nsslapd-return-default-opattr: namingContexts - nsslapd-return-default-opattr: supportedControl - nsslapd-return-default-opattr: supportedExtension - nsslapd-return-default-opattr: supportedLDAPVersion - nsslapd-return-default-opattr: supportedSASLMechanisms - nsslapd-return-default-opattr: vendorName - nsslapd-return-default-opattr: vendorVersion - objectClass: top - - dn: cn=changelog5,cn=config - cn: changelog5 - createTimestamp: 20201026161228Z - creatorsName: cn=Directory Manager - modifiersName: cn=Directory Manager - modifyTimestamp: 20201026161228Z - nsslapd-changelogdir: /var/lib/dirsrv/slapd-IDM-NYPD-FINEST/cldb - nsslapd-changelogmaxage: 7d - objectClass: top - objectClass: extensibleobject - - Returns: - - list: A list of dictionaries for each 'dn' attribute block of the ldif configuration. - - Examples: - - >>> ldif_config[0]['dn'] - '' - >>> ldif_config[0]['aci'] # the 2 aci are connected into one - '(targetattr != "aci")(version 3.0; aci "rootdse anon read access"; allow(read,search,compare) userdn="ldap:///anyone";)(target = "ldap:///cn=automember rebuild membership,cn=tasks,cn=config")(,cn=permissions,cn=pbac,dc=idm";)' - >>> ldif_config[0]['nsslapd-return-default-opattr'] # only keep the last - 'vendorVersion' - >>> ldif_config[1]['dn'] - 'cn=changelog5,cn=config' - >>> ldif_config[1]['modifiersName'] - 'cn=Directory Manager' - >>> ldif_config[1]['modifyTimestamp'] - '20201026161228Z' - """ - - def __init__(self, *args, **kwargs): - deprecated(LDIFParser, "Please use the :class:`insights.parsers.dse_ldif.DseLDIF` instead.", "3.5.0") - super(LDIFParser, self).__init__(*args, **kwargs) - - def parse_content(self, content): - if not content: - raise SkipComponent('The file is empty') - - attr_kval = {} - for line in content: - # lines beginning with # are ignored - line = line.strip() - if not line or line.startswith('#'): - continue - # line starts with 'dn' attribute - elif line.startswith('dn:'): - aci_flag = False - attr_kval = dict(dn=line.split(':', 1)[1].strip()) - self.append(attr_kval) - # line starts with 'aci' attribute - elif line.startswith('aci:'): - if 'aci' in attr_kval: - attr_kval['aci'] += line.split(':', 1)[1].strip() - else: - attr_kval['aci'] = line.split(':', 1)[1].strip() - aci_flag = True - # line is a muti-line value with the 'aci' attribute - elif aci_flag and ': ' not in line: - attr_kval['aci'] += line - # line is a non 'aci' attribute or file-backed value attribute - elif not line.startswith('aci:') and ': ' in line: - aci_flag = False - key, val = [i.strip() for i in line.split(':', 1)] - attr_kval[key] = val - - def search(self, **kwargs): - """ - Get the list for the 'dn' attribute block by searching the ldif configuration. - This uses the :py:func:`insights.parsers.keyword_search` function for searching, - see its documentation for usage details. If no search parameters are given or does - match the search, then nothing will be returned. - - Returns: - list: A list of dictionaries for each 'dn' attribute block of the ldif configuration that match the given - search criteria. - - Examples: - >>> ldif_config.search(dn__contains='cn=config')[0] == ldif_config[1] - True - >>> ldif_config.search(dn='cn=sasl,cn=config') == [] - True - >>> ldif_config.search(cn='changelog5')[0] == ldif_config[1] - True - """ - return keyword_search(self, row_keys_change=True, **kwargs) diff --git a/insights/parsers/ls_disk.py b/insights/parsers/ls_disk.py deleted file mode 100644 index af5dd78ed0..0000000000 --- a/insights/parsers/ls_disk.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -LsDisk - Command ``ls -lanR /dev/disk`` -======================================= - -The ``ls -lanR /dev/disk`` command provides information for the listing of the -directories under ``/dev/disk/`` . - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Examples: - >>> LS_DISK = ''' - ... /dev/disk/by-id: - ... total 0 - ... drwxr-xr-x. 2 0 0 360 Sep 20 09:36 . - ... drwxr-xr-x. 5 0 0 100 Sep 20 09:36 .. - ... lrwxrwxrwx. 1 0 0 9 Sep 20 09:36 ata-VBOX_CD-ROM_VB2-01700376 -> ../../sr0 - ... lrwxrwxrwx. 1 0 0 9 Sep 20 09:36 ata-VBOX_HARDDISK_VB4c56cb04-26932e6a -> ../../sdb - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 ata-VBOX_HARDDISK_VB4c56cb04-26932e6a-part1 -> ../../sdb1 - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 scsi-SATA_VBOX_HARDDISK_VB4c56cb04-26932e6a-part1 -> ../../sdb1 - ... - ... /dev/disk/by-path: - ... total 0 - ... drwxr-xr-x. 2 0 0 160 Sep 20 09:36 . - ... drwxr-xr-x. 5 0 0 100 Sep 20 09:36 .. - ... lrwxrwxrwx. 1 0 0 9 Sep 20 09:36 pci-0000:00:0d.0-scsi-1:0:0:0 -> ../../sdb - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 pci-0000:00:0d.0-scsi-1:0:0:0-part1 -> ../../sdb1 - ... - ... /dev/disk/by-uuid: - ... total 0 - ... drwxr-xr-x. 2 0 0 100 Sep 20 09:36 . - ... drwxr-xr-x. 5 0 0 100 Sep 20 09:36 .. - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 3ab50b34-d0b9-4518-9f21-05307d895f81 -> ../../dm-1 - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 51c5cf12-a577-441e-89da-bc93a73a1ba3 -> ../../sda1 - ... lrwxrwxrwx. 1 0 0 10 Sep 20 09:36 7b0068d4-1399-4ce7-a54a-3e2fc1232299 -> ../../dm-0 - ... ''' - >>> from insights.tests import context_wrap - >>> ls_disk = LsDisk(context_wrap(LS_DISK)) - <__main__.LsDisk object at 0x7f674914c690> - >>> "/dev/disk/by-path" in ls_disk - True - >>> ls_disk.files_of("/dev/disk/by-path") - ['pci-0000:00:0d.0-scsi-1:0:0:0', 'pci-0000:00:0d.0-scsi-1:0:0:0-part1'] - >>> ls_disk.dirs_of("/dev/disk/by-path") - ['.', '..'] - >>> ls_disk.specials_of("/dev/disk/by-path") - [] - >>> ls_disk.listing_of("/dev/disk/by-path").keys() - ['pci-0000:00:0d.0-scsi-1:0:0:0-part1', 'pci-0000:00:0d.0-scsi-1:0:0:0', '..', '.'] - >>> ls_disk.dir_entry("/dev/disk/by-path", "pci-0000:00:0d.0-scsi-1:0:0:0") - {'group': '0', 'name': 'pci-0000:00:0d.0-scsi-1:0:0:0', 'links': 1, 'perms': 'rwxrwxrwx.', - 'raw_entry': 'lrwxrwxrwx. 1 0 0 9 Sep 20 09:36 pci-0000:00:0d.0-scsi-1:0:0:0 -> ../../sdb', 'owner': '0', - 'link': '../../sdb', 'date': 'Sep 20 09:36', 'type': 'l', 'size': 9} - >>> ls_disk.listing_of('/dev/disk/by-path')['.']['type'] == 'd' - True - >>> ls_disk.listing_of('/dev/disk/by-path')['pci-0000:00:0d.0-scsi-1:0:0:0']['link'] - '../../sdb' -""" - -from .. import parser, FileListing, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_disk) -class LsDisk(CommandParser, FileListing): - """ - .. warning:: - This Parser is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanR` instead. - - Parses output of ``ls -lanR /dev/disk`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsDisk, "Please use the :class:`insights.parsers.ls.LSlanR` instead.", "3.5.0") - super(LsDisk, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_docker_volumes.py b/insights/parsers/ls_docker_volumes.py deleted file mode 100644 index 469345373d..0000000000 --- a/insights/parsers/ls_docker_volumes.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -DockerVolumesDir - command ``ls -lanR /var/lib/docker/volumes/`` -================================================================ - -A standard directory listing parser using the FileListing parser class. - -Given a listing of:: - - /var/lib/docker/volumes/: - total 4 - drwx------. 3 0 0 77 Mar 15 10:50 . - drwx-----x. 9 0 0 4096 Nov 18 22:04 .. - drwxr-xr-x. 3 0 0 18 Mar 15 10:50 7f9d945c3b3352308a44878a5da9e6046d63e34fafbac36486f4b94f5d372b61 - - /var/lib/docker/volumes/7f9d945c3b3352308a44878a5da9e6046d63e34fafbac36486f4b94f5d372b61: - total 0 - drwxr-xr-x. 3 0 0 18 Mar 15 10:50 . - drwx------. 3 0 0 77 Mar 15 10:50 .. - drwxr-xr-x. 2 0 0 6 Mar 15 10:50 _data - - /var/lib/docker/volumes/7f9d945c3b3352308a44878a5da9e6046d63e34fafbac36486f4b94f5d372b61/_data: - total 0 - drwxr-xr-x. 2 0 0 6 Mar 15 10:50 . - drwxr-xr-x. 3 0 0 18 Mar 15 10:50 .. - - -Examples: - - >>> docker_dirs = shared[DockerVolumesDir] - >>> '/var/lib/docker/volumes' in docker_dirs - True - >>> docker_dirs.dirs_of('/var/lib/docker/volumes') - ['.', '..', '97d7cd1a5d8fd7730e83bb61ecbc993742438e966ac5c11910776b5d53f4ae07'] - >>> '/var/lib/docker/volumes/97d7cd1a5d8fd7730e83bb61ecbc993742438e966ac5c11910776b5d53f4ae07' in docker_dirs - True - >>> docker_dirs.dirs_of('/var/lib/docker/volumes/97d7cd1a5d8fd7730e83bb61ecbc993742438e966ac5c11910776b5d53f4ae07') - ['.', '..', '_data'] -""" - -from .. import FileListing, parser, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_docker_volumes) -class DockerVolumesDir(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanR` instead. - - Read the directory for the docker volumes. - """ - def __init__(self, *args, **kwargs): - deprecated(DockerVolumesDir, "Please use the :class:`insights.parsers.ls.LSlanR` instead.", "3.5.0") - super(DockerVolumesDir, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_edac_mc.py b/insights/parsers/ls_edac_mc.py deleted file mode 100644 index 5cfcf95040..0000000000 --- a/insights/parsers/ls_edac_mc.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -LsEdacMC - command ``ls -lan /sys/devices/system/edac/mc`` -========================================================== - -The ``ls -lan /sys/devices/system/edac/mc`` command provides information for the listing of the -``/sys/devices/system/edac/mc`` directory. See the ``FileListing`` class for a more complete description of the -available features of the class. - -Sample ``ls -lan /sys/devices/system/edac/mc`` output:: - - /sys/devices/system/edac/mc: - total 90 - drwxr-xr-x. 3 0 0 0 Jan 10 10:33 . - drwxr-xr-x. 3 0 0 0 Jan 10 10:33 .. - drwxr-xr-x. 2 0 0 0 Jan 10 10:33 power - drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc0 - drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc1 - drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc2 - -Examples: - >>> '/sys/devices/system/edac/mc' in ls_edac_mc - True - >>> ls_edac_mc.dirs_of('/sys/devices/system/edac/mc') == ['.', '..', 'power', 'mc0', 'mc1', 'mc2'] - True -""" - -from insights.specs import Specs -from .. import parser, CommandParser, FileListing -from insights.util import deprecated - - -@parser(Specs.ls_edac_mc) -class LsEdacMC(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanR` instead. - - Parse the /sys/devices/system/edac/mc directory listing using a standard FileListing parser. - """ - def __init__(self, *args, **kwargs): - deprecated(LsEdacMC, "Please use the :class:`insights.parsers.ls.LSlanR` instead.", "3.5.0") - super(LsEdacMC, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_etc.py b/insights/parsers/ls_etc.py deleted file mode 100644 index f57d87c955..0000000000 --- a/insights/parsers/ls_etc.py +++ /dev/null @@ -1,129 +0,0 @@ -""" -Ls Etc Directory -================ - -Parsers provided in this module includes: - -LsEtc - command ``ls -lan /etc `` ------------------------------------------------- - -LsEtcSsh - command ``/bin/ls -lanL /etc/ssh`` ---------------------------------------------- -""" -from .. import parser, CommandParser -from .. import FileListing -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_etc) -class LsEtc(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -lan /etc `` command. - - The ``ls -lan /etc `` command provides information for - the listing of the ``/etc`` directory and specified sub-directories. - See ``FileListing`` class for additional information. - - Sample ``ls -lan /etc/sysconfig /etc/rc.d/rc3.d`` output:: - - /etc/sysconfig: - total 96 - drwxr-xr-x. 7 0 0 4096 Jul 6 23:41 . - drwxr-xr-x. 77 0 0 8192 Jul 13 03:55 .. - drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq - drwxr-xr-x. 2 0 0 6 Sep 16 2015 console - -rw-------. 1 0 0 1390 Mar 4 2014 ebtables-config - -rw-r--r--. 1 0 0 72 Sep 15 2015 firewalld - lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub - - /etc/rc.d/rc3.d: - total 4 - drwxr-xr-x. 2 0 0 58 Jul 6 23:32 . - drwxr-xr-x. 10 0 0 4096 Sep 16 2015 .. - lrwxrwxrwx. 1 0 0 20 Jul 6 23:32 K50netconsole -> ../init.d/netconsole - lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 S10network -> ../init.d/network - lrwxrwxrwx. 1 0 0 15 Jul 6 23:32 S97rhnsd -> ../init.d/rhnsd - - Examples: - - >>> "sysconfig" in ls_etc - False - >>> "/etc/sysconfig" in ls_etc - True - >>> len(ls_etc.files_of('/etc/sysconfig')) - 3 - >>> ls_etc.files_of("/etc/sysconfig") - ['ebtables-config', 'firewalld', 'grub'] - >>> ls_etc.dirs_of("/etc/sysconfig") - ['.', '..', 'cbq', 'console'] - >>> ls_etc.specials_of("/etc/sysconfig") - [] - >>> ls_etc.total_of("/etc/sysconfig") - 96 - >>> ls_etc.dir_entry('/etc/sysconfig', 'grub') == {'group': '0', 'name': 'grub', 'links': 1, 'perms': 'rwxrwxrwx.', 'raw_entry': 'lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub', 'owner': '0', 'link': '/etc/default/grub', 'date': 'Jul 6 23:32', 'type': 'l', 'dir': '/etc/sysconfig', 'size': 17} - True - >>> ls_etc.files_of('/etc/rc.d/rc3.d') - ['K50netconsole', 'S10network', 'S97rhnsd'] - >>> sorted(ls_etc.listing_of("/etc/sysconfig").keys()) == sorted(['console', 'grub', '..', 'firewalld', '.', 'cbq', 'ebtables-config']) - True - >>> sorted(ls_etc.listing_of("/etc/sysconfig")['console'].keys()) == sorted(['group', 'name', 'links', 'perms', 'raw_entry', 'owner', 'date', 'type', 'dir', 'size']) - True - >>> ls_etc.listing_of("/etc/sysconfig")['console']['type'] - 'd' - >>> ls_etc.listing_of("/etc/sysconfig")['console']['perms'] - 'rwxr-xr-x.' - >>> ls_etc.dir_contains("/etc/sysconfig", "console") - True - >>> ls_etc.dir_entry("/etc/sysconfig", "console") == {'group': '0', 'name': 'console', 'links': 2, 'perms': 'rwxr-xr-x.', 'raw_entry': 'drwxr-xr-x. 2 0 0 6 Sep 16 2015 console', 'owner': '0', 'date': 'Sep 16 2015', 'type': 'd', 'dir': '/etc/sysconfig', 'size': 6} - True - >>> ls_etc.dir_entry("/etc/sysconfig", "grub")['type'] - 'l' - >>> ls_etc.dir_entry("/etc/sysconfig", "grub")['link'] - '/etc/default/grub' - """ - def __init__(self, *args, **kwargs): - deprecated(LsEtc, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsEtc, self).__init__(*args, **kwargs) - - -@parser(Specs.ls_etc_ssh) -class LsEtcSsh(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanL` instead. - - Parses output of ``ls -lanL /etc/ssh`` command. - - Sample ``ls -lanL /etc/ssh`` output:: - - total 612 - drwxr-xr-x. 3 0 0 245 Aug 11 14:19 . - drwxr-xr-x. 138 0 0 8192 Jul 29 19:11 .. - -rw-r--r--. 1 0 0 577388 Mar 27 2020 moduli - -rw-r--r--. 1 0 0 1770 Mar 27 2020 ssh_config - drwxr-xr-x. 2 0 0 28 May 12 17:10 ssh_config.d - -rw-r-----. 1 0 994 480 May 13 09:58 ssh_host_ecdsa_key - -rw-r--r--. 1 0 0 162 May 13 09:58 ssh_host_ecdsa_key.pub - -rw-r-----. 1 0 994 387 May 13 09:58 ssh_host_ed25519_key - -rw-r--r--. 1 0 0 82 May 13 09:58 ssh_host_ed25519_key.pub - -rw-r-----. 1 0 994 2578 May 13 09:58 ssh_host_rsa_key - -rw-r--r--. 1 0 0 554 May 13 09:58 ssh_host_rsa_key.pub - -rw-------. 1 0 0 4260 Aug 11 14:19 sshd_config - - Examples: - >>> type(ls_etc_ssh) - - >>> ls_etc_ssh.files_of("/etc/ssh") - ['moduli', 'ssh_config', 'ssh_host_ecdsa_key', 'ssh_host_ecdsa_key.pub', 'ssh_host_ed25519_key', 'ssh_host_ed25519_key.pub', 'ssh_host_rsa_key', 'ssh_host_rsa_key.pub', 'sshd_config'] - >>> ls_etc_ssh.dir_entry('/etc/ssh', 'ssh_host_rsa_key')['perms'] - 'rw-r-----.' - """ - def __init__(self, *args, **kwargs): - deprecated(LsEtcSsh, "Please use the :class:`insights.parsers.ls.LSlanL` instead.", "3.5.0") - super(LsEtcSsh, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_ipa_idoverride_memberof.py b/insights/parsers/ls_ipa_idoverride_memberof.py deleted file mode 100644 index 631a150e0c..0000000000 --- a/insights/parsers/ls_ipa_idoverride_memberof.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -LsIPAIdoverrideMemberof - command ``ls -lan /usr/share/ipa/ui/js/plugins/idoverride-memberof`` -============================================================================================== - -The ``ls -lan /usr/share/ipa/ui/js/plugins/idoverride-memberof`` command provides information for the listing of the -``/usr/share/ipa/ui/js/plugins/idoverride-memberof`` files. See the ``FileListing`` class for a more complete description -of the available features of the class. - -Sample ``ls -lan /usr/share/ipa/ui/js/plugins/idoverride-memberof`` output:: - - /usr/share/ipa/ui/js/plugins/idoverride-memberof: - total 0 - drwxr-xr-x. 2 0 0 0 Nov 11 11:44 . - drwxr-xr-x. 4 0 0 0 Nov 11 11:44 .. - -rw-rw-r--. 1 0 0 0 Nov 11 11:44 idoverride-memberof.js - -rw-rw-r--. 1 0 0 0 Nov 11 11:44 idoverride-admemberof.js - -Examples: - >>> '/usr/share/ipa/ui/js/plugins/idoverride-memberof' in ls_ipa_idoverride_memberof - True - >>> ls_ipa_idoverride_memberof.files_of('/usr/share/ipa/ui/js/plugins/idoverride-memberof') == ['idoverride-memberof.js', 'idoverride-admemberof.js'] - True -""" - -from insights.specs import Specs -from .. import parser, CommandParser, FileListing -from insights.util import deprecated - - -@parser(Specs.ls_ipa_idoverride_memberof) -class LsIPAIdoverrideMemberof(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -lan /usr/share/ipa/ui/js/plugins/idoverride-memberof`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsIPAIdoverrideMemberof, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsIPAIdoverrideMemberof, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_krb5_sssd.py b/insights/parsers/ls_krb5_sssd.py deleted file mode 100644 index f0123ccf8f..0000000000 --- a/insights/parsers/ls_krb5_sssd.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -Lskrb5Sssd - command ``ls -lan /var/lib/sss/pubconf/krb5.include.d`` -==================================================================== - -The ``ls -lan /var/lib/sss/pubconf/krb5.include.d`` command provides information for the listing of the -``/var/lib/sss/pubconf/krb5.include.d`` directory. See the ``FileListing`` class for a more complete description -of the available features of the class. - -Sample ``ls -lan /var/lib/sss/pubconf/krb5.include.d`` output:: - - /var/lib/sss/pubconf/krb5.include.d: - total 24 - drwxr-xr-x@ 6 501 20 192 Jul 1 23:46 . - drwxr-xr-x@ 3 501 20 96 Jul 1 23:48 .. - -rw-r--r--@ 1 501 20 674 Jul 1 23:46 domain_realm_rhidm_gwl_bz - -rw-r--r--@ 1 501 20 35 Jul 1 23:46 krb5_libdefaults - -rw-r--r--@ 1 501 20 98 Jul 1 23:46 localauth_plugin - -rw-------@ 1 501 20 0 Oct 1 2021 localauth_pluginolsIe3 - -Examples: - >>> '/var/lib/sss/pubconf/krb5.include.d' in ls_krb5_sssd - True - >>> ls_krb5_sssd.files_of('/var/lib/sss/pubconf/krb5.include.d') == ['domain_realm_rhidm_gwl_bz', 'krb5_libdefaults', 'localauth_plugin', 'localauth_pluginolsIe3'] - True -""" - -from insights.specs import Specs -from .. import parser, CommandParser, FileListing -from insights.util import deprecated - - -@parser(Specs.ls_krb5_sssd) -class LsKrb5SSSD(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parse the /var/lib/sss/pubconf/krb5.include.d directory listing using a standard FileListing parser. - """ - def __init__(self, *args, **kwargs): - deprecated(LsKrb5SSSD, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsKrb5SSSD, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_lib_firmware.py b/insights/parsers/ls_lib_firmware.py deleted file mode 100644 index 4523286b22..0000000000 --- a/insights/parsers/ls_lib_firmware.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -Lists ALL the firmware packages -=============================== - -Parsers included in this module are: - -LsLibFW - command ``/bin/ls -lanR /lib/firmware`` ----------------------------------------------------- - -""" -from .. import parser, CommandParser, FileListing -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_lib_firmware) -class LsLibFW(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanR` instead. - - This parser will help to parse the output of command ``/bin/ls -lanR /lib/firmware`` - - Typical output of the ``/bin/ls -lanR /lib/firmware`` command is:: - - \t/lib/firmware: - \ttotal 37592 - \tdrwxr-xr-x. 83 0 0 8192 Aug 14 02:43 . - \tdr-xr-xr-x. 26 0 0 4096 Aug 14 02:22 .. - \tdrwxr-xr-x. 2 0 0 40 Aug 14 02:42 3com - \tlrwxrwxrwx. 1 0 0 16 Aug 14 02:42 a300_pfp.fw -> qcom/a300_pfp.fw - \tlrwxrwxrwx. 1 0 0 16 Aug 14 02:42 a300_pm4.fw -> qcom/a300_pm4.fw - \tdrwxr-xr-x. 2 0 0 34 Aug 14 02:42 acenic - \tdrwxr-xr-x. 2 0 0 50 Aug 14 02:42 adaptec - \tdrwxr-xr-x. 2 0 0 73 Aug 14 02:42 advansys - \t - \t/lib/firmware/3com: - \ttotal 84 - \tdrwxr-xr-x. 2 0 0 40 Aug 14 02:42 . - \tdrwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. - \t-rw-r--r--. 1 0 0 24880 Jun 6 10:14 3C359.bin - \t-rw-r--r--. 1 0 0 44548 Jun 6 10:14 typhoon.bin - \t - \t/lib/firmware/acenic: - \ttotal 160 - \tdrwxr-xr-x. 2 0 0 34 Aug 14 02:42 . - \tdrwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. - \t-rw-r--r--. 1 0 0 73116 Jun 6 10:14 tg1.bin - \t-rw-r--r--. 1 0 0 77452 Jun 6 10:14 tg2.bin - - Example: - - >>> type(lslibfw) - - >>> lslibfw.files_of("/lib/firmware/bnx2x") - ['bnx2x-e1-6.0.34.0.fw', 'bnx2x-e1-6.2.5.0.fw', 'bnx2x-e1-6.2.9.0.fw', 'bnx2x-e1-7.0.20.0.fw', 'bnx2x-e1-7.0.23.0.fw'] - >>> lslibfw.dir_contains("/lib/firmware/bnx2x", "bnx2x-e1-6.0.34.0.fw") - True - >>> lslibfw.dirs_of("/lib/firmware") - ['.', '..', '3com', 'acenic', 'adaptec', 'advansys'] - >>> lslibfw.total_of("/lib/firmware") - 37592 - """ - def __init__(self, *args, **kwargs): - deprecated(LsLibFW, "Please use the :class:`insights.parsers.ls.LSlanR` instead.", "3.5.0") - super(LsLibFW, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_ocp_cni_openshift_sdn.py b/insights/parsers/ls_ocp_cni_openshift_sdn.py deleted file mode 100644 index 479a31c485..0000000000 --- a/insights/parsers/ls_ocp_cni_openshift_sdn.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -LsOcpCniOpenshiftSdn - command ``ls -l /var/lib/cni/networks/openshift-sdn`` -============================================================================ - -The ``ls -l /var/lib/cni/networks/openshift-sdn`` command is used to return the count of cni files -and also could provide information for the listing of the ``/var/lib/cni/networks/openshift-sdn`` -directory. See ``FileListing`` class for additional information. -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 52 - -rw-r--r--. 1 root root 64 Aug 5 23:26 10.130.0.102 - -rw-r--r--. 1 root root 64 Aug 5 23:26 10.130.0.103 - -rw-r--r--. 1 root root 64 Aug 6 22:52 10.130.0.116 - -rw-r--r--. 1 root root 64 Aug 6 22:52 10.130.0.117 - -rw-r--r--. 1 root root 64 Aug 5 06:59 10.130.0.15 - -rw-r--r--. 1 root root 64 Aug 5 07:02 10.130.0.20 - -rw-r--r--. 1 root root 12 Aug 6 22:52 last_reserved_ip.0 - -Examples: - - >>> ls_ocp_cni_openshift_sdn.files_of("/var/lib/cni/networks/openshift-sdn") - ['10.130.0.102', '10.130.0.103', '10.130.0.116', '10.130.0.117', '10.130.0.15', '10.130.0.20', 'last_reserved_ip.0'] -""" - -from .. import FileListing -from .. import parser, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_ocp_cni_openshift_sdn) -class LsOcpCniOpenshiftSdn(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - Parses output of ``ls -l /var/lib/cni/networks/openshift-sdn`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsOcpCniOpenshiftSdn, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsOcpCniOpenshiftSdn, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_origin_local_volumes_pods.py b/insights/parsers/ls_origin_local_volumes_pods.py deleted file mode 100644 index 0f242f5465..0000000000 --- a/insights/parsers/ls_origin_local_volumes_pods.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -LsOriginLocalVolumePods - command ``ls -l /var/lib/origin/openshift.local.volumes/pods`` -======================================================================================== -""" - -from insights.specs import Specs -from insights import FileListing, parser, CommandParser -from insights.util import deprecated - - -@parser(Specs.ls_origin_local_volumes_pods) -class LsOriginLocalVolumePods(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - Class to parse the output of command ``ls -l /var/lib/origin/openshift.local.volumes/pods``. - See ``FileListing`` class for additional information. - - The typical content is:: - - total 0 - drwxr-x---. 5 root root 71 Oct 18 23:20 5946c1f644096161a1242b3de0ee5875 - drwxr-x---. 5 root root 71 Oct 18 23:24 6ea3d5cd-d34e-11e8-a142-001a4a160152 - drwxr-x---. 5 root root 71 Oct 18 23:31 77d6d959-d34f-11e8-a142-001a4a160152 - drwxr-x---. 5 root root 71 Oct 18 23:24 7ad952a0-d34e-11e8-a142-001a4a160152 - drwxr-x---. 5 root root 71 Oct 18 23:24 7b63e8aa-d34e-11e8-a142-001a4a160152 - - - Examples: - - >>> ls_origin_local_volumes_pods.pods - ['5946c1f644096161a1242b3de0ee5875', '6ea3d5cd-d34e-11e8-a142-001a4a160152', '77d6d959-d34f-11e8-a142-001a4a160152', '7ad952a0-d34e-11e8-a142-001a4a160152', '7b63e8aa-d34e-11e8-a142-001a4a160152'] - - Attributes: - pods (List): The list of pods uid under the directory /var/lib/origin/openshift.local.volumes/pods - """ - def __init__(self, *args, **kwargs): - deprecated(LsOriginLocalVolumePods, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsOriginLocalVolumePods, self).__init__(*args, **kwargs) - - @property - def pods(self): - return self.dirs_of("/var/lib/origin/openshift/local/volumes/pods") diff --git a/insights/parsers/ls_osroot.py b/insights/parsers/ls_osroot.py deleted file mode 100644 index 371ff2e2c8..0000000000 --- a/insights/parsers/ls_osroot.py +++ /dev/null @@ -1,64 +0,0 @@ -""" -LsOsroot - command ``ls -lan /`` -================================ - -The ``ls -lan /`` command provides information for only the ``/`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 5256 - dr-xr-xr-x. 17 0 0 271 Apr 5 18:08 . - dr-xr-xr-x. 17 0 0 271 Apr 5 18:08 .. - -rw-r--r--. 1 0 0 0 Feb 25 2017 1 - lrwxrwxrwx. 1 0 0 7 Feb 25 2017 bin -> usr/bin - dr-xr-xr-x. 3 0 0 4096 Feb 25 2017 boot - -rw-r--r--. 1 0 0 5168141 Oct 16 2017 channel-list - drwxr-xr-x. 21 0 0 3440 Apr 12 14:46 dev - drwxr-xr-x. 148 0 0 8192 Apr 18 09:17 etc - drwxr-xr-x. 5 0 0 37 Jul 31 2017 home - lrwxrwxrwx. 1 0 0 7 Feb 25 2017 lib -> usr/lib - lrwxrwxrwx. 1 0 0 9 Feb 25 2017 lib64 -> usr/lib64 - drwxr-xr-x. 2 0 0 6 Mar 10 2016 media - drwxr-xr-x. 2 0 0 6 Mar 10 2016 mnt - drwxr-xr-x. 5 0 0 48 Mar 27 13:37 opt - dr-xr-xr-x. 265 0 0 0 Apr 6 02:07 proc - -rw-r--r--. 1 0 0 175603 Apr 5 18:08 .readahead - dr-xr-x---. 26 0 0 4096 Apr 18 09:17 root - drwxr-xr-x. 43 0 0 1340 Apr 18 09:17 run - lrwxrwxrwx. 1 0 0 8 Feb 25 2017 sbin -> usr/sbin - drwxr-xr-x. 2 0 0 6 Mar 10 2016 srv - dr-xr-xr-x. 13 0 0 0 Apr 5 18:07 sys - drwxrwxrwt. 40 0 0 8192 Apr 18 11:17 tmp - drwxr-xr-x. 13 0 0 155 Feb 25 2017 usr - drwxr-xr-x. 21 0 0 4096 Apr 6 02:07 var - -Examples: - - >>> ls_osroot.listing_of("/")['tmp'] == {'group': '0', 'name': 'tmp', 'links': 40, 'perms': 'rwxrwxrwt.', 'raw_entry': 'drwxrwxrwt. 40 0 0 8192 Apr 18 11:17 tmp', 'owner': '0', 'date': 'Apr 18 11:17', 'type': 'd', 'dir': '/', 'size': 8192} - True - >>> ls_osroot.dir_entry("/", 'tmp')['perms'] - 'rwxrwxrwt.' -""" - - -from .. import FileListing -from .. import parser, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_osroot) -class LsOsroot(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -lan /`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsOsroot, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsOsroot, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_systemd_units.py b/insights/parsers/ls_systemd_units.py deleted file mode 100644 index 23788de1f8..0000000000 --- a/insights/parsers/ls_systemd_units.py +++ /dev/null @@ -1,92 +0,0 @@ -""" -LsSystemdUnits - command ``/bin/ls -lanRL /etc/systemd /run/systemd /usr/lib/systemd /usr/local/lib/systemd /usr/local/share/systemd /usr/share/systemd`` -========================================================================================================================================================= - -This parser provides file listing for Systemd Units gathered from the ``/bin/ls -lanRL /etc/systemd -/run/systemd /usr/lib/systemd /usr/local/lib/systemd /usr/local/share/systemd /usr/share/systemd`` -command. - - -The shortened sample output of the command is:: - - /etc/systemd: - total 40 - drwxr-xr-x. 4 0 0 150 Apr 4 2019 . - drwxr-xr-x. 88 0 0 8192 Jun 28 06:56 .. - -rw-r--r--. 1 0 0 615 Jun 22 2018 coredump.conf - -rw-r--r--. 1 0 0 1027 Jun 22 2018 journald.conf - -rw-r--r--. 1 0 0 1052 Apr 4 2019 logind.conf - -rw-r--r--. 1 0 0 631 Feb 26 2019 resolved.conf - drwxr-xr-x. 17 0 0 4096 Apr 4 2019 system - -rw-r--r--. 1 0 0 1682 Feb 26 2019 system.conf - drwxr-xr-x. 2 0 0 6 Feb 26 2019 user - -rw-r--r--. 1 0 0 1130 Jun 22 2018 user.conf - - /etc/systemd/system: - total 28 - drwxr-xr-x. 17 0 0 4096 Apr 4 2019 . - drwxr-xr-x. 4 0 0 150 Apr 4 2019 .. - drwxr-xr-x. 2 0 0 31 Apr 4 2019 basic.target.wants - -rw-r--r--. 1 0 0 1341 Feb 8 2019 dbus-org.freedesktop.NetworkManager.service - -rw-r--r--. 1 0 0 353 Feb 8 2019 dbus-org.freedesktop.nm-dispatcher.service - -rw-r--r--. 1 0 0 238 Nov 7 2017 dbus-org.freedesktop.timedate1.service - -rw-r--r--. 1 0 0 532 Jun 22 2018 default.target - drwxr-xr-x. 2 0 0 32 Apr 4 2019 getty.target.wants - drwxr-xr-x. 2 0 0 4096 Apr 4 2019 multi-user.target.wants - drwxr-xr-x. 2 0 0 48 Apr 4 2019 network-online.target.wants - drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-blkmap.service.requires - drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-idmapd.service.requires - drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-mountd.service.requires - drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-server.service.requires - drwxr-xr-x. 2 0 0 31 Apr 4 2019 remote-fs.target.wants - drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-gssd.service.requires - drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-statd-notify.service.requires - drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-statd.service.requires - drwxr-xr-x. 2 0 0 51 Apr 4 2019 sockets.target.wants - drwxr-xr-x. 2 0 0 151 Apr 4 2019 sysinit.target.wants - -rw-r--r--. 1 0 0 583 Dec 17 2018 syslog.service - crw-rw-rw-. 1 0 0 1, 3 Jun 28 06:56 systemd-timedated.service - drwxr-xr-x. 2 0 0 34 Apr 4 2019 timers.target.wants - - /etc/systemd/system/basic.target.wants: - total 8 - drwxr-xr-x. 2 0 0 31 Apr 4 2019 . - drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. - -rw-r--r--. 1 0 0 284 Nov 6 2018 microcode.service - -Examples: - >>> type(ls_systemd_units) - - >>> ls_systemd_units.dirs_of("/etc/systemd") - ['.', '..', 'system', 'user'] - >>> ls_systemd_units.files_of("/etc/systemd/system/basic.target.wants") - ['microcode.service'] - >>> ls_systemd_units.specials_of("/etc/systemd/system") - ['systemd-timedated.service'] - >>> ls_systemd_units.dir_contains("/etc/systemd/system", "default.target") - True - >>> ls_systemd_units.dir_entry("/etc/systemd/system", "syslog.service")["perms"] - 'rw-r--r--.' -""" - -from insights.core import CommandParser, FileListing -from insights.core.plugins import parser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_systemd_units) -class LsSystemdUnits(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanRL` instead. - - Class for parsing the ``/bin/ls -lanRL /etc/systemd /run/systemd /usr/lib/systemd - /usr/local/lib/systemd /usr/local/share/systemd /usr/share/systemd`` command. - - For more information, see the ``FileListing`` class. - """ - def __init__(self, *args, **kwargs): - deprecated(LsSystemdUnits, "Please use the :class:`insights.parsers.ls.LSlanRL` instead.", "3.5.0") - super(LsSystemdUnits, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_tmp.py b/insights/parsers/ls_tmp.py deleted file mode 100644 index 6a5a0112f7..0000000000 --- a/insights/parsers/ls_tmp.py +++ /dev/null @@ -1,65 +0,0 @@ -""" -LsTmp - Command ``ls -la /tmp`` -=============================== - -The ``ls -la /tmp`` command provides information for the listing of the -``/tmp`` directory. - -""" -from insights import parser, FileListing, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_tmp) -class LsTmp(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlaFiltered` instead. - - Parses output of ``ls -lan /tmp`` command. See ``FileListing`` class for - additional information. - - To prevent the output content from being too large, filters should be - applied. Sample output of ``ls -lan /tmp`` after filtered:: - - drwxrwxr-x. 2 whuser whuser 216 Jul 9 07:09 aws_sos - -rw-r--r--. 1 rauser rauser 1123 Jul 10 00:00 clean-old-archive.log - -rw-rw-r--. 1 whuser whuser 9620 Jul 9 07:09 daily-extraction-warehouse-run.log - -rw-rw-r--. 1 whuser whuser 11214 Jul 9 07:09 dask_master.log - -rw-rw-r--. 1 whuser whuser 27091 Jul 9 07:09 dask_worker.log - -rw-r--r--. 1 user10 user10 29 Jul 10 00:00 date.out - -rw-r--r--. 1 rauser rauser 325933528 Jul 10 00:18 delete-bad-pods.log - -rw-rw-r--. 1 whuser whuser 0 Jul 9 07:08 extraction_driver.log - drwxrwxrwt. 2 root root 6 Mar 27 2017 .font-unix - drwxrwxr-x. 3 user1 user1 17 Oct 28 2019 hadoop-user1 - drwxr-xr-x. 2 user1 user1 32 Jul 4 18:29 hsperfdata_user1 - drwxr-xr-x. 2 rauser rauser 6 Jul 10 00:00 hsperfdata_rauser - drwxr-xr-x. 2 root root 6 Jul 1 14:53 hsperfdata_root - drwxrwxrwt. 2 root root 6 Mar 27 2017 .ICE-unix - srw-rw----. 1 user10 user10 0 Jan 6 2020 lh_pair - srw-rw----. 1 user10 user10 0 Jan 28 11:24 lh_pair_ex - - - Examples: - >>> type(ls_tmp) - - >>> len(ls_tmp.files_of("/tmp")) - 9 - >>> len(ls_tmp.dirs_of("/tmp")) - 7 - >>> "/tmp" in ls_tmp - True - >>> "aws_sos" in ls_tmp.dirs_of("/tmp") - True - >>> "aws_sos" not in ls_tmp.files_of("/tmp") - True - >>> "date.out" not in ls_tmp.dirs_of("/tmp") - True - >>> "date.out" in ls_tmp.files_of("/tmp") - True - """ - def __init__(self, *args, **kwargs): - deprecated(LsTmp, "Please use the :class:`insights.parsers.ls.LSlaFiltered` instead.", "3.5.0") - super(LsTmp, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_usr_bin.py b/insights/parsers/ls_usr_bin.py deleted file mode 100644 index 673b61787d..0000000000 --- a/insights/parsers/ls_usr_bin.py +++ /dev/null @@ -1,66 +0,0 @@ -""" -LsUsrBin - command ``ls -lan /usr/bin`` -======================================= - -The ``ls -lan /usr/bin`` command provides information for the listing of the -``/usr/bin`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -For ls_usr_bin, it may collect a lot of files or directories that may not be -necessary, so a default filter `add_filter(Specs.ls_usr_bin, "total")` has been -added in this parser. - -If addtional file or directory need to be collected by this parser, please -add related filter to corresponding code. - -Sample added filter: - - >>> add_filter(Specs.ls_usr_bin, "python") - >>> add_filter(Specs.ls_usr_bin, "virt") - -Sample directory list collected:: - - total 41472 - lrwxrwxrwx. 1 0 0 7 Oct 22 2019 python -> python2 - -rwxr-xr-x. 1 0 0 2558 Apr 10 2019 python-argcomplete-check-easy-install-script - -rwxr-xr-x. 1 0 0 318 Apr 10 2019 python-argcomplete-tcsh - lrwxrwxrwx. 1 0 0 14 Oct 22 2019 python-config -> python2-config - lrwxrwxrwx. 1 0 0 9 Oct 22 2019 python2 -> python2.7 - -Examples: - - >>> "accessdb" in ls_usr_bin - False - >>> "/usr/bin" in ls_usr_bin - True - >>> ls_usr_bin.dir_entry('/usr/bin', 'python-argcomplete-tcsh')['type'] - '-' - >>> ls_usr_bin.dir_entry('/usr/bin', 'python2')['type'] - 'l' -""" - -from insights.core.filters import add_filter -from insights.specs import Specs -from insights.util import deprecated - -from .. import CommandParser, parser -from .. import FileListing - - -add_filter(Specs.ls_usr_bin, "total") - - -@parser(Specs.ls_usr_bin) -class LsUsrBin(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanFiltered` instead. - - Parses output of ``ls -lan /usr/bin`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsUsrBin, "Please use the :class:`insights.parsers.ls.LSlanFiltered` instead.", "3.5.0") - super(LsUsrBin, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_usr_lib64.py b/insights/parsers/ls_usr_lib64.py deleted file mode 100644 index 160d7ea1c4..0000000000 --- a/insights/parsers/ls_usr_lib64.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -LsUsrLib64 - command ``ls -lan /usr/lib64`` -=========================================== - -The ``ls -lan /usr/lib64`` command provides information for the listing of the -``/usr/lib64`` directory. - -See :class:`insights.core.FileListing` class for additional information. - -Sample directory list:: - - total 447460 - dr-xr-xr-x. 150 0 0 77824 Jul 30 16:39 . - drwxr-xr-x. 13 0 0 4096 Apr 30 2017 .. - drwxr-xr-x. 3 0 0 20 Nov 3 2016 krb5 - -rwxr-xr-x. 1 0 0 155464 Oct 28 2016 ld-2.17.so - drwxr-xr-x. 3 0 0 20 Jun 10 2016 ldb - lrwxrwxrwx. 1 0 0 10 Apr 30 2017 ld-linux-x86-64.so.2 -> ld-2.17.so - lrwxrwxrwx. 1 0 0 21 Apr 30 2017 libabrt_dbus.so.0 -> libabrt_dbus.so.0.0.1 - -Examples: - - >>> "krb5" in ls_usr_lib64 - False - >>> "/usr/lib64" in ls_usr_lib64 - True - >>> "krb5" in ls_usr_lib64.dirs_of('/usr/lib64') - True - >>> ls_usr_lib64.dir_entry('/usr/lib64', 'ld-linux-x86-64.so.2')['type'] - 'l' -""" -from insights import parser, CommandParser, FileListing -from insights.specs import Specs -from insights.core.filters import add_filter -from insights.util import deprecated - - -add_filter(Specs.ls_usr_lib64, "total") - - -@parser(Specs.ls_usr_lib64) -class LsUsrLib64(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanFiltered` instead. - - Parses output of ``ls -lan /usr/lib64`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsUsrLib64, "Please use the :class:`insights.parsers.ls.LSlanFiltered` instead.", "3.5.0") - super(LsUsrLib64, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_usr_sbin.py b/insights/parsers/ls_usr_sbin.py deleted file mode 100644 index 3e6a9f5136..0000000000 --- a/insights/parsers/ls_usr_sbin.py +++ /dev/null @@ -1,82 +0,0 @@ -""" -LsUsrSbin - command ``ls -ln /usr/sbin`` -======================================== - -The ``ls -ln /usr/sbin`` command provides information for the listing of the -``/usr/sbin`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -For ls_usr_sbin, it may collect a lot of files or directories that may not be -necessary, so a default filter `add_filter(Specs.ls_usr_sbin, "total")` has -been added in this parser. - -If addtional file or directory need to be collected by this parser, please -add related filter to corresponding code. - -Sample added filter: - - >>> add_filter(Specs.ls_usr_sbin, "accessdb") - -Sample directory list collected:: - - total 41472 - -rwxr-xr-x. 1 0 0 11720 Mar 18 2014 accessdb - -Examples: - - >>> "accessdb" in ls_usr_sbin - False - >>> "/usr/sbin" in ls_usr_sbin - True - >>> ls_usr_sbin.dir_entry('/usr/sbin', 'accessdb')['type'] - '-' - -Sample added filter: - - >>> add_filter(Specs.ls_usr_sbin, "accessdb") - >>> add_filter(Specs.ls_usr_sbin, "postdrop") - -Sample directory list collected:: - - total 41472 - -rwxr-xr-x. 1 0 0 11720 Mar 18 2014 accessdb - -rwxr-sr-x. 1 0 90 218552 Jan 27 2014 postdrop - -Examples: - - >>> "accessdb" in ls_usr_sbin - False - >>> "/usr/sbin" in ls_usr_sbin - True - >>> ls_usr_sbin.dir_entry('/usr/sbin', 'accessdb')['type'] - '-' - >>> ls_usr_sbin.dir_entry('/usr/sbin', 'postdrop')['type'] - '-' -""" - - -from insights.core.filters import add_filter -from insights.specs import Specs -from insights.util import deprecated - -from .. import CommandParser, parser -from .. import FileListing - - -add_filter(Specs.ls_usr_sbin, "total") - - -@parser(Specs.ls_usr_sbin) -class LsUsrSbin(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanFiltered` instead. - - Parses output of ``ls -ln /usr/sbin`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsUsrSbin, "Please use the :class:`insights.parsers.ls.LSlanFiltered` instead.", "3.5.0") - super(LsUsrSbin, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_cache_pulp.py b/insights/parsers/ls_var_cache_pulp.py deleted file mode 100644 index 0c4007200d..0000000000 --- a/insights/parsers/ls_var_cache_pulp.py +++ /dev/null @@ -1,46 +0,0 @@ -""" -LsVarCachePulp - command ``ls -lan /var/cache/pulp`` -==================================================== - -The ``ls -lan /var/cache/pulp`` command provides information for the listing of the ``/var/cache/pulp`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 0 - drwxrwxr-x. 5 48 1000 216 Jan 21 12:56 . - drwxr-xr-x. 10 0 0 121 Jan 20 13:57 .. - lrwxrwxrwx. 1 0 0 19 Jan 21 12:56 cache -> /var/lib/pulp/cache - drwxr-xr-x. 2 48 48 6 Jan 21 13:03 reserved_resource_worker-0@dhcp130-202.gsslab.pnq2.redhat.com - drwxr-xr-x. 2 48 48 6 Jan 21 02:03 reserved_resource_worker-1@dhcp130-202.gsslab.pnq2.redhat.com - drwxr-xr-x. 2 48 48 6 Jan 20 14:03 resource_manager@dhcp130-202.gsslab.pnq2.redhat.com - -Examples: - - >>> "journal" in ls_var_cache_pulp - False - >>> "/var/cache/pulp" in ls_var_cache_pulp - True -""" - - -from insights.specs import Specs -from insights.util import deprecated - -from insights import CommandParser, parser, FileListing - - -@parser(Specs.ls_var_cache_pulp) -class LsVarCachePulp(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -lan /var/cache/pulp`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarCachePulp, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsVarCachePulp, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_lib_mongodb.py b/insights/parsers/ls_var_lib_mongodb.py deleted file mode 100644 index 78e6e5b0d0..0000000000 --- a/insights/parsers/ls_var_lib_mongodb.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -LsVarLibMongodb - command ``ls -la /var/lib/mongodb`` -===================================================== - -The ``ls -la /var/lib/mongodb`` command provides information for the listing of the ``/var/lib/mongodb`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 6322200 - drwxr-xr-x. 3 mongodb mongodb 256 Jun 7 10:07 . - drwxr-xr-x. 71 root root 4096 Jun 22 10:35 .. - drwxr-xr-x. 2 mongodb mongodb 65 Jul 10 09:33 journal - -rw-------. 1 mongodb mongodb 67108864 Jul 10 09:32 local.0 - -rw-------. 1 mongodb mongodb 16777216 Jul 10 09:32 local.ns - -Examples: - - >>> "journal" in ls_var_lib_mongodb - False - >>> "/var/lib/mongodb" in ls_var_lib_mongodb - True - >>> ls_var_lib_mongodb.dir_entry('/var/lib/mongodb', 'journal')['type'] - 'd' -""" - - -from insights.specs import Specs -from insights.util import deprecated - -from .. import CommandParser, parser -from .. import FileListing - - -@parser(Specs.ls_var_lib_mongodb) -class LsVarLibMongodb(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - Parses output of ``ls -la /var/lib/mongodb`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarLibMongodb, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsVarLibMongodb, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_lib_nova_instances.py b/insights/parsers/ls_var_lib_nova_instances.py deleted file mode 100644 index 60af3837f0..0000000000 --- a/insights/parsers/ls_var_lib_nova_instances.py +++ /dev/null @@ -1,135 +0,0 @@ -''' -List files and dirs under ``/var/lib/nova/instances`` -===================================================== - -The parsers class in this module uses base parser class -``CommandParser`` & ``FileListing`` to list files & directories. - -Parsers included in this modules are: - -LsRVarLibNovaInstances - command ``ls -laR /var/lib/nova/instances`` ---------------------------------------------------------------------- - -LsVarLibNovaInstances - command ``ls -laRZ /var/lib/nova/instances`` ---------------------------------------------------------------------- -''' -from insights import CommandParser, FileListing, parser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_R_var_lib_nova_instances) -class LsRVarLibNovaInstances(CommandParser, FileListing): - ''' - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanR` instead. - - The class ``LsVarLibNovaInstances`` don't show file size when the - flag `-Z` is used. This class parses the output of ``ls -laR - /var/lib/nova/instances`` to output file listing with file size. - - Note: This issue is not seen in GNU coreutils-8.29. When the - coreutils package is updated to 8.29 on RHEL7, this parser class - can be deprecated. - - Typical output of the ``ls -laR /var/lib/nova/instances`` command is:: - - /var/lib/nova/instances: - total 4 - drwxr-xr-x. 5 nova nova 97 Feb 20 2017 . - drwxr-xr-x. 9 nova nova 111 Feb 17 2017 .. - drwxr-xr-x. 2 nova nova 54 Feb 17 2017 _base - -rw-r--r--. 1 nova nova 44 May 26 2017 compute_nodes - drwxr-xr-x. 2 nova nova 54 Feb 17 2017 e560e649-41fd-46a2-a3d2-5f4750ba2bb4 - drwxr-xr-x. 2 nova nova 93 Feb 17 2017 locks - - /var/lib/nova/instances/_base: - total 18176 - drwxr-xr-x. 2 nova nova 54 Feb 17 2017 . - drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. - -rw-r--r--. 1 qemu qemu 41126400 May 26 2017 faf1184c098da91e90290a920b8fab1ee6e1d4c4 - - /var/lib/nova/instances/e560e649-41fd-46a2-a3d2-5f4750ba2bb4: - total 2104 - drwxr-xr-x. 2 nova nova 54 Feb 17 2017 . - drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. - -rw-r--r--. 1 qemu qemu 48957 Feb 20 2017 console.log - -rw-r--r--. 1 qemu qemu 2097152 Feb 20 2017 disk - -rw-r--r--. 1 nova nova 79 Feb 17 2017 disk.info - - /var/lib/nova/instances/locks: - total 0 - drwxr-xr-x. 2 nova nova 93 Feb 17 2017 . - drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. - -rw-r--r--. 1 nova nova 0 Feb 17 2017 nova-faf1184c098da91e90290a920b8fab1ee6e1d4c4 - -rw-r--r--. 1 nova nova 0 Feb 17 2017 nova-storage-registry-lock - - - Example: - - >>> ls_r_var_lib_nova_instances.dir_entry('/var/lib/nova/instances/e560e649-41fd-46a2-a3d2-5f4750ba2bb4', 'console.log')['size'] - 48957 - ''' - def __init__(self, *args, **kwargs): - deprecated(LsRVarLibNovaInstances, "Please use the :class:`insights.parsers.ls.LSlanR` instead.", "3.5.0") - super(LsRVarLibNovaInstances, self).__init__(*args, **kwargs) - - -@parser(Specs.ls_var_lib_nova_instances) -class LsVarLibNovaInstances(CommandParser, FileListing): - ''' - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanRZ` instead. - - Parses the output of ``ls -laRZ /var/lib/nova/instances`` command - which provides the SELinux directory listings of the '/var/lib/nova/instances' directory. - - The ``ls -laRZ /var/lib/nova/instances`` command provides - information for the SELinux directory listing of the ``/var/lib/nova/instances`` directory. - - Typical output of the ``ls -laRZ /var/lib/nova/instances`` command is:: - - /var/lib/nova/instances/: - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 11415c6c-a2a5-45f0-a198-724246b96631 - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 _base - -rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 compute_nodes - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 locks - - /var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631: - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. - -rw-------. root root system_u:object_r:nova_var_lib_t:s0 console.log - -rw-r--r--. qemu qemu system_u:object_r:svirt_image_t:s0:c92,c808 disk - -rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 disk.info - - /var/lib/nova/instances/_base: - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. - -rw-r--r--. qemu qemu system_u:object_r:virt_content_t:s0 572dfdb7e1d9304342cbe1fd5e3da4ff2e55c7a6 - - /var/lib/nova/instances/locks: - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . - drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. - -rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-572dfdb7e1d9304342cbe1fd5e3da4ff2e55c7a6 - -rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-storage-registry-lock - - Examples: - - >>> '/var/lib/nova/instances/' in ls_var_lib_nova_instances - True - >>> ls_var_lib_nova_instances.files_of('/var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631') - ['console.log', 'disk', 'disk.info'] - >>> ls_var_lib_nova_instances.listings['/var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631']['entries']['console.log']['se_type'] != 'nova_var_lib_t' - False - >>> len(ls_var_lib_nova_instances.listings['/var/lib/nova/instances/locks']) - 6 - >>> ls_var_lib_nova_instances.dir_entry('/var/lib/nova/instances/locks', 'nova-storage-registry-lock')['raw_entry'] - '-rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-storage-registry-lock' - ''' - def __init__(self, *args, **kwargs): - deprecated(LsVarLibNovaInstances, "Please use the :class:`insights.parsers.ls.LSlanRZ` instead.", "3.5.0") - super(LsVarLibNovaInstances, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_lib_pcp.py b/insights/parsers/ls_var_lib_pcp.py deleted file mode 100644 index 970575d01a..0000000000 --- a/insights/parsers/ls_var_lib_pcp.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -LsVarLibPcp - command ``ls -la /var/lib/pcp`` -============================================= - -The ``ls -la /var/lib/pcp`` command provides information for the listing of the ``/var/lib/pcp`` directory. - -The parsers class in this module uses base parser class -``CommandParser`` & ``FileListing`` to list files & directories. - -Sample output of this command is:: - - total 16 - drwxr-xr-x. 4 root root 33 Dec 15 08:12 . - drwxr-xr-x. 20 root root 278 Dec 15 08:12 .. - drwxr-xr-x. 2 root root 6 Oct 3 09:37 pmcd - drwxr-xr-x. 2 root root 6 Oct 3 09:37 pmie - drwxrwxr-x. 4 root root 128 Aug 22 17:55 pmdas - -Examples: - - >>> "pmdas" in ls_var_lib_pcp - False - >>> "/var/lib/pcp" in ls_var_lib_pcp - True - >>> ls_var_lib_pcp.dir_entry('/var/lib/pcp', 'pmdas')['type'] - 'd' -""" - - -from insights.specs import Specs -from insights import CommandParser, parser -from insights.core import FileListing -from insights.util import deprecated - - -@parser(Specs.ls_var_lib_pcp) -class LsVarLibPcp(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - Parses output of ``ls -la /var/lib/pcp`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarLibPcp, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsVarLibPcp, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_lib_rpm.py b/insights/parsers/ls_var_lib_rpm.py deleted file mode 100644 index 4258080ad7..0000000000 --- a/insights/parsers/ls_var_lib_rpm.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -LsVarLibRpm - command ``ls -lan /var/lib/rpm`` -============================================== -""" - - -from insights.core import CommandParser, FileListing -from insights.core.plugins import parser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_var_lib_rpm) -class LsVarLibRpm(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -lan /var/lib/rpm`` command. - - Sample output:: - - total 172400 - drwxr-xr-x. 2 0 0 4096 Oct 19 2022 . - drwxr-xr-x. 31 0 0 4096 Nov 26 2021 .. - -rw-r--r--. 1 0 0 4034560 Apr 17 16:06 Basenames - -rw-r--r--. 1 0 0 8192 Apr 17 16:06 Conflictname - -rw-r--r--. 1 0 0 16384 Apr 17 10:43 Obsoletename - -rw-r--r--. 1 0 0 165253120 Apr 17 16:06 Packages - -rw-r--r--. 1 0 0 2461696 Apr 17 16:06 Providename - -rw-r--r--. 1 0 0 8192 Apr 17 10:42 Recommendname - - Examples: - >>> type(var_lib_rpm) - - >>> var_lib_rpm.dir_contains('/var/lib/rpm', 'Packages') - True - >>> var_lib_rpm.files_of('/var/lib/rpm') - ['Basenames', 'Conflictname', 'Obsoletename', 'Packages', 'Providename', 'Recommendname'] - - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarLibRpm, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsVarLibRpm, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_lib_rsyslog.py b/insights/parsers/ls_var_lib_rsyslog.py deleted file mode 100644 index 7723a2b7dc..0000000000 --- a/insights/parsers/ls_var_lib_rsyslog.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -LsVarLibRsyslog - command ``ls -lZ /var/lib/rsyslog`` -====================================================== -""" - - -from insights.core import CommandParser, FileListing -from insights.core.plugins import parser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_var_lib_rsyslog) -class LsVarLibRsyslog(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanZ` instead. - - 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' - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarLibRsyslog, "Please use the :class:`insights.parsers.ls.LSlanZ` instead.", "3.5.0") - super(LsVarLibRsyslog, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_log.py b/insights/parsers/ls_var_log.py deleted file mode 100644 index 942cec7b36..0000000000 --- a/insights/parsers/ls_var_log.py +++ /dev/null @@ -1,64 +0,0 @@ -""" -LsVarLog - command ``ls -laR /var/log`` -======================================= - -This parser reads the ``/var/log`` directory listings and uses the FileListing -parser class to provide a common access to them. - -Examples: - - >>> varlog = shared[LsVarLog] - >>> '/var/log' in varlog - True - >>> varlog.dir_contains('/var/log', 'messages') - True - >>> messages = varlog.dir_entry('/var/log', 'messages') - >>> messages['type'] - '-' - >>> messages['perms'] - 'rw-------' -""" - -from .. import FileListing, parser, CommandParser - -from insights.util.file_permissions import FilePermissions -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_var_log) -class LsVarLog(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead (NOT ``LSlaR``). - - A parser for accessing "ls -laR /var/log". - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarLog, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsVarLog, self).__init__(*args, **kwargs) - - def get_filepermissions(self, dir_name_where_to_search, dir_or_file_name_to_get): - """ - Returns a FilePermissions object, if found, for the specified dir or - file name in the specified directory. The directory must be specified - by the full path without trailing slash. The dir or file name to get - must be specified by the name only (without path). - - This is provided for several parsers which rely on this functionality, - and may be deprecated and removed in the future. - - Args: - dir_name_where_to_search (string): Full path without trailing - slash where to search. - dir_or_file_name_to_getl (string): Name of the dir or file to get - FilePermissions for. - - Returns: - FilePermissions: If found or None if not found. - """ - if dir_name_where_to_search in self: - d = self.listings[dir_name_where_to_search]['entries'] - if dir_or_file_name_to_get in d: - return FilePermissions(d[dir_or_file_name_to_get]['raw_entry']) diff --git a/insights/parsers/ls_var_opt_mssql.py b/insights/parsers/ls_var_opt_mssql.py deleted file mode 100644 index 2adc363e10..0000000000 --- a/insights/parsers/ls_var_opt_mssql.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -LsDVarOptMSSql - command ``ls -ld /var/opt/mssql`` -================================================== -""" -from insights.specs import Specs -from .. import CommandParser, parser, FileListing -from insights.util import deprecated - - -@parser(Specs.ls_var_opt_mssql) -class LsDVarOptMSSql(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead (NOT ``LSld``). - - Parses output of ``ls -ld /var/opt/mssql`` command. - - The ``ls -ld /var/opt/mssql`` command provides information for the listing - of the ``/var/opt/mssql`` directory. See ``FileListing`` class for addtional - information. - - - Sample ``ls -ld /var/opt/mssql`` output:: - - drwxrwx---. 5 root root 58 Apr 16 07:20 /var/opt/mssql - - Examples: - - >>> content.listing_of('/var/opt/mssql').get('/var/opt/mssql').get('owner') - 'root' - >>> content.listing_of('/var/opt/mssql').get('/var/opt/mssql').get('group') - 'root' - """ - def __init__(self, *args, **kwargs): - deprecated(LsDVarOptMSSql, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsDVarOptMSSql, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_opt_mssql_log.py b/insights/parsers/ls_var_opt_mssql_log.py deleted file mode 100644 index affd5a6b4b..0000000000 --- a/insights/parsers/ls_var_opt_mssql_log.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -LsVarOptMssqlLog - command ``ls -la /var/opt/mssql/log`` -======================================================== - -This parser reads the ``/var/opt/mssql/log`` directory listings and uses the -FileListing parser class to provide a common access to them. - -""" - -from insights import FileListing, parser, CommandParser -from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.ls_var_opt_mssql_log) -class LsVarOptMssqlLog(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - A parser for accessing "ls -la /var/opt/mssql/log". - - Examples: - >>> '/var/opt/mssql/log' in ls_mssql_log - True - >>> ls_mssql_log.dir_contains('/var/opt/mssql/log', 'messages') - False - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarOptMssqlLog, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsVarOptMssqlLog, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_run.py b/insights/parsers/ls_var_run.py deleted file mode 100644 index f96ecbf096..0000000000 --- a/insights/parsers/ls_var_run.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -LsVarRun - command ``ls -lnL /var/run`` -======================================= - -The ``ls -lnL /var/run`` command provides information for the listing of the -``/var/run`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 20 - drwx--x---. 2 0 984 40 May 15 09:29 openvpn - drwxr-xr-x. 2 0 0 40 May 15 09:30 plymouth - drwxr-xr-x. 2 0 0 40 May 15 09:29 ppp - drwxr-xr-x. 2 75 75 40 May 15 09:29 radvd - -rw-r--r--. 1 0 0 5 May 15 09:30 rhnsd.pid - drwxr-xr-x. 2 0 0 60 May 30 09:31 rhsm - drwx------. 2 32 32 40 May 15 09:29 rpcbind - -r--r--r--. 1 0 0 0 May 17 16:26 rpcbind.lock - -Examples: - - >>> "rhnsd.pid" in ls_var_run - False - >>> "/var/run" in ls_var_run - True - >>> ls_var_run.dir_entry('/var/run', 'openvpn')['type'] - 'd' -""" - - -from insights.specs import Specs -from insights.util import deprecated - -from .. import FileListing -from .. import parser - - -@parser(Specs.ls_var_run) -class LsVarRun(FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanL` instead. - - Parses output of ``ls -lnL /var/run`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarRun, "Please use the :class:`insights.parsers.ls.LSlanL` instead.", "3.5.0") - super(LsVarRun, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_spool_clientmq.py b/insights/parsers/ls_var_spool_clientmq.py deleted file mode 100644 index 4d76a1f523..0000000000 --- a/insights/parsers/ls_var_spool_clientmq.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -LsVarSpoolClientmq - command ``ls -ln /var/spool/clientmqueue`` -=============================================================== - -The ``ls -ln /var/spool/clientmqueue`` command provides information for the listing of the ``/var/spool/clientmqueue`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 40 - -rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6Wilr002718 - -rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6WixJ002715 - -rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6WjP6002721 - -rw-rw---- 1 51 51 817 Jul 11 03:35 dfw6B7Z8BB002906 - -rw-rw---- 1 51 51 817 Jul 11 04:02 dfw6B822T0011150 - -Examples: - - >>> "dfw6B6Wilr002718" in ls_var_spool_clientmq - False - >>> "/var/spool/clientmqueue" in ls_var_spool_clientmq - True - >>> ls_var_spool_clientmq.dir_entry('/var/spool/clientmqueue', 'dfw6B6Wilr002718')['type'] - '-' -""" - -from insights.specs import Specs -from insights.util import deprecated - -from .. import CommandParser, parser -from .. import FileListing - - -@parser(Specs.ls_var_spool_clientmq) -class LsVarSpoolClientmq(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -ln /var/spool/clientmqueue`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarSpoolClientmq, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsVarSpoolClientmq, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_spool_postfix_maildrop.py b/insights/parsers/ls_var_spool_postfix_maildrop.py deleted file mode 100644 index e616f3c5ce..0000000000 --- a/insights/parsers/ls_var_spool_postfix_maildrop.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -LsVarSpoolPostfixMaildrop - command ``ls -ln /var/spool/postfix/maildrop`` -========================================================================== - -The ``ls -ln /var/spool/postfix/maildrop`` command provides information for the listing of the ``/var/spool/postfix/maildrop`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - total 20 - -rwxr--r--. 1 0 90 258 Jul 11 15:54 55D6821C286 - -rwxr--r--. 1 0 90 282 Jul 11 15:54 5852121C284 - -rwxr--r--. 1 0 90 258 Jul 11 15:54 9FFEC21C287 - -rwxr--r--. 1 0 90 258 Jul 11 15:54 E9A4521C285 - -rwxr--r--. 1 0 90 258 Jul 11 15:54 EA60F21C288 - -Examples: - - >>> "55D6821C286" in ls_var_spool_postfix_maildrop - False - >>> "/var/spool/postfix/maildrop" in ls_var_spool_postfix_maildrop - True - >>> ls_var_spool_postfix_maildrop.dir_entry('/var/spool/postfix/maildrop', '55D6821C286')['type'] - '-' -""" - - -from insights.specs import Specs -from insights.util import deprecated - -from .. import CommandParser, parser -from .. import FileListing - - -@parser(Specs.ls_var_spool_postfix_maildrop) -class LsVarSpoolPostfixMaildrop(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlan` instead. - - Parses output of ``ls -ln /var/spool/postfix/maildrop`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarSpoolPostfixMaildrop, "Please use the :class:`insights.parsers.ls.LSlan` instead.", "3.5.0") - super(LsVarSpoolPostfixMaildrop, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_tmp.py b/insights/parsers/ls_var_tmp.py deleted file mode 100644 index 0e2ecb4bc0..0000000000 --- a/insights/parsers/ls_var_tmp.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -LsVarTmp - command ``ls -ln /var/tmp`` -====================================== - -The ``ls -ln /var/tmp`` command provides information for the listing of the -``/var/tmp`` directory. - -Sample input is shown in the Examples. See ``FileListing`` class for -additional information. - -Sample directory list:: - - /var/tmp: - total 20 - drwxr-xr-x. 2 0 0 4096 Mar 26 02:25 a1 - drwxr-xr-x. 2 0 0 4096 Mar 26 02:25 a2 - drwxr-xr-x. 2 0 0 4096 Apr 28 2018 foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad - -Examples: - - >>> "a1" in ls_var_tmp - False - >>> "/var/tmp" in ls_var_tmp - True - >>> ls_var_tmp.dir_entry('/var/tmp', 'a1')['type'] - 'd' -""" - - -from insights.specs import Specs -from insights.core.filters import add_filter -from insights.util import deprecated - -from .. import FileListing -from .. import parser, CommandParser - - -add_filter(Specs.ls_var_tmp, "/var/tmp") - - -@parser(Specs.ls_var_tmp) -class LsVarTmp(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSlanFiltered` instead. - - Parses output of ``ls -ln /var/tmp`` command. - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarTmp, "Please use the :class:`insights.parsers.ls.LSlanFiltered` instead.", "3.5.0") - super(LsVarTmp, self).__init__(*args, **kwargs) diff --git a/insights/parsers/ls_var_www_perms.py b/insights/parsers/ls_var_www_perms.py deleted file mode 100644 index bf1ae6ce09..0000000000 --- a/insights/parsers/ls_var_www_perms.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -LsVarWwwPerms - command ``/bin/ls -la /dev/null /var/www`` -========================================================== -""" - -from insights.core import CommandParser, FileListing -from insights.core.plugins import parser -from insights.specs import Specs -from insights.util import deprecated -from insights.util.file_permissions import FilePermissions - - -@parser(Specs.ls_var_www) -class LsVarWwwPerms(CommandParser, FileListing): - """ - .. warning:: - This class is deprecated and will be removed from 3.5.0. - Please use the :class:`insights.parsers.ls.LSla` instead. - - Class for parsing ``/bin/ls -la /dev/null /var/www`` command. - - Attributes: - file_permissions (list): list of `FilePermissions` objects for every file from the output - - Sample output of this command is:: - - crw-rw-rw-. 1 root root 1, 3 Dec 18 09:18 /dev/null - - /var/www: - total 16 - drwxr-xr-x. 4 root root 33 Dec 15 08:12 . - drwxr-xr-x. 20 root root 278 Dec 15 08:12 .. - drwxr-xr-x. 2 root root 6 Oct 3 09:37 cgi-bin - drwxr-xr-x. 2 root root 6 Oct 3 09:37 html - - Examples: - - >>> type(ls_var_www_perms) - - >>> ls_var_www_perms.file_permissions[2] - FilePermissions(cgi-bin) - >>> ls_var_www_perms.file_permissions[2].line - 'drwxr-xr-x. 2 root root 6 Oct 3 09:37 cgi-bin' - """ - def __init__(self, *args, **kwargs): - deprecated(LsVarWwwPerms, "Please use the :class:`insights.parsers.ls.LSla` instead.", "3.5.0") - super(LsVarWwwPerms, self).__init__(*args, **kwargs) - - def parse_content(self, content): - super(LsVarWwwPerms, self).parse_content(content) - - self.file_permissions = [] - if "/var/www" in self: - for filename, info in sorted(self.listing_of("/var/www").items()): - self.file_permissions.append(FilePermissions(info["raw_entry"])) diff --git a/insights/parsers/rpm_v_packages.py b/insights/parsers/rpm_v_packages.py index 9ba280aeb7..12aa332620 100644 --- a/insights/parsers/rpm_v_packages.py +++ b/insights/parsers/rpm_v_packages.py @@ -4,74 +4,14 @@ Parsers provided in this module includes: -RpmVPackages - command ``/bin/rpm -V `` -------------------------------------------------- - RpmVPackage - command ``/bin/rpm -V `` ----------------------------------------------- - """ from insights.core import CommandParser from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs -from insights.util import deprecated - - -@parser(Specs.rpm_V_packages) -class RpmVPackages(CommandParser): - """ - Class for parsing ``/bin/rpm -V `` command. - - .. warning:: - This class is deprecated and will be removed from 3.5.0. - - For Insights Advisor Rules, it's recommended to use the - :class:`insights.parsers.rpm_v_packages.RpmVPackage` and add the - ``'coreutils', 'procps', 'procps-ng', 'shadow-utils', 'passwd', 'sudo', 'chrony', 'findutils', 'glibc'`` - to the filter list of `Specs.rpm_V_package_list` instead. - - Attributes: - packages_list (list of dictionaries): every dictionary contains information about one entry - - Sample output of this command is:: - - package procps is not installed - ..?...... c /etc/sudoers - ..?...... /usr/bin/sudo - ..?...... /usr/bin/sudoreplay - missing /var/db/sudo/lectured (Permission denied) - - Examples: - >>> type(rpm_v_packages) - - >>> len(rpm_v_packages.packages_list) - 5 - >>> sorted(rpm_v_packages.packages_list[0].items()) - [('attributes', None), ('file', None), ('line', 'package procps is not installed'), ('mark', None)] - >>> sorted(rpm_v_packages.packages_list[1].items()) - [('attributes', '..?......'), ('file', '/etc/sudoers'), ('line', '..?...... c /etc/sudoers'), ('mark', 'c')] -""" - - def __init__(self, *args, **kwargs): - deprecated(RpmVPackages, "Please use the :class:`insights.parsers.rpm_v_packages.RpmVPackage` instead.", "3.5.0") - super(RpmVPackages, self).__init__(*args, **kwargs) - - def parse_content(self, content): - self.packages_list = [] - - for line in content: - line_parts = line.split() - if "package" in line_parts[0] or "missing" in line_parts[0]: - entry = {"line": line.strip(), "attributes": None, "mark": None, "file": None} - elif len(line_parts) == 3: - entry = {"line": line.strip(), "attributes": line_parts[0], "mark": line_parts[1], - "file": line_parts[2]} - else: - entry = {"line": line.strip(), "attributes": line_parts[0], "mark": None, - "file": line_parts[1]} - self.packages_list.append(entry) @parser(Specs.rpm_V_package) @@ -99,7 +39,7 @@ class RpmVPackage(CommandParser): 4 >>> sorted(rpm_v_pkg.discrepancies[0].items()) [('attributes', '..?......'), ('file', '/etc/sudoers'), ('line', '..?...... c /etc/sudoers'), ('mark', 'c')] -""" + """ def parse_content(self, content): self.discrepancies = [] @@ -116,11 +56,19 @@ def parse_content(self, content): if "missing" in line_parts[0]: entry = {"line": line.strip(), "attributes": None, "mark": None, "file": None} elif len(line_parts) == 3: - entry = {"line": line.strip(), "attributes": line_parts[0], "mark": line_parts[1], - "file": line_parts[2]} + entry = { + "line": line.strip(), + "attributes": line_parts[0], + "mark": line_parts[1], + "file": line_parts[2], + } else: - entry = {"line": line.strip(), "attributes": line_parts[0], "mark": None, - "file": line_parts[1]} + entry = { + "line": line.strip(), + "attributes": line_parts[0], + "mark": None, + "file": line_parts[1], + } self.discrepancies.append(entry) if not self.discrepancies: diff --git a/insights/specs/__init__.py b/insights/specs/__init__.py index de681d705a..d791b69df3 100644 --- a/insights/specs/__init__.py +++ b/insights/specs/__init__.py @@ -344,7 +344,6 @@ class Specs(SpecSet): leapp_migration_results = RegistryPoint() leapp_report = RegistryPoint() ld_library_path_of_user = RegistryPoint(no_obfuscate=['hostname', 'ip']) - ldif_config = RegistryPoint(multi_output=True) libssh_client_config = RegistryPoint(filterable=True) libssh_server_config = RegistryPoint(filterable=True) libvirtd_log = RegistryPoint(filterable=True) @@ -379,42 +378,11 @@ class Specs(SpecSet): ls_laRZ_dirs = RegistryPoint(filterable=True) ls_laZ = RegistryPoint() ls_laZ_dirs = RegistryPoint(filterable=True) - # Old `ls` Specs - ls_R_var_lib_nova_instances = RegistryPoint() + # Useful individual `ls` Specs ls_boot = RegistryPoint() ls_dev = RegistryPoint() - ls_disk = RegistryPoint() - ls_docker_volumes = RegistryPoint() - ls_edac_mc = RegistryPoint() - ls_etc = RegistryPoint() - ls_etc_ssh = RegistryPoint() - ls_ipa_idoverride_memberof = RegistryPoint() - ls_krb5_sssd = RegistryPoint() - ls_lib_firmware = RegistryPoint() - ls_ocp_cni_openshift_sdn = RegistryPoint() - ls_origin_local_volumes_pods = RegistryPoint() - ls_osroot = RegistryPoint() - ls_rsyslog_errorfile = RegistryPoint() ls_sys_firmware = RegistryPoint() - ls_systemd_units = RegistryPoint() - ls_tmp = RegistryPoint(filterable=True) - ls_usr_bin = RegistryPoint(filterable=True) - ls_usr_lib64 = RegistryPoint(filterable=True) - ls_usr_sbin = RegistryPoint(filterable=True) - ls_var_cache_pulp = RegistryPoint() - ls_var_lib_mongodb = RegistryPoint() - ls_var_lib_nova_instances = RegistryPoint() - ls_var_lib_pcp = RegistryPoint() - ls_var_lib_rpm = RegistryPoint() - ls_var_lib_rsyslog = RegistryPoint() - ls_var_log = RegistryPoint() - ls_var_opt_mssql = RegistryPoint() - ls_var_opt_mssql_log = RegistryPoint() - ls_var_run = RegistryPoint() - ls_var_spool_clientmq = RegistryPoint() - ls_var_spool_postfix_maildrop = RegistryPoint() - ls_var_tmp = RegistryPoint(filterable=True) - ls_var_www = RegistryPoint() + # ^ End of ls lsattr = RegistryPoint(no_obfuscate=['hostname', 'ip']) lsattr_files_or_dirs = RegistryPoint(filterable=True) lsblk = RegistryPoint() @@ -670,7 +638,6 @@ class Specs(SpecSet): route = RegistryPoint() rpm_V_package = RegistryPoint(multi_output=True, no_obfuscate=['hostname', 'ip']) rpm_V_package_list = RegistryPoint(filterable=True) - rpm_V_packages = RegistryPoint(no_obfuscate=['hostname', 'ip']) rpm_ostree_status = RegistryPoint() rpm_pkgs = RegistryPoint(no_obfuscate=['ip']) rsyslog_conf = RegistryPoint(filterable=True, multi_output=True) diff --git a/insights/specs/core3_archive.py b/insights/specs/core3_archive.py index 018be7dedc..ff2e6c423d 100644 --- a/insights/specs/core3_archive.py +++ b/insights/specs/core3_archive.py @@ -3,10 +3,10 @@ in the meta_data directory. This happens when the client itself collects the data and puts it into the archive. """ + from functools import partial from insights.core.context import SerializedArchiveContext -from insights.core.spec_factory import MetadataProvider # deprecated from insights.core.spec_factory import simple_file from insights.specs import Specs @@ -14,7 +14,4 @@ class Core3Specs(Specs): - ansible_host = simple_file("/ansible_host", kind=MetadataProvider) - branch_info = simple_file("/branch_info", kind=MetadataProvider) - display_name = simple_file("/display_name", kind=MetadataProvider) - version_info = simple_file("/version_info", kind=MetadataProvider) + pass diff --git a/insights/specs/default.py b/insights/specs/default.py index 9e842311ab..b78f73c11e 100644 --- a/insights/specs/default.py +++ b/insights/specs/default.py @@ -111,22 +111,6 @@ def _make_rpm_formatter(fmt=None): return r"\{" + ",".join(fmt) + r"\}\n" -_etc_and_sub_dirs = sorted( - [ - "/etc", - "/etc/pki/tls/private", - "/etc/pki/tls/certs", - "/etc/pki/ovirt-vmconsole", - "/etc/nova/migration", - "/etc/sysconfig", - "/etc/cloud/cloud.cfg.d", - "/etc/rc.d/init.d", - "/etc/selinux/targeted/policy", - "/etc/watchdog.d/", - ] -) -""" List of directories for spec `ls_etc` """ - _rpm_format = _make_rpm_formatter() """ Query format for specs `installed_rpms` and `container_installed_rpms` """ @@ -319,8 +303,8 @@ class DefaultSpecs(Specs): dracut_kdump_capture_service = simple_file( "/usr/lib/dracut/modules.d/99kdumpbase/kdump-capture.service" ) - dumpe2fs_h = foreach_execute(mount_ds.dumpdev_list, "/sbin/dumpe2fs -h %s") dse_ldif = glob_file("/etc/dirsrv/*/dse.ldif") + dumpe2fs_h = foreach_execute(mount_ds.dumpdev_list, "/sbin/dumpe2fs -h %s") du_dirs = foreach_execute(dir_list.du_dir_list, "/bin/du -s -k %s") # empty filter duplicate_machine_id = machine_ids.dup_machine_id_info eap_json_reports = foreach_collect(eap_reports.eap_report_files, "%s") @@ -514,38 +498,10 @@ class DefaultSpecs(Specs): ls_lanRL = command_with_args('/bin/ls -lanRl %s', ls.list_with_lanRL, keep_rc=True) ls_laRZ = command_with_args('/bin/ls -laRZ %s', ls.list_with_laRZ, keep_rc=True) ls_laZ = command_with_args('/bin/ls -laZ %s', ls.list_with_laZ, keep_rc=True) - # Old `ls` Specs - ls_R_var_lib_nova_instances = simple_command("/bin/ls -laR /var/lib/nova/instances") + # Useful individual `ls` Specs ls_boot = simple_command("/bin/ls -lanR /boot") ls_dev = simple_command("/bin/ls -lanR /dev") - ls_disk = simple_command("/bin/ls -lanR /dev/disk") - ls_edac_mc = simple_command("/bin/ls -lan /sys/devices/system/edac/mc") - ls_etc = simple_command("/bin/ls -lan {0}".format(' '.join(_etc_and_sub_dirs)), keep_rc=True) - ls_etc_ssh = simple_command("/bin/ls -lanL /etc/ssh") - ls_ipa_idoverride_memberof = simple_command( - "/bin/ls -lan /usr/share/ipa/ui/js/plugins/idoverride-memberof" - ) - ls_lib_firmware = simple_command("/bin/ls -lanR /lib/firmware") - ls_osroot = simple_command("/bin/ls -lan /") ls_sys_firmware = simple_command("/bin/ls -lanR /sys/firmware") - ls_systemd_units = simple_command( - "/bin/ls -lanRL /etc/systemd /run/systemd /usr/lib/systemd /usr/local/lib/systemd /usr/local/share/systemd /usr/share/systemd", - keep_rc=True, - ) - 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_var_lib_rpm = simple_command("/bin/ls -lan /var/lib/rpm") - ls_var_lib_rsyslog = simple_command("/bin/ls -lZ /var/lib/rsyslog") - ls_var_log = simple_command("/bin/ls -la /var/log /var/log/audit") - ls_var_opt_mssql = simple_command("/bin/ls -ld /var/opt/mssql") - ls_var_opt_mssql_log = simple_command("/bin/ls -la /var/opt/mssql/log") - ls_var_run = simple_command("/bin/ls -lnL /var/run") - ls_var_spool_clientmq = simple_command("/bin/ls -ln /var/spool/clientmqueue") - ls_var_spool_postfix_maildrop = simple_command("/bin/ls -ln /var/spool/postfix/maildrop") - ls_var_www = simple_command( - "/bin/ls -la /dev/null /var/www" - ) # https://github.com/RedHatInsights/insights-core/issues/827 lsattr = command_with_args("/bin/lsattr %s", lsattr.paths_to_lsattr) lsblk = simple_command("/bin/lsblk") lsblk_pairs = simple_command( @@ -780,11 +736,6 @@ class DefaultSpecs(Specs): ) rndc_status = simple_command("/usr/sbin/rndc status") ros_config = simple_file("/var/lib/pcp/config/pmlogger/config.ros") - rpm_V_packages = simple_command( - "/bin/rpm -V coreutils procps procps-ng shadow-utils passwd sudo chrony findutils glibc systemd", - keep_rc=True, - signum=signal.SIGTERM, - ) rpm_V_package = foreach_execute( rpm_pkgs.rpm_v_pkg_list, "/bin/rpm -V %s", keep_rc=True, signum=signal.SIGTERM ) diff --git a/insights/specs/insights_archive.py b/insights/specs/insights_archive.py index ae53d31d6e..6d94900c87 100644 --- a/insights/specs/insights_archive.py +++ b/insights/specs/insights_archive.py @@ -23,24 +23,50 @@ class InsightsArchiveSpecs(Specs): alternatives_display_python = simple_file("insights_commands/alternatives_--display_python") auditctl_rules = simple_file("insights_commands/auditctl_-l") auditctl_status = simple_file("insights_commands/auditctl_-s") - aws_instance_id_doc = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_aws_instance_id_doc") - aws_instance_id_pkcs7 = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_aws_instance_id_pkcs7") + aws_instance_id_doc = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_aws_instance_id_doc" + ) + aws_instance_id_pkcs7 = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_aws_instance_id_pkcs7" + ) awx_manage_check_license = simple_file("insights_commands/awx-manage_check_license") - awx_manage_print_settings = simple_file("insights_commands/awx-manage_print_settings_INSIGHTS_TRACKING_STATE_SYSTEM_UUID_INSTALL_UUID_TOWER_URL_BASE_AWX_CLEANUP_PATHS_AWX_PROOT_BASE_PATH_LOG_AGGREGATOR_ENABLED_LOG_AGGREGATOR_LEVEL_--format_json") - azure_instance_id = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_id") - azure_instance_type = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_type") - azure_instance_plan = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_plan") + awx_manage_print_settings = simple_file( + "insights_commands/awx-manage_print_settings_INSIGHTS_TRACKING_STATE_SYSTEM_UUID_INSTALL_UUID_TOWER_URL_BASE_AWX_CLEANUP_PATHS_AWX_PROOT_BASE_PATH_LOG_AGGREGATOR_ENABLED_LOG_AGGREGATOR_LEVEL_--format_json" + ) + azure_instance_id = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_id" + ) + azure_instance_type = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_type" + ) + azure_instance_plan = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_azure_instance_plan" + ) blkid = simple_file("insights_commands/blkid_-c_.dev.null") brctl_show = simple_file("insights_commands/brctl_show") - ceph_insights = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_ceph_insights") - ceph_osd_dump = first_file(["insights_commands/ceph_osd_dump_-f_json-pretty", "insights_commands/ceph_osd_dump_-f_json"]) - ceph_osd_tree = first_file(["insights_commands/ceph_osd_tree_-f_json-pretty", "insights_commands/ceph_osd_tree_-f_json"]) + ceph_insights = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_ceph_insights" + ) + ceph_osd_dump = first_file( + [ + "insights_commands/ceph_osd_dump_-f_json-pretty", + "insights_commands/ceph_osd_dump_-f_json", + ] + ) + ceph_osd_tree = first_file( + [ + "insights_commands/ceph_osd_tree_-f_json-pretty", + "insights_commands/ceph_osd_tree_-f_json", + ] + ) ceph_v = simple_file("insights_commands/ceph_-v") - certificates_enddate = first_file([ - "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_.etc.ipa_.etc.tower.tower.cert_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName", - "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_.etc.ipa_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName", - "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName" - ]) + certificates_enddate = first_file( + [ + "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_.etc.ipa_.etc.tower.tower.cert_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName", + "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_.etc.ipa_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName", + "insights_commands/find_.etc.origin.node_.etc.origin.master_.etc.pki_-type_f_-exec_.usr.bin.openssl_x509_-noout_-enddate_-in_-exec_echo_FileName", + ] + ) chkconfig = simple_file("insights_commands/chkconfig_--list") chronyc_sources = simple_file("insights_commands/chronyc_sources") corosync_cmapctl = glob_file("insights_commands/corosync-cmapctl*") @@ -80,15 +106,35 @@ class InsightsArchiveSpecs(Specs): firewall_cmd_list_all_zones = simple_file("insights_commands/firewall-cmd_--list-all-zones") fw_devices = simple_file("insights_commands/fwupdagent_get-devices") fw_security = simple_file("insights_commands/fwupdagent_security_--force") - gcp_instance_type = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_gcp_instance_type") - gcp_license_codes = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_gcp_license_codes") + gcp_instance_type = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_gcp_instance_type" + ) + gcp_license_codes = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_gcp_license_codes" + ) getcert_list = simple_file("insights_commands/getcert_list") getconf_page_size = simple_file("insights_commands/getconf_PAGE_SIZE") getenforce = simple_file("insights_commands/getenforce") getsebool = simple_file("insights_commands/getsebool_-a") - grubenv = first_file(["insights_commands/grub2-editenv_list", "/boot/grub2/grubenv", "/boot/efi/EFI/redhat/grubenv"]) - grub1_config_perms = first_file(["insights_commands/ls_-lH_.boot.grub.grub.conf", "insights_commands/ls_-l_.boot.grub.grub.conf"]) - grub_config_perms = first_file(["insights_commands/ls_-lH_.boot.grub2.grub.cfg", "insights_commands/ls_-l_.boot.grub2.grub.cfg"]) + grubenv = first_file( + [ + "insights_commands/grub2-editenv_list", + "/boot/grub2/grubenv", + "/boot/efi/EFI/redhat/grubenv", + ] + ) + grub1_config_perms = first_file( + [ + "insights_commands/ls_-lH_.boot.grub.grub.conf", + "insights_commands/ls_-l_.boot.grub.grub.conf", + ] + ) + grub_config_perms = first_file( + [ + "insights_commands/ls_-lH_.boot.grub2.grub.cfg", + "insights_commands/ls_-l_.boot.grub2.grub.cfg", + ] + ) grubby_default_index = simple_file("insights_commands/grubby_--default-index") grubby_default_kernel = simple_file("insights_commands/grubby_--default-kernel") gluster_v_info = simple_file("insights_commands/gluster_volume_info") @@ -101,7 +147,7 @@ class InsightsArchiveSpecs(Specs): "/etc/httpd/conf/httpd.conf", "/etc/httpd/conf.d/*.conf", "/etc/httpd/conf.d/*/*.conf", - "/etc/httpd/conf.modules.d/*.conf" + "/etc/httpd/conf.modules.d/*.conf", ] ) httpd_conf_scl_httpd24 = glob_file( @@ -109,7 +155,7 @@ class InsightsArchiveSpecs(Specs): "/opt/rh/httpd24/root/etc/httpd/conf/httpd.conf", "/opt/rh/httpd24/root/etc/httpd/conf.d/*.conf", "/opt/rh/httpd24/root/etc/httpd/conf.d/*/*.conf", - "/opt/rh/httpd24/root/etc/httpd/conf.modules.d/*.conf" + "/opt/rh/httpd24/root/etc/httpd/conf.modules.d/*.conf", ] ) httpd_conf_scl_jbcs_httpd24 = glob_file( @@ -117,11 +163,13 @@ class InsightsArchiveSpecs(Specs): "/opt/rh/jbcs-httpd24/root/etc/httpd/conf/httpd.conf", "/opt/rh/jbcs-httpd24/root/etc/httpd/conf.d/*.conf", "/opt/rh/jbcs-httpd24/root/etc/httpd/conf.d/*/*.conf", - "/opt/rh/jbcs-httpd24/root/etc/httpd/conf.modules.d/*.conf" + "/opt/rh/jbcs-httpd24/root/etc/httpd/conf.modules.d/*.conf", ] ) httpd_M = glob_file("insights_commands/*httpd*_-M") - httpd_on_nfs = simple_file("insights_commands/python_-m_insights.tools.cat_--no-header_httpd_on_nfs") + httpd_on_nfs = simple_file( + "insights_commands/python_-m_insights.tools.cat_--no-header_httpd_on_nfs" + ) httpd_V = glob_file("insights_commands/*httpd*_-V") initctl_lst = simple_file("insights_commands/initctl_--system_list") ip6tables = simple_file("insights_commands/ip6tables-save") @@ -144,32 +192,11 @@ class InsightsArchiveSpecs(Specs): lpstat_p = simple_file("insights_commands/lpstat_-p") ls_boot = simple_file("insights_commands/ls_-lanR_.boot") ls_dev = simple_file("insights_commands/ls_-lanR_.dev") - ls_disk = simple_file("insights_commands/ls_-lanR_.dev.disk") - ls_edac_mc = simple_file("insights_commands/ls_-lan_.sys.devices.system.edac.mc") - ls_etc = first_file(["insights_commands/ls_-lan_.etc_.etc.cloud.cloud.cfg.d_.etc.nova.migration_.etc.pki.ovirt-vmconsole_.etc.pki.tls.certs_.etc.pki.tls.private_.etc.rc.d.init.d_.etc.selinux.targeted.policy_.etc.sysconfig_.etc.watchdog.d", "insights_commands/ls_-lan_.etc_.etc.cloud.cloud.cfg.d_.etc.nova.migration_.etc.pki.ovirt-vmconsole_.etc.pki.tls.certs_.etc.pki.tls.private_.etc.rc.d.init.d_.etc.selinux.targeted.policy_.etc.sysconfig", "insights_commands/ls_-lan_.etc_.etc.cloud.cloud.cfg.d_.etc.nova.migration_.etc.pki.ovirt-vmconsole_.etc.pki.tls.certs_.etc.pki.tls.private_.etc.rc.d.init.d_.etc.sysconfig"]) - ls_etc_ssh = simple_file("insights_commands/ls_-lanL_.etc.ssh") - ls_ipa_idoverride_memberof = simple_file("insights_commands/ls_-lan_.usr.share.ipa.ui.js.plugins.idoverride-memberof") - ls_lib_firmware = simple_file("insights_commands/ls_-lanR_.lib.firmware") - ls_osroot = simple_file("insights_commands/ls_-lan") ls_sys_firmware = simple_file("insights_commands/ls_-lanR_.sys.firmware") - ls_systemd_units = first_file([ - "insights_commands/ls_-lanRL_.etc.systemd_.run.systemd_.usr.lib.systemd_.usr.local.lib.systemd_.usr.local.share.systemd_.usr.share.systemd", - "insights_commands/ls_-lanRL_.etc.systemd_.run.systemd_.usr.lib.systemd_.usr.local.lib.systemd" - ]) - ls_tmp = simple_file("insights_commands/ls_-la_.tmp") - ls_usr_bin = simple_file("insights_commands/ls_-lan_.usr.bin") - ls_usr_lib64 = simple_file("insights_commands/ls_-lan_.usr.lib64") - ls_var_lib_rpm = simple_file("insights_commands/ls_-lan_.var.lib.rpm") - ls_var_lib_rsyslog = simple_file("insights_commands/ls_-lZ_.var.lib.rsyslog") - ls_var_log = simple_file("insights_commands/ls_-la_.var.log_.var.log.audit") - ls_var_opt_mssql = simple_file("insights_commands/ls_-ld_.var.opt.mssql") - ls_var_opt_mssql_log = simple_file("insights_commands/ls_-la_.var.opt.mssql.log") - ls_var_spool_clientmq = simple_file("insights_commands/ls_-ln_.var.spool.clientmqueue") - ls_var_spool_postfix_maildrop = simple_file("insights_commands/ls_-ln_.var.spool.postfix.maildrop") - ls_var_run = simple_file("insights_commands/ls_-lnL_.var.run") - ls_var_www = simple_file("insights_commands/ls_-la_.dev.null_.var.www") lsblk = simple_file("insights_commands/lsblk") - lsblk_pairs = simple_file("insights_commands/lsblk_-P_-o_NAME_KNAME_MAJ_MIN_FSTYPE_MOUNTPOINT_LABEL_UUID_RA_RO_RM_MODEL_SIZE_STATE_OWNER_GROUP_MODE_ALIGNMENT_MIN-IO_OPT-IO_PHY-SEC_LOG-SEC_ROTA_SCHED_RQ-SIZE_TYPE_DISC-ALN_DISC-GRAN_DISC-MAX_DISC-ZERO") + lsblk_pairs = simple_file( + "insights_commands/lsblk_-P_-o_NAME_KNAME_MAJ_MIN_FSTYPE_MOUNTPOINT_LABEL_UUID_RA_RO_RM_MODEL_SIZE_STATE_OWNER_GROUP_MODE_ALIGNMENT_MIN-IO_OPT-IO_PHY-SEC_LOG-SEC_ROTA_SCHED_RQ-SIZE_TYPE_DISC-ALN_DISC-GRAN_DISC-MAX_DISC-ZERO" + ) lscpu = simple_file("insights_commands/lscpu") lsmod = simple_file("insights_commands/lsmod") lsof = simple_file("insights_commands/lsof") @@ -177,15 +204,16 @@ class InsightsArchiveSpecs(Specs): lspci_vmmkn = simple_file("insights_commands/lspci_-vmmkn") lssap = simple_file("insights_commands/usr.sap.hostctrl.exe.lssap") lsscsi = simple_file("insights_commands/lsscsi") - lvm_fullreport = simple_file("insights_commands/lvm_fullreport_-a_--nolocking_--reportformat_json") - lvmconfig = first_file([ - "insights_commands/lvmconfig_--type_full", - "insights_commands/lvm_dumpconfig_--type_full" - ]) + lvm_fullreport = simple_file( + "insights_commands/lvm_fullreport_-a_--nolocking_--reportformat_json" + ) + lvmconfig = first_file( + ["insights_commands/lvmconfig_--type_full", "insights_commands/lvm_dumpconfig_--type_full"] + ) lvs_noheadings = first_file( [ "insights_commands/lvs_--nameprefixes_--noheadings_--separator_-a_-o_lv_name_lv_size_lv_attr_mirror_log_vg_name_devices_region_size_data_percent_metadata_percent_segtype_seg_monitor_lv_kernel_major_lv_kernel_minor_--config_global_locking_type_0", - "insights_commands/lvs_--nameprefixes_--noheadings_--separator_-a_-o_lv_name_lv_size_lv_attr_mirror_log_vg_name_devices_region_size_data_percent_metadata_percent_segtype_seg_monitor_--config_global_locking_type_0" + "insights_commands/lvs_--nameprefixes_--noheadings_--separator_-a_-o_lv_name_lv_size_lv_attr_mirror_log_vg_name_devices_region_size_data_percent_metadata_percent_segtype_seg_monitor_--config_global_locking_type_0", ] ) max_uid = simple_file("insights_commands/awk_-F_if_3_max_max_3_END_print_max_.etc.passwd") @@ -193,7 +221,9 @@ class InsightsArchiveSpecs(Specs): mdadm_D = simple_file("insights_commands/mdadm_-D_.dev.md") mount = simple_file("insights_commands/mount") mokutil_sbstate = simple_file("insights_commands/mokutil_--sb-state") - multicast_querier = simple_file("insights_commands/find_.sys.devices.virtual.net._-name_multicast_querier_-print_-exec_cat") + multicast_querier = simple_file( + "insights_commands/find_.sys.devices.virtual.net._-name_multicast_querier_-print_-exec_cat" + ) multipath_conf_initramfs = simple_file("insights_commands/lsinitrd_-f_.etc.multipath.conf") multipath__v4__ll = simple_file("insights_commands/multipath_-v4_-ll") mysqladmin_vars = simple_file("insights_commands/mysqladmin_variables") @@ -213,12 +243,21 @@ class InsightsArchiveSpecs(Specs): ovs_vsctl_show = simple_file("insights_commands/ovs-vsctl_show") package_provides_command = glob_file("insights_commands/echo_*java*") parted__l = simple_file("insights_commands/parted_-l_-s") - pci_rport_target_disk_paths = simple_file("insights_commands/find_.sys.devices._-maxdepth_10_-mindepth_9_-name_stat_-type_f") - pcp_metrics = simple_file("insights_commands/curl_-s_http_..127.0.0.1_44322.metrics_--connect-timeout_5") + pci_rport_target_disk_paths = simple_file( + "insights_commands/find_.sys.devices._-maxdepth_10_-mindepth_9_-name_stat_-type_f" + ) + pcp_metrics = simple_file( + "insights_commands/curl_-s_http_..127.0.0.1_44322.metrics_--connect-timeout_5" + ) pcs_quorum_status = simple_file("insights_commands/pcs_quorum_status") pcs_status = simple_file("insights_commands/pcs_status") pidstat = simple_file("insights_commands/pidstat") - pmrep_metrics = first_file(["insights_commands/pmrep_-t_1s_-T_1s_network.interface.out.packets_network.interface.collisions_swap.pagesout_mssql.memory_manager.stolen_server_memory_mssql.memory_manager.total_server_memory_-o_csv", "insights_commands/pmrep_-t_1s_-T_1s_network.interface.out.packets_network.interface.collisions_swap.pagesout_-o_csv"]) + pmrep_metrics = first_file( + [ + "insights_commands/pmrep_-t_1s_-T_1s_network.interface.out.packets_network.interface.collisions_swap.pagesout_mssql.memory_manager.stolen_server_memory_mssql.memory_manager.total_server_memory_-o_csv", + "insights_commands/pmrep_-t_1s_-T_1s_network.interface.out.packets_network.interface.collisions_swap.pagesout_-o_csv", + ] + ) podman_list_containers = simple_file("insights_commands/podman_ps_--all_--no-trunc") postconf_builtin = simple_file("insights_commands/postconf_-C_builtin") postconf = simple_file("insights_commands/postconf") @@ -227,42 +266,68 @@ class InsightsArchiveSpecs(Specs): ps_auxcww = simple_file("insights_commands/ps_auxcww") ps_auxww = simple_file("insights_commands/ps_auxww") ps_ef = simple_file("insights_commands/ps_-ef") - ps_eo = first_file(["insights_commands/ps_-eo_pid_ppid_comm_nlwp", "insights_commands/ps_-eo_pid_ppid_comm"]) - puppet_ca_cert_expire_date = simple_file("insights_commands/openssl_x509_-in_.etc.puppetlabs.puppet.ssl.ca.ca_crt.pem_-enddate_-noout") - pvs_noheadings = simple_file("insights_commands/pvs_--nameprefixes_--noheadings_--separator_-a_-o_pv_all_vg_name_--config_global_locking_type_0") + ps_eo = first_file( + ["insights_commands/ps_-eo_pid_ppid_comm_nlwp", "insights_commands/ps_-eo_pid_ppid_comm"] + ) + puppet_ca_cert_expire_date = simple_file( + "insights_commands/openssl_x509_-in_.etc.puppetlabs.puppet.ssl.ca.ca_crt.pem_-enddate_-noout" + ) + pvs_noheadings = simple_file( + "insights_commands/pvs_--nameprefixes_--noheadings_--separator_-a_-o_pv_all_vg_name_--config_global_locking_type_0" + ) readlink_e_etc_mtab = simple_file("insights_commands/readlink_-e_.etc.mtab") - readlink_e_shift_cert_client = simple_file("insights_commands/readlink_-e_.etc.origin.node.certificates.kubelet-client-current.pem") - readlink_e_shift_cert_server = simple_file("insights_commands/readlink_-e_.etc.origin.node.certificates.kubelet-server-current.pem") + readlink_e_shift_cert_client = simple_file( + "insights_commands/readlink_-e_.etc.origin.node.certificates.kubelet-client-current.pem" + ) + readlink_e_shift_cert_server = simple_file( + "insights_commands/readlink_-e_.etc.origin.node.certificates.kubelet-server-current.pem" + ) repquota_agnpuv = simple_file("insights_commands/repquota_-agnpuv") - rhsm_katello_default_ca_cert = simple_file("insights_commands/openssl_x509_-in_.etc.rhsm.ca.katello-default-ca.pem_-noout_-issuer") + rhsm_katello_default_ca_cert = simple_file( + "insights_commands/openssl_x509_-in_.etc.rhsm.ca.katello-default-ca.pem_-noout_-issuer" + ) rndc_status = simple_file("insights_commands/rndc_status") rpm_ostree_status = simple_file("insights_commands/rpm-ostree_status_--json") - rpm_V_packages = first_file([ - "insights_commands/rpm_-V_coreutils_procps_procps-ng_shadow-utils_passwd_sudo_chrony_findutils_glibc_systemd" - "insights_commands/rpm_-V_coreutils_procps_procps-ng_shadow-utils_passwd_sudo_chrony_findutils_glibc", - "insights_commands/rpm_-V_coreutils_procps_procps-ng_shadow-utils_passwd_sudo_chrony_findutils", - "insights_commands/rpm_-V_coreutils_procps_procps-ng_shadow-utils_passwd_sudo_chrony", - "insights_commands/rpm_-V_coreutils_procps_procps-ng_shadow-utils_passwd_sudo" - ]) - saphostctl_getcimobject_sapinstance = simple_file("insights_commands/usr.sap.hostctrl.exe.saphostctrl_-function_GetCIMObject_-enuminstances_SAPInstance") - satellite_content_hosts_count = first_file([ - "insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_count_from_hosts", - "insights_commands/sudo_-iu_postgres_psql_-d_foreman_-c_select_count_from_hosts" - ]) - satellite_custom_ca_chain = simple_file("insights_commands/awk_BEGIN_pipe_openssl_x509_-noout_-subject_-enddate_._-_BEGIN_CERT._._-_END_CERT._print_pipe_._-_END_CERT._close_pipe_printf_n_.etc.pki.katello.certs.katello-server-ca.crt") - satellite_provision_param_settings = simple_file('insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_name_value_from_parameters_where_name_package_upgrade_and_reference_id_in_select_id_from_operatingsystems_where_name_RedHat_and_major_9_--csv') - satellite_qualified_capsules = simple_file("insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_name_from_smart_proxies_where_download_policy_background_--csv") - satellite_qualified_katello_repos = simple_file("insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_id_name_url_download_policy_from_katello_root_repositories_where_download_policy_background_or_url_is_NULL_--csv") + saphostctl_getcimobject_sapinstance = simple_file( + "insights_commands/usr.sap.hostctrl.exe.saphostctrl_-function_GetCIMObject_-enuminstances_SAPInstance" + ) + satellite_content_hosts_count = first_file( + [ + "insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_count_from_hosts", + "insights_commands/sudo_-iu_postgres_psql_-d_foreman_-c_select_count_from_hosts", + ] + ) + satellite_custom_ca_chain = simple_file( + "insights_commands/awk_BEGIN_pipe_openssl_x509_-noout_-subject_-enddate_._-_BEGIN_CERT._._-_END_CERT._print_pipe_._-_END_CERT._close_pipe_printf_n_.etc.pki.katello.certs.katello-server-ca.crt" + ) + satellite_provision_param_settings = simple_file( + 'insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_name_value_from_parameters_where_name_package_upgrade_and_reference_id_in_select_id_from_operatingsystems_where_name_RedHat_and_major_9_--csv' + ) + satellite_qualified_capsules = simple_file( + "insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_name_from_smart_proxies_where_download_policy_background_--csv" + ) + satellite_qualified_katello_repos = simple_file( + "insights_commands/sudo_-iu_postgres_.usr.bin.psql_-d_foreman_-c_select_id_name_url_download_policy_from_katello_root_repositories_where_download_policy_background_or_url_is_NULL_--csv" + ) sealert = simple_file('insights_commands/sealert_-l') sestatus = simple_file("insights_commands/sestatus_-b") smbstatus_p = simple_file("insights_commands/smbstatus_-p") software_collections_list = simple_file('insights_commands/scl_--list') - spamassassin_channels = simple_file('insights_commands/grep_-r_s_CHANNELURL_.etc.mail.spamassassin.channel.d') + spamassassin_channels = simple_file( + 'insights_commands/grep_-r_s_CHANNELURL_.etc.mail.spamassassin.channel.d' + ) ss = simple_file("insights_commands/ss_-tupna") - sshd_config_perms = first_file(["insights_commands/ls_-lH_.etc.ssh.sshd_config", "insights_commands/ls_-l_.etc.ssh.sshd_config"]) + sshd_config_perms = first_file( + [ + "insights_commands/ls_-lH_.etc.ssh.sshd_config", + "insights_commands/ls_-l_.etc.ssh.sshd_config", + ] + ) subscription_manager_facts = simple_file("insights_commands/subscription-manager_facts") subscription_manager_id = simple_file("insights_commands/subscription-manager_identity") - subscription_manager_installed_product_ids = simple_file("insights_commands/find_.etc.pki.product-default._.etc.pki.product._-name_pem_-exec_rct_cat-cert_--no-content") + subscription_manager_installed_product_ids = simple_file( + "insights_commands/find_.etc.pki.product-default._.etc.pki.product._-name_pem_-exec_rct_cat-cert_--no-content" + ) subscription_manager_status = simple_file("insights_commands/subscription-manager_status") sysctl = simple_file("insights_commands/sysctl_-a") systemctl_cat_rpcbind_socket = simple_file("insights_commands/systemctl_cat_rpcbind.socket") @@ -272,25 +337,39 @@ class InsightsArchiveSpecs(Specs): systemctl_show_all_services = simple_file("insights_commands/systemctl_show_.service") systemctl_show_target = simple_file("insights_commands/systemctl_show_.target") systemd_analyze_blame = simple_file("insights_commands/systemd-analyze_blame") - systemd_docker = first_file(["insights_commands/systemctl_cat_docker.service", "/usr/lib/systemd/system/docker.service"]) - systemd_openshift_node = first_file(["insights_commands/systemctl_cat_atomic-openshift-node.service", "/usr/lib/systemd/system/atomic-openshift-node.service"]) + systemd_docker = first_file( + ["insights_commands/systemctl_cat_docker.service", "/usr/lib/systemd/system/docker.service"] + ) + systemd_openshift_node = first_file( + [ + "insights_commands/systemctl_cat_atomic-openshift-node.service", + "/usr/lib/systemd/system/atomic-openshift-node.service", + ] + ) testparm_s = simple_file("insights_commands/testparm_-s") testparm_v_s = simple_file("insights_commands/testparm_-v_-s") timedatectl_status = simple_file("insights_commands/timedatectl_status") - tomcat_vdc_fallback = simple_file("insights_commands/find_.usr.share_-maxdepth_1_-name_tomcat_-exec_.bin.grep_-R_-s_VirtualDirContext_--include_.xml") + tomcat_vdc_fallback = simple_file( + "insights_commands/find_.usr.share_-maxdepth_1_-name_tomcat_-exec_.bin.grep_-R_-s_VirtualDirContext_--include_.xml" + ) tuned_adm = simple_file("insights_commands/tuned-adm_list") uname = simple_file("insights_commands/uname_-a") uptime = simple_file("insights_commands/uptime") vdo_status = simple_file("insights_commands/vdo_status") vgdisplay = simple_file("insights_commands/vgdisplay") - vgs_noheadings = simple_file("insights_commands/vgs_--nameprefixes_--noheadings_--separator_-a_-o_vg_all_--config_global_locking_type_0") + vgs_noheadings = simple_file( + "insights_commands/vgs_--nameprefixes_--noheadings_--separator_-a_-o_vg_all_--config_global_locking_type_0" + ) virsh_list_all = simple_file("insights_commands/virsh_--readonly_list_--all") virt_what = simple_file("insights_commands/virt-what") wc_proc_1_mountinfo = simple_file("insights_commands/wc_-l_.proc.1.mountinfo") xfs_quota_state = simple_file("insights_commands/xfs_quota_-x_-c_state_-gu") yum_list_available = simple_file("insights_commands/yum_-C_--noplugins_list_available") - yum_repolist = first_file([ - "insights_commands/yum_-d_2_-C_--noplugins_repolist", - "insights_commands/yum_-C_--noplugins_repolist", - "insights_commands/yum_-C_repolist"]) + yum_repolist = first_file( + [ + "insights_commands/yum_-d_2_-C_--noplugins_repolist", + "insights_commands/yum_-C_--noplugins_repolist", + "insights_commands/yum_-C_repolist", + ] + ) yum_updateinfo = simple_file("insights_commands/yum_-C_updateinfo_list") diff --git a/insights/tests/test_get_dependency_specs.py b/insights/tests/core/test_get_dependency_specs.py similarity index 66% rename from insights/tests/test_get_dependency_specs.py rename to insights/tests/core/test_get_dependency_specs.py index a280b97115..3e74443aaf 100644 --- a/insights/tests/test_get_dependency_specs.py +++ b/insights/tests/core/test_get_dependency_specs.py @@ -3,28 +3,23 @@ from insights.parsers.uname import Uname from insights.parsers.redhat_release import RedhatRelease from insights.parsers.messages import Messages -from insights.parsers.ps import PsAuxcww +from insights.parsers.ps import PsAuxcww, PsAux, PsAuxww, PsEf, PsEo from insights.parsers.virt_what import VirtWhat -from insights.parsers.date import Date +from insights.parsers.date import Date, DateUTC from insights.parsers.client_metadata import Tags from insights.parsers.lspci import LsPci, LsPciVmmkn from insights.parsers.lsof import Lsof from insights.parsers.lscpu import LsCPU from insights.parsers.lsblk import LSBlock -from insights.parsers.ls_etc import LsEtc from insights.parsers.ls_boot import LsBoot -from insights.parsers.ls_dev import LsDev -from insights.parsers.ls_disk import LsDisk -from insights.parsers.ls_tmp import LsTmp -from insights.parsers.ls_usr_bin import LsUsrBin -from insights.parsers.ls_var_log import LsVarLog -from insights.parsers.ls_var_tmp import LsVarTmp -from insights.parsers.ls_var_www_perms import LsVarWwwPerms -from insights.parsers.ls_var_run import LsVarRun +from insights.parsers.ls_sys_firmware import LsSysFirmware +from insights.parsers.dmidecode import DMIDecode +from insights.parsers.os_release import OsRelease from insights.parsers.mount import Mount from insights.parsers.lvm import LvmConfig, LvmConf from insights.parsers.lsscsi import LsSCSI from insights.parsers.uptime import Uptime +from insights.parsers.dmesg import DmesgLineList from insights.combiners.redhat_release import RedHatRelease from insights.core.dr import get_dependency_specs @@ -39,12 +34,12 @@ def condition_02(*args): return True -@condition(LsVarLog, [LsBoot, LsEtc]) +@condition(PsAux, [LsBoot, PsAuxww]) def condition_03(*args): return True -@condition(LsVarWwwPerms, [LsDev, LsDisk], optional=[LsVarRun]) +@condition(PsEf, [LsSysFirmware, DMIDecode], optional=[PsEo]) def condition_04(*args): return True @@ -59,20 +54,25 @@ def condition_06(*args): return True -@condition(Mount, [LsTmp, LsVarTmp], optional=[LsUsrBin]) +@condition(Mount, [OsRelease, PsEo], optional=[DateUTC]) def condition_07(*args): return True -@rule(Lsof, condition_01, condition_02, - [LsCPU, condition_03], [condition_04, LsSCSI], - [condition_05, condition_06], - optional=[LSBlock, condition_07]) +@rule( + Lsof, + condition_01, + condition_02, + [LsCPU, condition_03], + [condition_04, LsSCSI], + [condition_05, condition_06], + optional=[LSBlock, condition_07], +) def report_01(*args): return make_fail("HIT") -@condition(LsVarLog, [LsBoot, LsEtc]) +@condition(PsAux, [LsBoot, DmesgLineList]) def condition_11(*args): return True @@ -82,44 +82,44 @@ def condition_12(*args): return True -@condition(LsPci, LsBoot, LsDisk) +@condition(LsPci, LsBoot, DMIDecode) def report_11(*args): return True -@condition(PsAuxcww, LsVarLog, [Uname, RedhatRelease], [LsPci, condition_11]) +@condition(PsAuxcww, PsAux, [Uname, RedhatRelease], [LsPci, condition_11]) def condition_21(*args): return True -@condition(RedHatRelease, LsVarLog, condition_12, condition_21) +@condition(RedHatRelease, PsAux, condition_12, condition_21) def report_21(*args): return True def test_get_dependency_specs_1_level_requires_only(): specs = get_dependency_specs(report_11) - assert sorted(specs) == ['ls_boot', 'ls_disk', 'lspci'] + assert sorted(specs) == ['dmidecode', 'ls_boot', 'lspci'] def test_get_dependency_specs_2_level(): specs = get_dependency_specs(condition_12) # [ - # ('lspci', [('ls_etc', 'ls_boot'), 'ls_var_log']) + # ('lspci', [('ps_auxww', 'ls_boot'), 'ps_aux']) # ] assert len([alo for alo in specs if isinstance(alo, tuple)]) == 1 assert 'lspci' in specs[0] x, y = specs[0] if x == 'lspci': - assert 'ls_var_log' in y + assert 'ps_aux' in y else: - assert 'ls_var_log' in x + assert 'ps_aux' in x m, n = x if isinstance(m, tuple): t = m else: t = n - assert all(i in t for i in ('ls_etc', 'ls_boot')) + assert all(i in t for i in ('ps_auxww', 'ls_boot')) def test_get_dependency_specs_complex(): @@ -131,8 +131,8 @@ def test_get_dependency_specs_complex(): # 'virt_what', # ('redhat_release', 'uname'), # ('ps_auxcww', 'up2date'), - # ('ls_cpu', ['ls_var_log', ('ls_boot', 'ls_etc')]), - # ('lsscsi', ['ls_var_tmp', ('ls_disk', 'ls_dev')]), + # ('ls_cpu', ['ps_aux', ('ls_boot', 'ps_auxww')]), + # ('lsscsi', ['ps_aux', ('dmidecode', 'ls_sys_firmware')]), # (('lspci', 'lspci_vmmkn'), ('lvm_conf', 'lvmconfig')) # ] requires = ['installed_rpms', 'tags', 'lsof', 'virt_what'] @@ -148,14 +148,14 @@ def test_get_dependency_specs_duplicate(): # [ # ('uname', 'redhat_release'), # 'ps_auxcww', - # 'ls_var_log', - # ('ls_pci', ['ls_var_log', ('ls_boot', 'ls_etc')]) + # 'ps_aux', + # ('ls_pci', ['ps_aux', ('ls_boot', 'ps_auxww')]) # ] # There is only one such item in the result assert ('uname', 'redhat_release') in specs specs.remove(('uname', 'redhat_release')) assert ('uname', 'redhat_release') not in specs - assert 'ls_var_log' in specs - specs.remove('ls_var_log') - assert 'ls_var_log' not in specs + assert 'ps_aux' in specs + specs.remove('ps_aux') + assert 'ps_aux' not in specs diff --git a/insights/tests/parsers/test_dse_ldif_simple.py b/insights/tests/parsers/test_dse_ldif_simple.py deleted file mode 100644 index 9c133a7573..0000000000 --- a/insights/tests/parsers/test_dse_ldif_simple.py +++ /dev/null @@ -1,207 +0,0 @@ -# -*- coding: utf-8 -*- - -import doctest - -from collections import defaultdict - -from insights.core import filters -from insights.parsers import dse_ldif_simple -from insights.parsers.dse_ldif_simple import DseLdifSimple -from insights.specs import Specs -from insights.tests import context_wrap - -DSE_LDIF_REAL_EXAMPLE = """ - -dn: cn=config -cn: config -objectClass: top -objectClass: extensibleObject -objectClass: nsslapdConfig -nsslapd-schemadir: /etc/dirsrv/slapd-dir/schema -nsslapd-lockdir: /var/lock/dirsrv/slapd-dir -nsslapd-tmpdir: /tmp -nsslapd-certdir: /etc/dirsrv/slapd-dir -nsslapd-ldifdir: /var/lib/dirsrv/slapd-dir/ldif -nsslapd-bakdir: /var/lib/dirsrv/slapd-dir/bak -nsslapd-rundir: /var/run/dirsrv -nsslapd-instancedir: /usr/lib64/dirsrv/slapd-dir -nsslapd-accesslog: /var/log/dirsrv/slapd-dir/access -nsslapd-localhost: testinstance.local -nsslapd-port: 389 -nsslapd-localuser: dirsrv -nsslapd-errorlog: /var/log/dirsrv/slapd-dir/errors -nsslapd-auditlog: /var/log/dirsrv/slapd-dir/audit -nsslapd-auditfaillog: /var/log/dirsrv/slapd-dir/audit -nsslapd-rootdn: cn=Directory Manager -nsslapd-ldapifilepath: /var/run/slapd-dir.socket -nsslapd-ldapilisten: off -nsslapd-ldapiautobind: off -nsslapd-ldapimaprootdn: cn=Directory Manager -nsslapd-ldapimaptoentries: off -nsslapd-ldapiuidnumbertype: uidNumber -nsslapd-ldapigidnumbertype: gidNumber -nsslapd-ldapientrysearchbase: dc=testinstance,dc=local -nsslapd-defaultnamingcontext: dc=testinstance,dc=local -aci: (targetattr="*")(version 3.0; acl "Configuration Administrators Group"; a - llow (all) groupdn="ldap:///cn=Configuration Administrators,ou=Groups,ou=Topo - logyManagement,o=NetscapeRoot";) -aci: (targetattr="*")(version 3.0; acl "Configuration Administrator"; allow (a - ll) userdn="ldap:///uid=admin,ou=Administrators,ou=TopologyManagement,o=Netsc - apeRoot";) -aci: (targetattr = "*")(version 3.0; acl "SIE Group"; allow (all) groupdn = "l - dap:///cn=slapd-dir,cn=Red Hat Directory Server,cn=Server Group,cn=testinstan - ce.local,ou=testinstance.local,o=NetscapeRoot";) -modifiersName: cn=directory manager -modifyTimestamp: 20211015231914Z -nsslapd-securePort: 636 -nsslapd-security: on -nsslapd-rootpw: {SSHA512}la6KbVGTR3XKHN6CoZ/PcYvOrS7qGAVSC9kjvGtyuPzSJGbHXReTs - FUBF6QnP0jHAONEx4784x6PNPcMzTOdpoJw0gOQkXKM -numSubordinates: 10 - - -dn: cn=monitor -objectClass: top -objectClass: extensibleObject -cn: monitor -aci: (target ="ldap:///cn=monitor*")(targetattr != "aci || connection")(versio - n 3.0; acl "monitor"; allow( read, search, compare ) userdn = "ldap:///anyone - ";) -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=server,cn=plugins,cn=config -createTimestamp: 20211015215626Z -modifyTimestamp: 20211015215626Z -numSubordinates: 3 - -dn: cn=encryption,cn=config -objectClass: top -objectClass: nsEncryptionConfig -cn: encryption -nsSSLSessionTimeout: 0 -nsSSLClientAuth: allowed -sslVersionMin: TLS1.0 -sslVersionMax: TLS1.1 -nsSSL3: on -nsTLS1: on -allowWeakCipher: on -nsSSL3Ciphers: +all -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=server,cn=plugins,cn=config -createTimestamp: 20211015215626Z -modifyTimestamp: 20211015231142Z -CACertExtractFile: /etc/dirsrv/slapd-dir/server-cert.pem -numSubordinates: 1 - -dn: cn=features,cn=config -objectClass: top -objectClass: nsContainer -cn: features -numSubordinates: 5 - -""" - -DSE_LDIF_SMOKE = """ -cn: config -nsslapd-security: on -sslVersionMin: TLS1.0 -sslVersionMax: TLS1.1 -nsSSL3: on -# a comment : with a colon -""" - -# This is purely for coverage testing. Real deployments don't use these features -# for these attributes. -DSE_LDIF_COVERAGE = """ -# a comment -nsslapd-security: o - n -sslVersionMax:: VExTMS4yIA== -sslVersionMin:< file:///tmp/somefile -nsSSL3: on -""" - -DSE_LDIF_DOCTEST = """ -dn: cn=config -nsslapd-securePort: 636 -nsslapd-security: on - -dn: cn=encryption,cn=config -sslVersionMin: SSLv3 -sslVersionMax: TLS1.1 -nsSSL3: on -""" - - -def setup_function(func): - if func in [test_dse_ldif_filtered]: - filters.add_filter( - Specs.dse_ldif, [ - "nsslapd-security", - "sslVersionMin", - "sslVersionMax", - "nsSSL3", - "cn: config", # Note that this can serve as a canary for knowing whether the spec is collected. - ] - ) - - -def teardown_function(func): - filters._CACHE = {} - filters.FILTERS = defaultdict(set) - - -def test_dse_ldif_smoke(): - dse_ldif_simple = DseLdifSimple(context_wrap(DSE_LDIF_SMOKE)) - assert None is dse_ldif_simple.get("asdf") - assert len(dse_ldif_simple) == 5 - expected = { - "cn": "config", # just a canary to detect spec collection status - "nsslapd-security": "on", - "sslVersionMin": "TLS1.0", - "sslVersionMax": "TLS1.1", - "nsSSL3": "on", - } - assert dict(dse_ldif_simple) == expected - assert dse_ldif_simple["nsslapd-security"] == "on" - assert "sslVersionMin" in dse_ldif_simple - for k in dse_ldif_simple: - assert expected[k] == dse_ldif_simple[k] - assert expected[k] == dse_ldif_simple.get(k) - - -def test_dse_ldif_coverage(): - dse_ldif_simple = DseLdifSimple(context_wrap(DSE_LDIF_COVERAGE)) - assert "sslVersionMin" not in dse_ldif_simple - assert "sslVersionMax" not in dse_ldif_simple - assert "nsSSL3" in dse_ldif_simple - assert len(dse_ldif_simple) == 2 - expected = { - "nsSSL3": "on", - # This doesn't happen in real deployments because 389-ds automatically - # reformats it back to a single line. - "nsslapd-security": "o", - } - assert dict(dse_ldif_simple) == expected - - -def test_dse_ldif_filtered(): - dse_ldif_simple = DseLdifSimple(context_wrap(DSE_LDIF_REAL_EXAMPLE, filtered_spec=Specs.dse_ldif)) - assert dse_ldif_simple["nsslapd-security"] == "on" - assert len(dse_ldif_simple) == 6 - expected = { - "cn": "config", # just a canary to detect spec collection status - "nsslapd-security": "on", - "sslVersionMin": "TLS1.0", - "sslVersionMax": "TLS1.1", - "nsSSL3": "on", - "nsSSL3Ciphers": "+all", - } - assert dict(dse_ldif_simple) == expected - - -def test_doc_examples(): - env = { - "dse_ldif_simple": DseLdifSimple(context_wrap(DSE_LDIF_DOCTEST)), - } - failed, total = doctest.testmod(dse_ldif_simple, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ldif_config.py b/insights/tests/parsers/test_ldif_config.py deleted file mode 100644 index 6267dd9b2b..0000000000 --- a/insights/tests/parsers/test_ldif_config.py +++ /dev/null @@ -1,227 +0,0 @@ -import doctest -import pytest - -from insights.core.exceptions import SkipComponent -from insights.parsers import ldif_config -from insights.parsers.ldif_config import LDIFParser -from insights.tests import context_wrap - -LDIF_CONFIG = """ -dn: -aci: (targetattr != "aci")(version 3.0; aci "rootdse anon read access"; allow( - read,search,compare) userdn="ldap:///anyone";) -createTimestamp: 20201026161200Z -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=Directory Manager -modifyTimestamp: 20210608144722Z -nsslapd-return-default-opattr: namingContexts -nsslapd-return-default-opattr: supportedControl -nsslapd-return-default-opattr: supportedExtension -nsslapd-return-default-opattr: supportedLDAPVersion -nsslapd-return-default-opattr: supportedSASLMechanisms -nsslapd-return-default-opattr: vendorName -nsslapd-return-default-opattr: vendorVersion -objectClass: top - -dn: cn=config -aci: (targetattr != aci)(version 3.0; aci "cert manager read access"; allow (r - ead, search, compare) userdn = "ldap:///uid=pkidbuser,ou=people,o=ipaca";) -aci: (target = "ldap:///cn=automember rebuild membership,cn=tasks,cn=config")( - targetattr=*)(version 3.0;acl "permission:Add Automember Rebuil Membership T - ask";allow (add) groupdn = "ldap:///cn=Add Automember Rebuild Membership Task - ,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";) -aci: (targetattr = "cn || createtimestamp || entryusn || modifytimestamp || ob - jectclass || passsyncmanagersdns*")(target = "ldap:///cn=ipa_pwd_extop,cn=plu - gins,cn=config")(version 3.0;acl "permission:Read PassSync Managers Configura - tion";allow (compare,read,search) groupdn = "ldap:///cn=Read PassSync Manager - s Configuration,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";) -cn: config1111 -cn: config2222 -cn1:: IGJlZ2lucyB3aXRoIGEgc3BhY2U= -cn2:< file:///tmp/value -modifiersName: cn=directory manager -modifyTimestamp: 20210609192548Z -objectClass: nsslapdConfig -CACertExtractFile: /etc/dirsrv/slapd-IDM-NYPD-FINEST/IDM.NYPD.FINEST20IPA20CA. - pem -numSubordinates: 14 -nsslapd-errorlog-level: 81920 -nsslapd-rootpw: {SSHA512}mdrYu17fr9ukhID6B6/aMHE1KeMhWLwVfP3y2LSNtTFaMkRPf340X - MGEN/ocUoAyykmDSMxVcF3ajVR3+f5mqmNqxUek9PYT - -dn: cn=monitor -aci: (target ="ldap:///cn=monitor*")(targetattr != "aci || connection")(versio - n 3.0; acl "monitor"; allow( read, search, compare ) userdn = "ldap:///anyone - ";) -cn: monitor -createTimestamp: 20201026161200Z -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=server,cn=plugins,cn=config -modifyTimestamp: 20201026161200Z -objectClass: top -objectClass: extensibleObject -numSubordinates: 3 - -dn: cn=changelog5,cn=config -cn: changelog5 -createTimestamp: 20201026161228Z -creatorsName: cn=Directory Manager -modifiersName: cn=Directory Manager -modifyTimestamp: 20201026161228Z -nsslapd-changelogdir: /var/lib/dirsrv/slapd-IDM-NYPD-FINEST/cldb -nsslapd-changelogmaxage: 7d -objectClass: top -objectClass: extensibleobject - -dn: cn=encryption,cn=config -aci: (target ="ldap:///cn=monitor*")(targetattr != "aci) -CACertExtractFile: /etc/dirsrv/slapd-IDM-NYPD-FINEST/IDM.NYPD.FINEST20IPA20CA. - pem -# ldif config -allowWeakCipher: off -cn: encryption -createTimestamp: 20201026161200Z -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=server,cn=plugins,cn=config -modifyTimestamp: 20201026161252Z -nsSSL3Ciphers: default -nsSSLClientAuth: allowed -nsSSLSessionTimeout: 0 -objectClass: top -objectClass: nsEncryptionConfig -sslVersionMin: TLS1.0 -numSubordinates: 1 - -dn: cn=features,cn=config -cn: features -objectClass: top -objectClass: nsContainer -numSubordinates: 5 - -dn: cn=mapping tree,cn=config -aci: (targetattr = "cn || createtimestamp || description || entryusn || modify - timestamp || nsds50ruv || nsds5beginreplicarefresh || nsds5debugreplicatimeou - t || nsds5flags || nsds5replicaabortcleanruv || nsds5replicaautoreferral || n - sds5replicabackoffmax || nsds5replicabackoffmin || nsds5replicabinddn || nsds - 5replicabindmethod || nsds5replicabusywaittime || nsds5replicachangecount || - nsds5replicachangessentsincestartup || nsds5replicacleanruv || nsds5replicacl - eanruvnotified || nsds5replicacredentials || nsds5replicaenabled || nsds5repl - icahost || nsds5replicaid || nsds5replicalastinitend || nsds5replicalastinits - tart || nsds5replicalastinitstatus || nsds5replicalastupdateend || nsds5repli - calastupdatestart || nsds5replicalastupdatestatus || nsds5replicalegacyconsum - er || nsds5replicaname || nsds5replicaport || nsds5replicaprotocoltimeout || - nsds5replicapurgedelay || nsds5replicareferral || nsds5replicaroot || nsds5re - plicasessionpausetime || nsds5replicastripattrs || nsds5replicatedattributeli - st || nsds5replicatedattributelisttotal || nsds5replicatimeout || nsds5replic - atombstonepurgeinterval || nsds5replicatransportinfo || nsds5replicatype || n - sds5replicaupdateinprogress || nsds5replicaupdateschedule || nsds5task || nsd - s7directoryreplicasubtree || nsds7dirsynccookie || nsds7newwingroupsyncenable - d || nsds7newwinusersyncenabled || nsds7windowsdomain || nsds7windowsreplicas - ubtree || nsruvreplicalastmodified || nsstate || objectclass || onewaysync || - winsyncdirectoryfilter || winsyncinterval || winsyncmoveaction || winsyncsub - treepair || winsyncwindowsfilter")(targetfilter = "(|(objectclass=nsds5Replic - a)(objectclass=nsds5replicationagreement)(objectclass=nsDSWindowsReplicationA - greement)(objectClass=nsMappingTree))")(version 3.0;acl "permission:Read Repl - ication Agreements";allow (compare,read,search) groupdn = "ldap:///cn=Read Re - plication Agreements,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";) -aci: (targetattr=*)(version 3.0;acl "permission:Add Replication Agreements";al - low (add) groupdn = "ldap:///cn=Add Replication Agreements,cn=permissions,cn= - pbac,dc=idm,dc=nypd,dc=finest";) -aci: (targetattr=*)(targetfilter="(|(objectclass=nsds5Replica)(objectclass=nsd - s5replicationagreement)(objectclass=nsDSWindowsReplicationAgreement)(objectCl - ass=nsMappingTree))")(version 3.0; acl "permission:Modify Replication Agreeme - nts"; allow (read, write, search) groupdn = "ldap:///cn=Modify Replication Ag - reements,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";) -aci: (targetattr=*)(targetfilter="(|(objectclass=nsds5replicationagreement)(ob - jectclass=nsDSWindowsReplicationAgreement))")(version 3.0;acl "permission:Rem - ove Replication Agreements";allow (delete) groupdn = "ldap:///cn=Remove Repli - cation Agreements,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";) -aci: (target = "ldap:///cn=meTo($dn),cn=*,cn=mapping tree,cn=config")(targetat - tr = "objectclass || cn")(version 3.0; acl "Allow hosts to read their replica - tion agreements"; allow(read, search, compare) userdn = "ldap:///fqdn=($dn),c - n=computers,cn=accounts,dc=idm,dc=nypd,dc=finest";) -cn: mapping tree -modifiersName: cn=Directory Manager -modifyTimestamp: 20201026161600Z -objectClass: top -objectClass: extensibleObject -numSubordinates: 3 - -dn: cn=sasl,cn=config -cn: sasl -objectClass: top -objectClass: nsContainer -numSubordinates: 1 -""" - -LDIF_CONFIG_DOC = """ -dn: -aci: (targetattr != "aci")(version 3.0; aci "rootdse anon read access"; allow( - read,search,compare) userdn="ldap:///anyone";) -aci: (target = "ldap:///cn=automember rebuild membership,cn=tasks,cn=config")( - ,cn=permissions,cn=pbac,dc=idm";) -createTimestamp: 20201026161200Z -creatorsName: cn=server,cn=plugins,cn=config -modifiersName: cn=Directory Manager -modifyTimestamp: 20210608144722Z -nsslapd-return-default-opattr: namingContexts -nsslapd-return-default-opattr: supportedControl -nsslapd-return-default-opattr: supportedExtension -nsslapd-return-default-opattr: supportedLDAPVersion -nsslapd-return-default-opattr: supportedSASLMechanisms -nsslapd-return-default-opattr: vendorName -nsslapd-return-default-opattr: vendorVersion -objectClass: top - -dn: cn=changelog5,cn=config -cn: changelog5 -createTimestamp: 20201026161228Z -creatorsName: cn=Directory Manager -modifiersName: cn=Directory Manager -modifyTimestamp: 20201026161228Z -nsslapd-changelogdir: /var/lib/dirsrv/slapd-IDM-NYPD-FINEST/cldb -nsslapd-changelogmaxage: 7d -objectClass: top -objectClass: extensibleobject -""" - -LDIF_CONFIG_EMPTY = "" - - -def test_ldif_parser(): - ldif_config = LDIFParser(context_wrap(LDIF_CONFIG)) - for item in ldif_config: - if item['dn'] == "": - item['aci'] == '(targetattr != "aci")(version 3.0; aci "rootdse anon read access"; allow(read,search,compare) userdn="ldap:///anyone";)' - item['modifiersName'] == 'cn=Directory Manager' - if item['dn'] == 'cn=changelog5,cn=config': - assert item['createTimestamp'] == '20201026161228Z' - assert item['creatorsName'] == 'cn=Directory Manager' - assert item['nsslapd-changelogdir'] == '/var/lib/dirsrv/slapd-IDM-NYPD-FINEST/cldb' - assert item['objectClass'] == 'extensibleobject' - if item['dn'] == 'cn=config': - assert item['aci'] == '(targetattr != aci)(version 3.0; aci "cert manager read access"; allow (read, search, compare) userdn = "ldap:///uid=pkidbuser,ou=people,o=ipaca";)(target = "ldap:///cn=automember rebuild membership,cn=tasks,cn=config")(targetattr=*)(version 3.0;acl "permission:Add Automember Rebuil Membership Task";allow (add) groupdn = "ldap:///cn=Add Automember Rebuild Membership Task,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";)(targetattr = "cn || createtimestamp || entryusn || modifytimestamp || objectclass || passsyncmanagersdns*")(target = "ldap:///cn=ipa_pwd_extop,cn=plugins,cn=config")(version 3.0;acl "permission:Read PassSync Managers Configuration";allow (compare,read,search) groupdn = "ldap:///cn=Read PassSync Managers Configuration,cn=permissions,cn=pbac,dc=idm,dc=nypd,dc=finest";)' - assert item['modifiersName'] == 'cn=directory manager' - assert item['modifyTimestamp'] == '20210609192548Z' - assert item['objectClass'] == 'nsslapdConfig' - if item['dn'] == 'cn=monitor': - assert item['aci'] == '(target ="ldap:///cn=monitor*")(targetattr != "aci || connection")(version 3.0; acl "monitor"; allow( read, search, compare ) userdn = "ldap:///anyone";)' - - assert ldif_config.search(dn='cn=features,cn=config')[0] == ldif_config[5] - assert ldif_config.search(dn='cn=sasl,cn=config')[0] == ldif_config[7] - assert ldif_config.search(cn='features')[0] == ldif_config[5] - assert ldif_config.search(dn='cn=sasl,cn=config')[0] == ldif_config[-1] - - -def test_empty(): - with pytest.raises(SkipComponent) as e: - LDIFParser(context_wrap(LDIF_CONFIG_EMPTY)) - assert 'The file is empty' in str(e) - - -def test_ldif_config_doc_examples(): - env = { - 'ldif_config': LDIFParser(context_wrap(LDIF_CONFIG_DOC)), - } - failed, total = doctest.testmod(ldif_config, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_disk.py b/insights/tests/parsers/test_ls_disk.py deleted file mode 100644 index b69327171a..0000000000 --- a/insights/tests/parsers/test_ls_disk.py +++ /dev/null @@ -1,75 +0,0 @@ -from insights.parsers.ls_disk import LsDisk -from insights.tests import context_wrap - -LS_DISK = """ -/dev/disk/by-path: -total 0 -drwxr-xr-x. 2 0 0 160 Sep 19 10:15 . -drwxr-xr-x. 5 0 0 100 Sep 19 10:15 .. -lrwxrwxrwx. 1 0 0 9 Sep 19 10:15 pci-0000:00:01.1-scsi-1:0:0:0 -> ../../sr0 -lrwxrwxrwx. 1 0 0 9 Sep 19 10:15 pci-0000:00:0d.0-scsi-0:0:0:0 -> ../../sda -lrwxrwxrwx. 1 0 0 10 Sep 19 10:15 pci-0000:00:0d.0-scsi-0:0:0:0-part1 -> ../../sda1 -lrwxrwxrwx. 1 0 0 10 Sep 19 10:15 pci-0000:00:0d.0-scsi-0:0:0:0-part2 -> ../../sda2 -lrwxrwxrwx. 1 0 0 9 Sep 19 10:15 pci-0000:00:0d.0-scsi-1:0:0:0 -> ../../sdb -lrwxrwxrwx. 1 0 0 10 Sep 19 10:15 pci-0000:00:0d.0-scsi-1:0:0:0-part1 -> ../../sdb - -/dev/disk/by-uuid: -total 0 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 3ab50b34-d0b9-4518-9f21-05307d895f81 -> ../../dm-1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 51c5cf12-a577-441e-89da-bc93a73a1ba3 -> ../../sda1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 7b0068d4-1399-4ce7-a54a-3e2fc1232299 -> ../../dm-0 - -/dev/disk/by-id: -total 0 -lrwxrwxrwx. 1 root root 9 Sep 19 10:15 ata-VBOX_CD-ROM_VB2-01700376 -> ../../sr0 -lrwxrwxrwx. 1 root root 9 Sep 19 10:15 ata-VBOX_HARDDISK_VB4c56cb04-26932e6a -> ../../sdb -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 ata-VBOX_HARDDISK_VB4c56cb04-26932e6a-part1 -> ../../sdb1 -lrwxrwxrwx. 1 root root 9 Sep 19 10:15 ata-VBOX_HARDDISK_VBdb3eca59-6c439fb7 -> ../../sda -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 ata-VBOX_HARDDISK_VBdb3eca59-6c439fb7-part1 -> ../../sda1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 ata-VBOX_HARDDISK_VBdb3eca59-6c439fb7-part2 -> ../../sda2 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 dm-name-vg_yizhangrhel6-lv_root -> ../../dm-0 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 dm-name-vg_yizhangrhel6-lv_swap -> ../../dm-1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 dm-uuid-LVM-vT3Sj2vOtGXyChqSzGvmps0qezNWEO7MI7atvuhelVCBetzJ3QPpOlIDyXSIt6cw -> ../../dm-1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 dm-uuid-LVM-vT3Sj2vOtGXyChqSzGvmps0qezNWEO7MlJOewBrdU3NOoolrIVn99sdXojq9qIxd -> ../../dm-0 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 lvm-pv-uuid-1lI8Ef-9H35-HVlP-1UdC-XlgD-eedv-SRjC0i -> ../../sda2 -lrwxrwxrwx. 1 root root 9 Sep 19 10:15 scsi-SATA_VBOX_HARDDISK_VB4c56cb04-26932e6a -> ../../sdb -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 scsi-SATA_VBOX_HARDDISK_VB4c56cb04-26932e6a-part1 -> ../../sdb1 -lrwxrwxrwx. 1 root root 9 Sep 19 10:15 scsi-SATA_VBOX_HARDDISK_VBdb3eca59-6c439fb7 -> ../../sda -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 scsi-SATA_VBOX_HARDDISK_VBdb3eca59-6c439fb7-part1 -> ../../sda1 -lrwxrwxrwx. 1 root root 10 Sep 19 10:15 scsi-SATA_VBOX_HARDDISK_VBdb3eca59-6c439fb7-part2 -> ../../sda2 - -/dev/disk/by-label: -total 0 -lrwxrwxrwx. 1 root root 9 Sep 18 11:20 RHEL-7.2\x20Server.x86_64 -> ../../sr0 -""" - -BY_DISK = "/dev/disk/by-path" - - -def test_ls_disk(): - ls_disk = LsDisk(context_wrap(LS_DISK)) - assert ls_disk.listing_of("/dev/disk/by-uuid") == { - '7b0068d4-1399-4ce7-a54a-3e2fc1232299': {'group': 'root', 'name': '7b0068d4-1399-4ce7-a54a-3e2fc1232299', - 'links': 1, 'perms': 'rwxrwxrwx.', 'dir': '/dev/disk/by-uuid', - 'raw_entry': 'lrwxrwxrwx. 1 root root 10 Sep 19 10:15 7b0068d4-1399-4ce7-a54a-3e2fc1232299 -> ../../dm-0', - 'owner': 'root', 'link': '../../dm-0', 'date': 'Sep 19 10:15', - 'type': 'l', - 'size': 10}, - '3ab50b34-d0b9-4518-9f21-05307d895f81': {'group': 'root', 'name': '3ab50b34-d0b9-4518-9f21-05307d895f81', - 'links': 1, 'perms': 'rwxrwxrwx.', 'dir': '/dev/disk/by-uuid', - 'raw_entry': 'lrwxrwxrwx. 1 root root 10 Sep 19 10:15 3ab50b34-d0b9-4518-9f21-05307d895f81 -> ../../dm-1', - 'owner': 'root', 'link': '../../dm-1', 'date': 'Sep 19 10:15', - 'type': 'l', - 'size': 10}, - '51c5cf12-a577-441e-89da-bc93a73a1ba3': {'group': 'root', 'name': '51c5cf12-a577-441e-89da-bc93a73a1ba3', - 'links': 1, 'perms': 'rwxrwxrwx.', 'dir': '/dev/disk/by-uuid', - 'raw_entry': 'lrwxrwxrwx. 1 root root 10 Sep 19 10:15 51c5cf12-a577-441e-89da-bc93a73a1ba3 -> ../../sda1', - 'owner': 'root', 'link': '../../sda1', 'date': 'Sep 19 10:15', - 'type': 'l', - 'size': 10}} - assert ls_disk.listings.get("/dev/disk/by-uuid")['files'] == ['3ab50b34-d0b9-4518-9f21-05307d895f81', - '51c5cf12-a577-441e-89da-bc93a73a1ba3', - '7b0068d4-1399-4ce7-a54a-3e2fc1232299'] - - assert ls_disk.listings.get("/dev/disk/by-uuid")['entries']['3ab50b34-d0b9-4518-9f21-05307d895f81'][ - 'link'] == "../../dm-1" diff --git a/insights/tests/parsers/test_ls_docker_volumes.py b/insights/tests/parsers/test_ls_docker_volumes.py deleted file mode 100644 index 52e4dc82cc..0000000000 --- a/insights/tests/parsers/test_ls_docker_volumes.py +++ /dev/null @@ -1,54 +0,0 @@ -from insights.parsers.ls_docker_volumes import DockerVolumesDir -from insights.tests import context_wrap - -DOCKER_VOLUME_EMPTY_DIR = """ -/var/lib/docker/volumes/: -total 0 -drwx------. 3 0 0 77 Mar 15 10:50 . -drwx-----x. 9 0 0 4096 Nov 18 22:04 .. -""" - -# Truncated 64-character hash into '7HASH7' for legibility -DOCKER_VOLUME_HAS_VOL_DIR = """ -/var/lib/docker/volumes/: -total 4 -drwx------. 3 0 0 77 Mar 15 10:50 . -drwx-----x. 9 0 0 4096 Nov 18 22:04 .. -drwxr-xr-x. 3 0 0 18 Mar 15 10:50 7HASH7 - -/var/lib/docker/volumes/7HASH7: -total 0 -drwxr-xr-x. 3 0 0 18 Mar 15 10:50 . -drwx------. 3 0 0 77 Mar 15 10:50 .. -drwxr-xr-x. 2 0 0 6 Mar 15 10:50 _data - -/var/lib/docker/volumes/7HASH7/_data: -total 0 -drwxr-xr-x. 2 0 0 6 Mar 15 10:50 . -drwxr-xr-x. 3 0 0 18 Mar 15 10:50 .. -""" - -BASE_DIR = '/var/lib/docker/volumes/' - - -def test_empty_dir(): - ctx = context_wrap(DOCKER_VOLUME_EMPTY_DIR, path='/bin/ls -lanR /var/lib/docker/volumes') - dirs = DockerVolumesDir(ctx) - - assert BASE_DIR in dirs - assert dirs.dirs_of(BASE_DIR) == ['.', '..'] - assert dirs.files_of(BASE_DIR) == [] - - -def test_has_volumes(): - ctx = context_wrap(DOCKER_VOLUME_HAS_VOL_DIR, path='/bin/ls -lanR /var/lib/docker/volumes') - dirs = DockerVolumesDir(ctx) - - assert BASE_DIR in dirs - assert dirs.dirs_of(BASE_DIR) == ['.', '..', '7HASH7'] - assert dirs.files_of(BASE_DIR) == [] - - volume_dir = BASE_DIR + '7HASH7' - assert volume_dir in dirs - assert dirs.dirs_of(volume_dir) == ['.', '..', '_data'] - assert dirs.files_of(volume_dir) == [] diff --git a/insights/tests/parsers/test_ls_edac_mc.py b/insights/tests/parsers/test_ls_edac_mc.py deleted file mode 100644 index d18790c358..0000000000 --- a/insights/tests/parsers/test_ls_edac_mc.py +++ /dev/null @@ -1,29 +0,0 @@ -from insights.parsers import ls_edac_mc -from insights.parsers.ls_edac_mc import LsEdacMC -from insights.tests import context_wrap -import doctest - -LS_EDAC_MC = """ -/sys/devices/system/edac/mc: -total 37592 -drwxr-xr-x. 3 0 0 0 Jan 10 10:33 . -drwxr-xr-x. 3 0 0 0 Jan 10 10:33 .. -drwxr-xr-x. 2 0 0 0 Jan 10 10:33 power -drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc0 -drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc1 -drwxr-xr-x. 2 0 0 0 Jan 10 10:33 mc2 -""" - - -def test_ls_edac_mc(): - ls_edac_mc = LsEdacMC(context_wrap(LS_EDAC_MC)) - assert '/sys/devices/system/edac/mc' in ls_edac_mc - assert ls_edac_mc.dirs_of('/sys/devices/system/edac/mc') == ['.', '..', 'power', 'mc0', 'mc1', 'mc2'] - - -def test_ls_etc_documentation(): - failed_count, tests = doctest.testmod( - ls_edac_mc, - globs={'ls_edac_mc': ls_edac_mc.LsEdacMC(context_wrap(LS_EDAC_MC))} - ) - assert failed_count == 0 diff --git a/insights/tests/parsers/test_ls_etc.py b/insights/tests/parsers/test_ls_etc.py deleted file mode 100644 index cfd1f771c8..0000000000 --- a/insights/tests/parsers/test_ls_etc.py +++ /dev/null @@ -1,265 +0,0 @@ -import doctest - -from insights.parsers import ls_etc -from insights.tests import context_wrap - - -LS_ETC = """ -/etc/: -total 388 -drwxr-xr-x. 46 1000 1000 4096 Jun 11 21:01 . -drwx------. 15 1000 1000 4096 Aug 5 13:45 .. -drwxr-xr-x. 3 1000 1000 4096 Nov 12 2015 acpi -drwxr-xr-x. 2 1000 1000 4096 Apr 19 2017 alsa -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:56 alternatives --rw-r--r--. 1 1000 1000 148 Jan 12 2016 asound.conf -drwxr-x---. 2 1000 1000 4096 Jun 11 20:31 audit --rw-r--r--. 1 1000 1000 13641 Mar 13 2019 autofs.conf --rw-------. 1 1000 1000 232 Mar 13 2019 autofs_ldap_auth.conf --rw-r--r--. 1 1000 1000 667 Mar 13 2019 auto.master --rw-r--r--. 1 1000 1000 524 Mar 13 2019 auto.misc --rwxr-xr-x. 1 1000 1000 1260 Mar 13 2019 auto.net --rwxr-xr-x. 1 1000 1000 687 Mar 13 2019 auto.smb -drwxr-xr-x. 2 1000 1000 4096 Mar 24 2019 cron.d -drwxr-xr-x. 2 1000 1000 4096 Oct 20 2019 cron.daily --rw-------. 1 1000 1000 0 Jul 22 2016 cron.deny -drwxr-xr-x. 2 1000 1000 4096 Apr 19 2017 cron.hourly -drwxr-xr-x. 2 1000 1000 4096 Mar 5 2015 cron.monthly --rw-r--r--. 1 1000 1000 457 Jun 3 2011 crontab -drwxr-xr-x. 2 1000 1000 4096 May 17 2019 cups -drwxr-xr-x. 3 1000 1000 4096 Aug 18 2019 dbus-1 --rw-r--r--. 1 1000 1000 21214 Oct 22 2017 dnsmasq.conf --rw-r--r--. 1 1000 1000 1331 Jun 11 19:33 fstab -drwxr-xr-x. 6 1000 1000 4096 Jul 8 2018 gdm -lrwxrwxrwx. 1 1000 1000 22 Jun 11 20:56 grub.conf -> ../boot/grub/grub.conf --rw-r--r--. 1 1000 1000 9 Nov 2 2016 host.conf --rw-r--r--. 1 1000 1000 1128 Mar 6 2019 hosts --rw-r--r--. 1 1000 1000 158 Jan 12 2010 hosts.20150304.133833 --rw-r--r--. 1 1000 1000 986 Mar 5 2015 hosts.20180326.154713.ihaider --rw-r--r--. 1 1000 1000 370 Jan 12 2010 hosts.allow --rw-------. 1 1000 1000 1073 Mar 6 2019 hosts.backup --rw-r--r--. 1 1000 1000 460 Jan 12 2010 hosts.deny --rw-r--r--. 1 1000 1000 4850 Feb 8 2017 idmapd.conf -drwxr-xr-x. 2 1000 1000 4096 Jun 11 19:32 init --rw-r--r--. 1 1000 1000 0 Feb 12 2018 init.conf -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:55 init.d --rw-r--r--. 1 1000 1000 884 Apr 27 2018 inittab -drwxr-xr-x. 2 1000 1000 4096 Jul 8 2018 iproute2 --rw-r--r--. 1 1000 1000 2380 Jan 9 2020 ipsec.conf -drwx------. 3 1000 1000 4096 Mar 20 15:12 ipsec.d -drwxr-xr-x. 2 1000 1000 4096 Jun 27 2018 iscsi -drwxr-xr-x. 2 1000 1000 4096 Mar 24 2019 java --rw-r--r--. 1 1000 1000 8120 Jul 8 2018 kdump.conf --rw-r--r--. 1 1000 1000 4752 Jun 11 21:00 krb5.conf --rw-r--r--. 1 1000 1000 28 Jul 25 2013 ld.so.conf -drwxr-xr-x. 2 1000 1000 4096 Jun 11 20:55 ld.so.conf.d --rw-r--r--. 1 1000 1000 3519 May 4 2010 localtime --rw-r--r--. 1 1000 1000 215 Nov 19 2013 logrotate.conf --rw-r--r--. 1 1000 1000 662 Aug 29 2007 logrotate.conf.20150304.134454 -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:56 logrotate.d --rw-r--r--. 1 1000 1000 152 Mar 5 2015 lsb-release -drwxr-xr-x. 2 1000 1000 4096 Mar 5 2015 lsb-release.d -drwxr-xr-x. 6 1000 1000 4096 Jan 20 2018 lvm -drwxr-xr-x. 2 1000 1000 4096 Jun 11 19:32 modprobe.d --rw-r--r--. 1 1000 1000 744 Sep 18 2014 multipath.conf -drwxr-xr-x. 2 1000 1000 4096 Sep 12 2018 NetworkManager --rw-r--r--. 1 1000 1000 58 Apr 27 2018 networks --rw-r--r--. 1 1000 1000 3605 Mar 3 00:32 nfsmount.conf --rw-r--r--. 1 1000 1000 1724 Mar 5 2015 nsswitch.conf -drwxr-xr-x. 2 1000 1000 4096 Jan 27 2019 ntp --rw-r--r--. 1 1000 1000 261 Mar 23 2016 ntp.conf -drwxr-xr-x. 3 1000 1000 4096 Apr 19 2017 openldap -drwxr-xr-x. 2 1000 1000 4096 Jun 11 21:00 pam.d -drwxr-xr-x. 4 1000 1000 4096 Apr 19 2017 pki -drwxr-xr-x. 2 1000 1000 4096 Apr 19 2017 postfix -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:56 ppp -drwxr-xr-x. 10 1000 1000 4096 Jul 8 2018 rc.d --rw-r--r--. 1 1000 1000 56 Nov 22 2019 redhat-release --rw-r--r--. 1 1000 1000 1484 Jul 22 2014 request-key.conf -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:55 request-key.d --rw-r--r--. 1 1000 1000 71 Mar 5 2015 resolv.conf -drwxr-xr-x. 3 1000 1000 4096 Oct 20 2019 rhsm --rw-r--r--. 1 1000 1000 2951 Apr 19 2017 rsyslog.conf -drwxr-xr-x. 2 1000 1000 4096 Jan 17 2020 samba -drwxr-xr-x. 4 1000 1000 4096 May 29 09:35 security -drwxr-xr-x. 3 1000 1000 4096 Dec 6 2017 selinux -drwxr-xr-x. 2 1000 1000 4096 Jan 17 2020 snmp --rw-r--r--. 1 1000 1000 256 Oct 9 2019 sos.conf -drwxr-xr-x. 2 1000 1000 4096 Jun 11 21:01 ssh -drwxr-xr-x. 6 1000 1000 4096 Jun 11 20:55 sysconfig --rw-r--r--. 1 1000 1000 1183 Apr 17 09:32 sysctl.conf -drwxr-xr-x. 3 1000 1000 4096 Jan 17 2020 udev -drwxr-xr-x. 2 1000 1000 4096 Aug 4 16:02 vmware-tools -drwxr-xr-x. 3 1000 1000 4096 Jul 8 2018 X11 --rw-------. 1 1000 1000 1001 Dec 16 2015 xinetd.conf -drwxr-xr-x. 2 1000 1000 4096 Apr 19 2017 xinetd.d -drwxr-xr-x. 3 1000 1000 4096 Apr 16 2017 yum --rw-r--r--. 1 1000 1000 813 Mar 15 2016 yum.conf -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:53 yum.repos.d - -/etc/rc.d/init.d: -total 460 -drwxr-xr-x. 2 1000 1000 4096 Apr 19 07:55 . -drwxr-xr-x. 10 1000 1000 4096 Jul 8 2018 .. --rwxr-xr-x. 1 1000 1000 1287 Jan 24 2018 abrt-ccpp --rwxr-xr-x. 1 1000 1000 1628 Jan 24 2018 abrtd --rwxr-xr-x. 1 1000 1000 1641 Jan 24 2018 abrt-oops --rwxr-xr-x. 1 1000 1000 1818 Nov 12 2015 acpid --rwxr-xr-x. 1 1000 1000 2062 Oct 18 2016 atd --rwxr-xr-x. 1 1000 1000 3580 Dec 22 2016 auditd --rwxr-xr-x. 1 1000 1000 4040 Mar 13 2019 autofs --rwxr-xr-x. 1 1000 1000 11695 Aug 16 2019 b9daemon --rwxr-xr-x. 1 1000 1000 2105 Dec 4 2014 besclient --r-xr-xr-x. 1 1000 1000 1362 Nov 2 2017 blk-availability --rwxr--r--. 1 1000 1000 2155 Jan 29 2019 cbdaemon --rwxr-xr-x. 1 1000 1000 2010 Mar 5 2015 centrifydc --rwxr-xr-x. 1 1000 1000 11864 Jun 16 2015 cpuspeed --rwxr-xr-x. 1 1000 1000 2826 Jul 22 2016 crond --rwxr-xr-x. 1 1000 1000 3034 Feb 27 2019 cups --rwxr-xr-x. 1 1000 1000 1734 Sep 27 2017 dnsmasq --rw-r--r--. 1 1000 1000 25592 Apr 27 2018 functions --rwxr-xr-x. 1 1000 1000 1801 Jun 19 2014 haldaemon --rwxr-xr-x. 1 1000 1000 5985 Apr 27 2018 halt --rwxr-xr-x. 1 1000 1000 11244 Apr 16 2018 ip6tables --rwxr-xr-x. 1 1000 1000 6548 Jan 9 2020 ipsec --rwxr-xr-x. 1 1000 1000 11123 Apr 16 2018 iptables --rwxr-xr-x. 1 1000 1000 1938 Feb 2 2018 irqbalance --rwxr-xr-x. 1 1000 1000 4535 Jun 9 2017 iscsi --rwxr-xr-x. 1 1000 1000 3990 Jun 9 2017 iscsid --rwxr-xr-x. 1 1000 1000 21406 Apr 12 2018 kdump --rwxr-xr-x. 1 1000 1000 652 Apr 27 2018 killall --r-xr-xr-x. 1 1000 1000 2137 Nov 2 2017 lvm2-lvmetad --r-xr-xr-x. 1 1000 1000 3045 Nov 2 2017 lvm2-monitor --rwxr-xr-x. 1 1000 1000 2103 Oct 27 2015 mcelogd --rwxr-xr-x. 1 1000 1000 2571 Jan 26 2017 mdmonitor --rwxr-xr-x. 1 1000 1000 2200 Jul 8 2019 messagebus --rwxr-xr-x. 1 1000 1000 2523 Sep 11 2018 multipathd --r-x------. 1 1000 1000 22776 Mar 5 2015 netbackup --rwxr-xr-x. 1 1000 1000 4334 Apr 27 2018 netconsole --rwxr-xr-x. 1 1000 1000 5309 Apr 27 2018 netfs --rwxr-xr-x. 1 1000 1000 6742 Apr 27 2018 network --rwxr-xr-x. 1 1000 1000 2188 Jan 13 2017 NetworkManager --rwxr-xr-x. 1 1000 1000 6889 Mar 3 00:32 nfs --rwxr-xr-x. 1 1000 1000 3526 Mar 3 00:32 nfslock --rwxr-xr-x. 1 1000 1000 3570 Nov 23 2016 nfs-rdma --rwxr-xr-x. 1 1000 1000 1923 Dec 11 2018 ntpd --rwxr-xr-x. 1 1000 1000 2043 Dec 11 2018 ntpdate --rwxr-xr-x. 1 1000 1000 2023 Mar 17 2016 portreserve --rwxr-xr-x. 1 1000 1000 3912 Oct 31 2016 postfix --rwxr-xr-x. 1 1000 1000 1738 Mar 1 2016 pppoe-server --rwxr-xr-x. 1 1000 1000 1556 Nov 2 2016 psacct --rwxr-xr-x. 1 1000 1000 2034 Jan 7 2015 quota_nld --rwx------. 1 1000 1000 2092 Feb 1 2018 rc.agent_user --rwxr-xr-x. 1 1000 1000 1513 Dec 7 2016 rdisc --rwxr-xr-x. 1 1000 1000 12856 Nov 23 2016 rdma --rwxr-xr-x. 1 1000 1000 1822 Oct 25 2016 restorecond --rwxr-xr-x. 1 1000 1000 2898 Mar 19 2010 rhnsd --rwxr-xr-x. 1 1000 1000 1770 Jun 26 2019 rhsmcertd --rwxr-xr-x. 1 1000 1000 1808 Sep 3 2015 rngd --rwxr-xr-x. 1 1000 1000 2073 Feb 8 2018 rpcbind --rwxr-xr-x. 1 1000 1000 2518 Mar 3 00:32 rpcgssd --rwxr-xr-x. 1 1000 1000 2305 Mar 3 00:32 rpcidmapd --rwxr-xr-x. 1 1000 1000 2464 Mar 3 00:32 rpcsvcgssd --rwxr-xr-x. 1 1000 1000 2011 Dec 1 2017 rsyslog --rwxr-xr-x. 1 1000 1000 1698 Oct 25 2016 sandbox --rwxr-xr-x. 1 1000 1000 2056 Feb 27 2015 saslauthd --rwxr--r--. 1 1000 1000 1642 Apr 10 2017 scx-cimd --rwxr-xr-x. 1 1000 1000 647 Apr 27 2018 single --rwxr-xr-x. 1 1000 1000 3002 Oct 21 2016 smartd --rwxr-xr-x. 1 1000 1000 2162 Sep 26 2019 snmpd --rwxr-xr-x. 1 1000 1000 1738 Sep 26 2019 snmptrapd --rwxr-xr-x. 1 1000 1000 2472 Apr 2 2019 spice-vdagentd --rwx------. 1 1000 1000 1028 Jun 23 2018 splunk --rwxr-xr-x. 1 1000 1000 4621 Mar 20 2019 sshd --rwxr-xr-x. 1 1000 1000 1144 Nov 13 2017 sysstat --rwxr-xr-x. 1 1000 1000 2096 Mar 15 2018 tsys-notify --rwxr-xr-x. 1 1000 1000 2265 Jun 23 2014 tsys-notify.20190401.214025. --rwxr-xr-x. 1 1000 1000 2294 Oct 1 2019 udev-post --rwxr-xr-x. 1 1000 1000 3176 Apr 5 2019 udsagent -lrwxrwxrwx. 1 1000 1000 30 Jun 11 19:32 vmware-tools -> ../../vmware-tools/services.sh -lrwxrwxrwx. 1 1000 1000 40 Mar 5 2015 vxpbx_exchanged -> ../../../opt/VRTSpbx/bin/vxpbx_exchanged --rwxr-xr-x. 1 1000 1000 1598 Oct 9 2019 winbind --rwxr-xr-x. 1 1000 1000 1914 Oct 18 2017 wpa_supplicant --rwxr-xr-x. 1 1000 1000 3555 Dec 16 2015 xinetd - -/etc/sysconfig: -total 96 -drwxr-xr-x. 7 0 0 4096 Jul 6 23:41 . -drwxr-xr-x. 77 0 0 8192 Jul 13 03:55 .. -drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq -drwxr-xr-x. 2 0 0 6 Sep 16 2015 console --rw-------. 1 0 0 1390 Mar 4 2014 ebtables-config --rw-r--r--. 1 0 0 72 Sep 15 2015 firewalld -lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub - -/etc/rc.d/rc3.d: -total 4 -drwxr-xr-x. 2 0 0 58 Jul 6 23:32 . -drwxr-xr-x. 10 0 0 4096 Sep 16 2015 .. -lrwxrwxrwx. 1 0 0 20 Jul 6 23:32 K50netconsole -> ../init.d/netconsole -lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 S10network -> ../init.d/network -lrwxrwxrwx. 1 0 0 15 Jul 6 23:32 S97rhnsd -> ../init.d/rhnsd -""" - -LS_ETC_SSH = """ -total 612 -drwxr-xr-x. 3 0 0 245 Aug 11 14:19 . -drwxr-xr-x. 138 0 0 8192 Jul 29 19:11 .. --rw-r--r--. 1 0 0 577388 Mar 27 2020 moduli --rw-r--r--. 1 0 0 1770 Mar 27 2020 ssh_config -drwxr-xr-x. 2 0 0 28 May 12 17:10 ssh_config.d --rw-r-----. 1 0 994 480 May 13 09:58 ssh_host_ecdsa_key --rw-r--r--. 1 0 0 162 May 13 09:58 ssh_host_ecdsa_key.pub --rw-r-----. 1 0 994 387 May 13 09:58 ssh_host_ed25519_key --rw-r--r--. 1 0 0 82 May 13 09:58 ssh_host_ed25519_key.pub --rw-r-----. 1 0 994 2578 May 13 09:58 ssh_host_rsa_key --rw-r--r--. 1 0 0 554 May 13 09:58 ssh_host_rsa_key.pub --rw-------. 1 0 0 4260 Aug 11 14:19 sshd_config -""" - - -def test_ls_etc(): - list_etc = ls_etc.LsEtc(context_wrap(LS_ETC)) - assert "/etc/rc.d/init.d" in list_etc - assert "/etc/sysconfig" in list_etc - assert 'vmware-tools' in list_etc.files_of("/etc/rc.d/init.d") - assert len(list_etc.files_of("/etc/rc.d/init.d")) == 80 - assert len(list_etc.files_of("/etc/sysconfig")) == 3 - assert list_etc.files_of("/etc/sysconfig") == ['ebtables-config', 'firewalld', 'grub'] - assert list_etc.dirs_of("/etc/sysconfig") == ['.', '..', 'cbq', 'console'] - assert list_etc.specials_of("/etc/sysconfig") == [] - assert list_etc.total_of("/etc/sysconfig") == 96 - grub = list_etc.dir_entry("/etc/sysconfig", "grub") - assert grub is not None - assert grub == { - 'group': '0', - 'name': 'grub', - 'links': 1, - 'perms': 'rwxrwxrwx.', - 'raw_entry': 'lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub', - 'owner': '0', - 'link': '/etc/default/grub', - 'date': 'Jul 6 23:32', - 'type': 'l', - 'size': 17, - 'dir': '/etc/sysconfig'} - assert list_etc.files_of("/etc/rc.d/rc3.d") == ['K50netconsole', - 'S10network', 'S97rhnsd'] - - -def test_ls_etc_documentation(): - failed_count, tests = doctest.testmod( - ls_etc, - globs={'ls_etc': ls_etc.LsEtc(context_wrap(LS_ETC)), - 'ls_etc_ssh': ls_etc.LsEtcSsh(context_wrap(LS_ETC_SSH, path='ls_-lanL_.etc.ssh'))} - ) - assert failed_count == 0 - - -def test_ls_etc_ssh(): - ls_etc_ssh = ls_etc.LsEtcSsh(context_wrap(LS_ETC_SSH, path='ls_-lanL_.etc.ssh')) - assert '/etc/ssh' in ls_etc_ssh - assert len(ls_etc_ssh.files_of("/etc/ssh")) == 9 - assert ls_etc_ssh.files_of("/etc/ssh") == ['moduli', 'ssh_config', 'ssh_host_ecdsa_key', 'ssh_host_ecdsa_key.pub', 'ssh_host_ed25519_key', 'ssh_host_ed25519_key.pub', 'ssh_host_rsa_key', 'ssh_host_rsa_key.pub', 'sshd_config'] - assert ls_etc_ssh.dirs_of("/etc/ssh") == ['.', '..', 'ssh_config.d'] - assert ls_etc_ssh.listing_of("/etc/ssh")['ssh_host_rsa_key'] == {'group': '994', 'name': 'ssh_host_rsa_key', 'links': 1, 'perms': 'rw-r-----.', 'raw_entry': '-rw-r-----. 1 0 994 2578 May 13 09:58 ssh_host_rsa_key', 'owner': '0', 'date': 'May 13 09:58', 'type': '-', 'dir': '/etc/ssh', 'size': 2578} diff --git a/insights/tests/parsers/test_ls_file_permissions.py b/insights/tests/parsers/test_ls_file_permissions.py new file mode 100644 index 0000000000..5b30bb54ae --- /dev/null +++ b/insights/tests/parsers/test_ls_file_permissions.py @@ -0,0 +1,260 @@ +import pytest +from insights.util.file_permissions import FilePermissions +from insights.parsers.ls import FileListing +from insights.tests import context_wrap +from insights.tests.parsers import test_ls_file_listing + +PERMISSIONS_TEST_EXCEPTION_VECTORS = [ + ('-rw------ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), + ('bash: ls: command not found', True), + ('-rw------ 1 root root 762 Se', True), + ('-rw------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw-------. 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw-------@ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw-------+ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw-------* 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw-------asdf 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), + ('-rw------- 1 ro:t root 762 Sep 23 002 /etc/ssh/sshd_config', True), + ('-rw------- 1 root r:ot 762 Sep 23 002 /etc/ssh/sshd_config', True), + ('-rwasdfas- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), + ('-rwx/----- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), + ('/usr/bin/ls: cannot access /boot/grub2/grub.cfg: No such file or directory', True), + ('cannot access /boot/grub2/grub.cfg: No such file or directory', True), + ('No such file or directory', True), + ('adsf', True), +] + +PERMISSIONS_TEST_VECTORS = [ + ( + '-rw------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', + False, + 'rw-', + '---', + '---', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + True, + True, + ), + ( + '-rw------- 1 root root 762 Sep 23 002 /a path/with/spaces everywhere', + False, + 'rw-', + '---', + '---', + 'root', + 'root', + '/a path/with/spaces everywhere', + True, + True, + True, + True, + ), + ( + '-rw------- 1 root root 762 Sep 23 002 no_slash_here', + False, + 'rw-', + '---', + '---', + 'root', + 'root', + 'no_slash_here', + True, + True, + True, + True, + ), + ( + '-rw-------. 1 root root 4308 Apr 22 15:57 /etc/ssh/sshd_config', + False, + 'rw-', + '---', + '---', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + True, + True, + ), + ( + '-rw-rw-rw-. 1 root root 4308 Apr 22 15:57 /etc/ssh/sshd_config', + False, + 'rw-', + 'rw-', + 'rw-', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + False, + False, + ), + ( + '-rw-rw---- 1 root user 762 Sep 23 002 /etc/ssh/sshd_config', + True, + 'rw-', + 'rw-', + '---', + 'root', + 'user', + '/etc/ssh/sshd_config', + True, + False, + False, + False, + ), + ( + '-rw------- 1 root user 762 Sep 23 002 /etc/ssh/sshd_config', + False, + 'rw-', + '---', + '---', + 'root', + 'user', + '/etc/ssh/sshd_config', + True, + False, + True, + True, + ), + ( + '-rw------- 1 user root 762 Sep 23 002 /etc/ssh/sshd_config', + False, + 'rw-', + '---', + '---', + 'user', + 'root', + '/etc/ssh/sshd_config', + False, + False, + False, + False, + ), + ( + '-rw-rw---- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', + True, + 'rw-', + 'rw-', + '---', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + True, + True, + ), + ( + '-rw-rw-r-- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', + True, + 'rw-', + 'rw-', + 'r--', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + False, + True, + ), + ( + '-rw-rw--w- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', + True, + 'rw-', + 'rw-', + '-w-', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + True, + False, + ), + ( + '---------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', + False, + '---', + '---', + '---', + 'root', + 'root', + '/etc/ssh/sshd_config', + True, + True, + True, + True, + ), +] + + +def test_permissions(): + for vector in PERMISSIONS_TEST_VECTORS: + ( + line, + with_group, + permissions_owner, + permissions_group, + permissions_other, + owner, + group, + path, + owned_by_root_user, + owned_by_root_user_and_group, + only_root_can_read, + only_root_can_write, + ) = vector + p = FilePermissions(line) + assert p.perms_owner == permissions_owner + assert p.perms_group == permissions_group + assert p.perms_other == permissions_other + assert p.owner == owner + assert p.group == group + assert p.owned_by('root', also_check_group=False) == owned_by_root_user + assert p.owned_by('root', also_check_group=True) == owned_by_root_user_and_group + assert p.only_root_can_read(root_group_can_read=with_group) == only_root_can_read + assert p.only_root_can_write(root_group_can_write=with_group) == only_root_can_write + assert p.all_zero() == all( + (p.perms_owner == '---', p.perms_group == '---', p.perms_other == '---') + ) + assert p.owner_can_read() == ('r' in p.perms_owner) + assert p.owner_can_write() == ('w' in p.perms_owner) + assert p.owner_can_only_read() == ('r--' == p.perms_owner) + assert p.group_can_read() == ('r' in p.perms_group) + assert p.group_can_write() == ('w' in p.perms_group) + assert p.group_can_only_read() == ('r--' == p.perms_group) + assert p.others_can_read() == ('r' in p.perms_other) + assert p.others_can_write() == ('w' in p.perms_other) + assert p.others_can_only_read() == ('r--' == p.perms_other) + + +def test_permissions_invalid(): + for vector in PERMISSIONS_TEST_EXCEPTION_VECTORS: + garbage, should_raise = vector + if should_raise: + with pytest.raises(ValueError): + FilePermissions(garbage) + else: + # shouldn't raise an exception + FilePermissions(garbage) + + +def test_multiple_directories(): + dirs = FileListing(context_wrap(test_ls_file_listing.MULTIPLE_DIRECTORIES)) + assert '/etc/sysconfig' in dirs + assert 'cbq' in dirs.dirs_of('/etc/sysconfig') + # drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq + obj = FilePermissions.from_dict(dirs.path_entry('/etc/sysconfig/cbq')) + assert hasattr(obj, 'name') + assert obj.name == 'cbq' + assert obj.perms_owner == 'rwx' + assert obj.perms_group == 'r-x' + assert obj.perms_other == 'r-x' diff --git a/insights/tests/parsers/test_ls_ipa_idoverride_memberof.py b/insights/tests/parsers/test_ls_ipa_idoverride_memberof.py deleted file mode 100644 index a35e1ea9a4..0000000000 --- a/insights/tests/parsers/test_ls_ipa_idoverride_memberof.py +++ /dev/null @@ -1,27 +0,0 @@ -from insights.parsers import ls_ipa_idoverride_memberof -from insights.parsers.ls_ipa_idoverride_memberof import LsIPAIdoverrideMemberof -from insights.tests import context_wrap -import doctest - -LS_IPA_IDOVERRIDEMEMBEROF = """ -/usr/share/ipa/ui/js/plugins/idoverride-memberof: -total 0 -drwxr-xr-x. 2 0 0 0 Nov 11 11:44 . -drwxr-xr-x. 4 0 0 0 Nov 11 11:44 .. --rw-rw-r--. 1 0 0 0 Nov 11 11:44 idoverride-memberof.js --rw-rw-r--. 1 0 0 0 Nov 11 11:44 idoverride-admemberof.js -""" - - -def test_ls_ipa_idoverride_memberof(): - ls_ipa_idoverride_memberof = LsIPAIdoverrideMemberof(context_wrap(LS_IPA_IDOVERRIDEMEMBEROF)) - assert '/usr/share/ipa/ui/js/plugins/idoverride-memberof' in ls_ipa_idoverride_memberof - assert ls_ipa_idoverride_memberof.files_of('/usr/share/ipa/ui/js/plugins/idoverride-memberof') == ['idoverride-memberof.js', 'idoverride-admemberof.js'] - - -def test_ls_ipa_idoverride_memberof_doc(): - failed_count, tests = doctest.testmod( - ls_ipa_idoverride_memberof, - globs={'ls_ipa_idoverride_memberof': ls_ipa_idoverride_memberof.LsIPAIdoverrideMemberof(context_wrap(LS_IPA_IDOVERRIDEMEMBEROF))} - ) - assert failed_count == 0 diff --git a/insights/tests/parsers/test_ls_krb5_sssd.py b/insights/tests/parsers/test_ls_krb5_sssd.py deleted file mode 100644 index 933d59b4aa..0000000000 --- a/insights/tests/parsers/test_ls_krb5_sssd.py +++ /dev/null @@ -1,29 +0,0 @@ -from insights.parsers import ls_krb5_sssd -from insights.parsers.ls_krb5_sssd import LsKrb5SSSD -from insights.tests import context_wrap -import doctest - -LS_KRB5_SSSD = """ -/var/lib/sss/pubconf/krb5.include.d: -total 24 -drwxr-xr-x@ 6 501 20 192 Jul 1 23:46 . -drwxr-xr-x@ 3 501 20 96 Jul 1 23:48 .. --rw-r--r--@ 1 501 20 674 Jul 1 23:46 domain_realm_rhidm_gwl_bz --rw-r--r--@ 1 501 20 35 Jul 1 23:46 krb5_libdefaults --rw-r--r--@ 1 501 20 98 Jul 1 23:46 localauth_plugin --rw-------@ 1 501 20 0 Oct 1 2021 localauth_pluginolsIe3 -""" - - -def test_ls_krb5_sssd(): - ls_krb5_sssd = LsKrb5SSSD(context_wrap(LS_KRB5_SSSD)) - assert '/var/lib/sss/pubconf/krb5.include.d' in ls_krb5_sssd - assert ls_krb5_sssd.files_of('/var/lib/sss/pubconf/krb5.include.d') == ['domain_realm_rhidm_gwl_bz', 'krb5_libdefaults', 'localauth_plugin', 'localauth_pluginolsIe3'] - - -def test_ls_krb5_sssd_doc(): - failed_count, tests = doctest.testmod( - ls_krb5_sssd, - globs={'ls_krb5_sssd': ls_krb5_sssd.LsKrb5SSSD(context_wrap(LS_KRB5_SSSD))} - ) - assert failed_count == 0 diff --git a/insights/tests/parsers/test_ls_lib_firmware.py b/insights/tests/parsers/test_ls_lib_firmware.py deleted file mode 100644 index fa879c75d7..0000000000 --- a/insights/tests/parsers/test_ls_lib_firmware.py +++ /dev/null @@ -1,89 +0,0 @@ -import doctest - -from insights.parsers import ls_lib_firmware -from insights.parsers.ls_lib_firmware import LsLibFW -from insights.tests import context_wrap - -LS_LIB_FW = """ -/lib/firmware: -total 37592 -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 . -dr-xr-xr-x. 26 0 0 4096 Aug 14 02:22 .. -drwxr-xr-x. 2 0 0 40 Aug 14 02:42 3com -lrwxrwxrwx. 1 0 0 16 Aug 14 02:42 a300_pfp.fw -> qcom/a300_pfp.fw -lrwxrwxrwx. 1 0 0 16 Aug 14 02:42 a300_pm4.fw -> qcom/a300_pm4.fw -drwxr-xr-x. 2 0 0 34 Aug 14 02:42 acenic -drwxr-xr-x. 2 0 0 50 Aug 14 02:42 adaptec -drwxr-xr-x. 2 0 0 73 Aug 14 02:42 advansys - -/lib/firmware/3com: -total 84 -drwxr-xr-x. 2 0 0 40 Aug 14 02:42 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 24880 Jun 6 10:14 3C359.bin --rw-r--r--. 1 0 0 44548 Jun 6 10:14 typhoon.bin - -/lib/firmware/acenic: -total 160 -drwxr-xr-x. 2 0 0 34 Aug 14 02:42 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 73116 Jun 6 10:14 tg1.bin --rw-r--r--. 1 0 0 77452 Jun 6 10:14 tg2.bin - -/lib/firmware/adaptec: -total 20 -drwxr-xr-x. 2 0 0 50 Aug 14 02:42 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 832 Jun 6 10:14 starfire_rx.bin --rw-r--r--. 1 0 0 832 Jun 6 10:14 starfire_tx.bin - -/lib/firmware/advansys: -total 40 -drwxr-xr-x. 2 0 0 73 Aug 14 02:42 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 5026 Jun 6 10:14 3550.bin --rw-r--r--. 1 0 0 5340 Jun 6 10:14 38C0800.bin --rw-r--r--. 1 0 0 6334 Jun 6 10:14 38C1600.bin --rw-r--r--. 1 0 0 2308 Jun 6 10:14 mcode.bin - -/lib/firmware/bnx2: -total 1448 -drwxr-xr-x. 2 0 0 4096 Aug 14 02:43 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 92628 Jun 6 10:14 bnx2-mips-06-4.6.16.fw --rw-r--r--. 1 0 0 93172 Jun 6 10:14 bnx2-mips-06-5.0.0.j3.fw --rw-r--r--. 1 0 0 94252 Jun 6 10:14 bnx2-mips-06-5.0.0.j6.fw --rw-r--r--. 1 0 0 92824 Jun 6 10:14 bnx2-mips-06-6.2.3.fw --rw-r--r--. 1 0 0 92760 Jun 6 10:14 bnx2-mips-09-4.6.17.fw --rw-r--r--. 1 0 0 96996 Jun 6 10:14 bnx2-mips-09-5.0.0.j15.fw - -/lib/firmware/bnx2x: -total 8772 -drwxr-xr-x. 2 0 0 4096 Aug 14 02:43 . -drwxr-xr-x. 83 0 0 8192 Aug 14 02:43 .. --rw-r--r--. 1 0 0 151568 Jun 6 10:14 bnx2x-e1-6.0.34.0.fw --rw-r--r--. 1 0 0 151680 Jun 6 10:14 bnx2x-e1-6.2.5.0.fw --rw-r--r--. 1 0 0 151688 Jun 6 10:14 bnx2x-e1-6.2.9.0.fw --rw-r--r--. 1 0 0 161144 Jun 6 10:14 bnx2x-e1-7.0.20.0.fw --rw-r--r--. 1 0 0 161248 Jun 6 10:14 bnx2x-e1-7.0.23.0.fw -""".strip() - - -def test_ls_lib_firmware(): - lslib = LsLibFW(context_wrap(LS_LIB_FW)) - assert "bnx2x" not in lslib - assert "/lib/firmware/bnx2" in lslib - assert "/lib/firmware/bnx2x" in lslib - assert lslib.dirs_of("/lib/firmware") == ['.', '..', '3com', 'acenic', 'adaptec', 'advansys'] - assert lslib.files_of("/lib/firmware/bnx2x") == ['bnx2x-e1-6.0.34.0.fw', 'bnx2x-e1-6.2.5.0.fw', 'bnx2x-e1-6.2.9.0.fw', 'bnx2x-e1-7.0.20.0.fw', 'bnx2x-e1-7.0.23.0.fw'] - assert "bnx2x-e1-6.0.34.0.fw" in lslib.files_of("/lib/firmware/bnx2x") - assert lslib.dir_contains("/lib/firmware/bnx2x", "bnx2x-e1-6.0.34.0.fw") is True - assert lslib.total_of("/lib/firmware") == 37592 - - -def test_ls_lib_firmware_doc_examples(): - env = { - 'lslibfw': LsLibFW(context_wrap(LS_LIB_FW)), - } - failed, total = doctest.testmod(ls_lib_firmware, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_ocp_nci_openshift_sdn.py b/insights/tests/parsers/test_ls_ocp_nci_openshift_sdn.py deleted file mode 100644 index 850013fa74..0000000000 --- a/insights/tests/parsers/test_ls_ocp_nci_openshift_sdn.py +++ /dev/null @@ -1,35 +0,0 @@ -import doctest - -from insights.parsers import ls_ocp_cni_openshift_sdn -from insights.parsers.ls_ocp_cni_openshift_sdn import LsOcpCniOpenshiftSdn -from insights.tests import context_wrap - -LS_CNI_OPENSHIFT_SDN = """ -total 52 --rw-r--r--. 1 root root 64 Aug 5 23:26 10.130.0.102 --rw-r--r--. 1 root root 64 Aug 5 23:26 10.130.0.103 --rw-r--r--. 1 root root 64 Aug 6 22:52 10.130.0.116 --rw-r--r--. 1 root root 64 Aug 6 22:52 10.130.0.117 --rw-r--r--. 1 root root 64 Aug 5 06:59 10.130.0.15 --rw-r--r--. 1 root root 64 Aug 5 07:02 10.130.0.20 --rw-r--r--. 1 root root 12 Aug 6 22:52 last_reserved_ip.0 -""".strip() - - -def test_ls_ocp_cni_openshift_sdn(): - ls_ocp_cni_openshift_sdn = LsOcpCniOpenshiftSdn( - context_wrap(LS_CNI_OPENSHIFT_SDN, path='insights_commands/ls_-l_.var.lib.cni.networks.openshift-sdn')) - assert len(ls_ocp_cni_openshift_sdn.files_of("/var/lib/cni/networks/openshift-sdn")) == 7 - assert ls_ocp_cni_openshift_sdn.files_of("/var/lib/cni/networks/openshift-sdn") == ['10.130.0.102', '10.130.0.103', - '10.130.0.116', '10.130.0.117', - '10.130.0.15', '10.130.0.20', - 'last_reserved_ip.0'] - - -def test_ls_ocp_cni_openshift_sdn_doc_examples(): - env = { - 'ls_ocp_cni_openshift_sdn': LsOcpCniOpenshiftSdn( - context_wrap(LS_CNI_OPENSHIFT_SDN, path='insights_commands/ls_-l_.var.lib.cni.networks.openshift-sdn')), - } - failed, total = doctest.testmod(ls_ocp_cni_openshift_sdn, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_origin_local_volumes_pods.py b/insights/tests/parsers/test_ls_origin_local_volumes_pods.py deleted file mode 100644 index 11a6506ef2..0000000000 --- a/insights/tests/parsers/test_ls_origin_local_volumes_pods.py +++ /dev/null @@ -1,34 +0,0 @@ -import doctest -from insights.parsers import ls_origin_local_volumes_pods -from insights.parsers.ls_origin_local_volumes_pods import LsOriginLocalVolumePods -from insights.tests import context_wrap - -LS_ORIGIN_LOCAL_VOLUME_PODS = """ -total 0 -drwxr-x---. 5 root root 71 Oct 18 23:20 5946c1f644096161a1242b3de0ee5875 -drwxr-x---. 5 root root 71 Oct 18 23:24 6ea3d5cd-d34e-11e8-a142-001a4a160152 -drwxr-x---. 5 root root 71 Oct 18 23:31 77d6d959-d34f-11e8-a142-001a4a160152 -drwxr-x---. 5 root root 71 Oct 18 23:24 7ad952a0-d34e-11e8-a142-001a4a160152 -drwxr-x---. 5 root root 71 Oct 18 23:24 7b63e8aa-d34e-11e8-a142-001a4a160152 -""".strip() - - -def test_ls_origin_local_volumes_pods(): - ls_origin_local_volumes_pods = LsOriginLocalVolumePods( - context_wrap(LS_ORIGIN_LOCAL_VOLUME_PODS, - path='insights_commands/ls_-l_.var.lib.origin.openshift.local.volumes.pods')) - assert len(ls_origin_local_volumes_pods.pods) == 5 - assert ls_origin_local_volumes_pods.pods == [ - '5946c1f644096161a1242b3de0ee5875', '6ea3d5cd-d34e-11e8-a142-001a4a160152', - '77d6d959-d34f-11e8-a142-001a4a160152', '7ad952a0-d34e-11e8-a142-001a4a160152', - '7b63e8aa-d34e-11e8-a142-001a4a160152'] - - -def test_ls_origin_local_volumes_pods_doc_examples(): - env = { - 'ls_origin_local_volumes_pods': LsOriginLocalVolumePods( - context_wrap(LS_ORIGIN_LOCAL_VOLUME_PODS, - path='insights_commands/ls_-l_.var.lib.origin.openshift.local.volumes.pods')), - } - failed, total = doctest.testmod(ls_origin_local_volumes_pods, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_osroot.py b/insights/tests/parsers/test_ls_osroot.py deleted file mode 100644 index 3bcb46abee..0000000000 --- a/insights/tests/parsers/test_ls_osroot.py +++ /dev/null @@ -1,51 +0,0 @@ -import doctest - -from insights.parsers import ls_osroot -from insights.parsers.ls_osroot import LsOsroot -from insights.tests import context_wrap - -LS_LAN_OSROOT = """ -total 5256 -dr-xr-xr-x. 17 0 0 271 Apr 5 18:08 . -dr-xr-xr-x. 17 0 0 271 Apr 5 18:08 .. --rw-r--r--. 1 0 0 0 Feb 25 2017 1 -lrwxrwxrwx. 1 0 0 7 Feb 25 2017 bin -> usr/bin -dr-xr-xr-x. 3 0 0 4096 Feb 25 2017 boot --rw-r--r--. 1 0 0 5168141 Oct 16 2017 channel-list -drwxr-xr-x. 21 0 0 3440 Apr 12 14:46 dev -drwxr-xr-x. 148 0 0 8192 Apr 18 09:17 etc -drwxr-xr-x. 5 0 0 37 Jul 31 2017 home -lrwxrwxrwx. 1 0 0 7 Feb 25 2017 lib -> usr/lib -lrwxrwxrwx. 1 0 0 9 Feb 25 2017 lib64 -> usr/lib64 -drwxr-xr-x. 2 0 0 6 Mar 10 2016 media -drwxr-xr-x. 2 0 0 6 Mar 10 2016 mnt -drwxr-xr-x. 5 0 0 48 Mar 27 13:37 opt -dr-xr-xr-x. 265 0 0 0 Apr 6 02:07 proc --rw-r--r--. 1 0 0 175603 Apr 5 18:08 .readahead -dr-xr-x---. 26 0 0 4096 Apr 18 09:17 root -drwxr-xr-x. 43 0 0 1340 Apr 18 09:17 run -lrwxrwxrwx. 1 0 0 8 Feb 25 2017 sbin -> usr/sbin -drwxr-xr-x. 2 0 0 6 Mar 10 2016 srv -dr-xr-xr-x. 13 0 0 0 Apr 5 18:07 sys -drwxrwxrwt. 40 0 0 8192 Apr 18 11:17 tmp -drwxr-xr-x. 13 0 0 155 Feb 25 2017 usr -drwxr-xr-x. 21 0 0 4096 Apr 6 02:07 var -""".strip() - - -def test_ls_osroot(): - ls_osroot = LsOsroot(context_wrap(LS_LAN_OSROOT, path='ls_-lan')) - assert '/' in ls_osroot - assert len(ls_osroot.files_of("/")) == 7 - assert ls_osroot.files_of("/") == ['1', 'bin', 'channel-list', 'lib', 'lib64', '.readahead', 'sbin'] - assert ls_osroot.dirs_of("/") == ['.', '..', 'boot', 'dev', 'etc', 'home', 'media', 'mnt', 'opt', 'proc', 'root', 'run', 'srv', 'sys', 'tmp', 'usr', 'var'] - assert ls_osroot.listing_of("/")['tmp'] == {'group': '0', 'name': 'tmp', 'links': 40, 'perms': 'rwxrwxrwt.', 'raw_entry': 'drwxrwxrwt. 40 0 0 8192 Apr 18 11:17 tmp', 'owner': '0', 'date': 'Apr 18 11:17', 'type': 'd', 'dir': '/', 'size': 8192} - - -def test_ls_osroot_doc_examples(): - env = { - 'LsOsroot': LsOsroot, - 'ls_osroot': LsOsroot(context_wrap(LS_LAN_OSROOT, path='ls_-lan')), - } - failed, total = doctest.testmod(ls_osroot, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_rsyslog_errorfile.py b/insights/tests/parsers/test_ls_rsyslog_errorfile.py deleted file mode 100644 index b0f1a17987..0000000000 --- a/insights/tests/parsers/test_ls_rsyslog_errorfile.py +++ /dev/null @@ -1,41 +0,0 @@ -from insights.core.exceptions import ParseException -from insights.parsers import ls_rsyslog_errorfile -from insights.parsers.ls_rsyslog_errorfile import LsRsyslogErrorfile -from insights.tests import context_wrap -import doctest -import pytest - -LS_RSYSLOG_ERRORFILE = """ -/bin/ls: cannot access '/var/log/rsyslog/es-errors2.log': No such file or directory -/bin/ls: cannot access '/var/log/rsyslog/es-errors3.log': No such file or directory --rw-r--r--. 1 0 0 9 Mar 15 17:16 /var/log/omelasticsearch.log --rw-r--r--. 1 0 0 176 Mar 22 15:10 /var/log/rsyslog/es-errors1.log -""" - -LS_RSYSLOG_ERRORFILE_ERROR = """ -/bin/ls: cannot access '/var/log/omelasticsearch.log': No such file or directory -/bin/ls: cannot access '/var/log/rsyslog/es-errors1.log': No such file or directory -/bin/ls: cannot access '/var/log/rsyslog/es-errors2.log': No such file or directory -/bin/ls: cannot access '/var/log/rsyslog/es-errors3.log': No such file or directory -""" - - -def test_ls_rsyslog_errorfile(): - rsyslog_errorfile = LsRsyslogErrorfile(context_wrap(LS_RSYSLOG_ERRORFILE)) - assert len(rsyslog_errorfile.entries) == 2 - assert rsyslog_errorfile.entries.get('/var/log/omelasticsearch.log') == {'type': '-', 'perms': 'rw-r--r--.', 'links': 1, 'owner': '0', 'group': '0', 'size': 9, 'date': 'Mar 15 17:16', 'name': '/var/log/omelasticsearch.log', 'raw_entry': '-rw-r--r--. 1 0 0 9 Mar 15 17:16 /var/log/omelasticsearch.log', 'dir': ''} - assert rsyslog_errorfile.entries.get('/var/log/rsyslog/es-errors1.log').get('size') == 176 - - -def test_ls_rsyslog_errorfile_err(): - with pytest.raises(ParseException) as pe: - LsRsyslogErrorfile(context_wrap(LS_RSYSLOG_ERRORFILE_ERROR)) - assert 'Error:' in str(pe) - - -def test_ls_rsyslog_errorfile_doc_examples(): - env = { - 'rsyslog_errorfile': LsRsyslogErrorfile(context_wrap(LS_RSYSLOG_ERRORFILE)), - } - failed, total = doctest.testmod(ls_rsyslog_errorfile, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_systemd_units.py b/insights/tests/parsers/test_ls_systemd_units.py deleted file mode 100644 index 56f8e996cb..0000000000 --- a/insights/tests/parsers/test_ls_systemd_units.py +++ /dev/null @@ -1,1084 +0,0 @@ -import doctest - -from insights.parsers import ls_systemd_units -from insights.parsers.ls_systemd_units import LsSystemdUnits -from insights.tests import context_wrap - -# deliberately full output -LS_OUTPUT_FULL = """ -/etc/systemd: -total 40 -drwxr-xr-x. 4 0 0 150 Apr 4 2019 . -drwxr-xr-x. 88 0 0 8192 Jun 28 06:56 .. --rw-r--r--. 1 0 0 615 Jun 22 2018 coredump.conf --rw-r--r--. 1 0 0 1027 Jun 22 2018 journald.conf --rw-r--r--. 1 0 0 1052 Apr 4 2019 logind.conf --rw-r--r--. 1 0 0 631 Feb 26 2019 resolved.conf -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 system --rw-r--r--. 1 0 0 1682 Feb 26 2019 system.conf -drwxr-xr-x. 2 0 0 6 Feb 26 2019 user --rw-r--r--. 1 0 0 1130 Jun 22 2018 user.conf - -/etc/systemd/system: -total 28 -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 4 0 0 150 Apr 4 2019 .. -drwxr-xr-x. 2 0 0 31 Apr 4 2019 basic.target.wants --rw-r--r--. 1 0 0 1341 Feb 8 2019 dbus-org.freedesktop.NetworkManager.service --rw-r--r--. 1 0 0 353 Feb 8 2019 dbus-org.freedesktop.nm-dispatcher.service --rw-r--r--. 1 0 0 238 Nov 7 2017 dbus-org.freedesktop.timedate1.service --rw-r--r--. 1 0 0 532 Jun 22 2018 default.target -drwxr-xr-x. 2 0 0 32 Apr 4 2019 getty.target.wants -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 multi-user.target.wants -drwxr-xr-x. 2 0 0 48 Apr 4 2019 network-online.target.wants -drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-blkmap.service.requires -drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-idmapd.service.requires -drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-mountd.service.requires -drwxr-xr-x. 2 0 0 33 Apr 4 2019 nfs-server.service.requires -drwxr-xr-x. 2 0 0 31 Apr 4 2019 remote-fs.target.wants -drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-gssd.service.requires -drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-statd-notify.service.requires -drwxr-xr-x. 2 0 0 33 Apr 4 2019 rpc-statd.service.requires -drwxr-xr-x. 2 0 0 51 Apr 4 2019 sockets.target.wants -drwxr-xr-x. 2 0 0 151 Apr 4 2019 sysinit.target.wants --rw-r--r--. 1 0 0 583 Dec 17 2018 syslog.service -crw-rw-rw-. 1 0 0 1, 3 Jun 28 06:56 systemd-timedated.service -drwxr-xr-x. 2 0 0 34 Apr 4 2019 timers.target.wants - -/etc/systemd/system/basic.target.wants: -total 8 -drwxr-xr-x. 2 0 0 31 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 284 Nov 6 2018 microcode.service - -/etc/systemd/system/getty.target.wants: -total 8 -drwxr-xr-x. 2 0 0 32 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 1975 Feb 26 2019 getty@tty1.service - -/etc/systemd/system/multi-user.target.wants: -total 80 -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 1516 Jan 9 2019 auditd.service --rw-r--r--. 1 0 0 495 Aug 13 2018 chronyd.service --rw-r--r--. 1 0 0 491 Jan 23 2019 cloud-config.service --rw-r--r--. 1 0 0 514 Jan 23 2019 cloud-final.service --rw-r--r--. 1 0 0 878 Jan 23 2019 cloud-init-local.service --rw-r--r--. 1 0 0 648 Jan 23 2019 cloud-init.service --rw-r--r--. 1 0 0 322 Oct 2 2018 crond.service --rw-r--r--. 1 0 0 301 Jan 4 2019 dnf-makecache.timer --rw-r--r--. 1 0 0 224 Nov 6 2018 irqbalance.service --rw-r--r--. 1 0 0 349 Feb 22 2019 kdump.service --rw-r--r--. 1 0 0 1341 Feb 8 2019 NetworkManager.service --rw-r--r--. 1 0 0 413 Feb 15 2019 nfs-client.target --rw-r--r--. 1 0 0 522 Jun 22 2018 remote-fs.target --rw-r--r--. 1 0 0 547 Oct 20 2018 rpcbind.service --rw-r--r--. 1 0 0 583 Dec 17 2018 rsyslog.service --rw-r--r--. 1 0 0 456 Nov 26 2018 sshd.service --rw-r--r--. 1 0 0 420 Feb 11 2019 sssd.service --rw-r--r--. 1 0 0 376 Jul 4 2018 tuned.service - -/etc/systemd/system/network-online.target.wants: -total 8 -drwxr-xr-x. 2 0 0 48 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 302 Feb 8 2019 NetworkManager-wait-online.service - -/etc/systemd/system/nfs-blkmap.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/nfs-idmapd.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/nfs-mountd.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/nfs-server.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/remote-fs.target.wants: -total 8 -drwxr-xr-x. 2 0 0 31 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 413 Feb 15 2019 nfs-client.target - -/etc/systemd/system/rpc-gssd.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/rpc-statd-notify.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/rpc-statd.service.requires: -total 8 -drwxr-xr-x. 2 0 0 33 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service - -/etc/systemd/system/sockets.target.wants: -total 12 -drwxr-xr-x. 2 0 0 51 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 368 Oct 20 2018 rpcbind.socket --rw-r--r--. 1 0 0 187 Feb 11 2019 sssd-kcm.socket - -/etc/systemd/system/sysinit.target.wants: -total 24 -drwxr-xr-x. 2 0 0 151 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 441 Aug 3 2018 import-state.service --rw-r--r--. 1 0 0 355 Aug 3 2018 loadmodules.service --rw-r--r--. 1 0 0 378 Aug 12 2018 nis-domainname.service --rw-r--r--. 1 0 0 126 Dec 21 2018 rngd.service --rw-r--r--. 1 0 0 406 Dec 14 2018 selinux-autorelabel-mark.service - -/etc/systemd/system/timers.target.wants: -total 8 -drwxr-xr-x. 2 0 0 34 Apr 4 2019 . -drwxr-xr-x. 17 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 346 Aug 12 2018 unbound-anchor.timer - -/etc/systemd/user: -total 0 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 4 0 0 150 Apr 4 2019 .. - -/run/systemd: -total 0 -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 . -drwxr-xr-x. 27 0 0 820 Jun 28 06:56 .. -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 ask-password -srwx------. 1 0 0 0 Jun 28 06:56 cgroups-agent -srw-------. 1 0 0 0 Jun 28 06:56 coredump -drwxr-xr-x. 4 0 0 100 Jun 28 06:56 generator -d---------. 3 0 0 160 Jun 28 06:56 inaccessible -drwxr-xr-x. 2 0 0 80 Jun 28 06:56 inhibit -drwxr-xr-x. 3 0 0 160 Jun 28 06:56 journal -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 machines -srwxrwxrwx. 1 0 0 0 Jun 28 06:56 notify -srwxrwxrwx. 1 0 0 0 Jun 28 06:56 private -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 seats -drwxr-xr-x. 2 0 0 80 Jun 28 09:44 sessions --rw-r--r--. 1 0 0 0 Jun 28 06:56 show-status -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 shutdown -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 system -drwxr-xr-x. 2 0 0 60 Jun 28 09:44 transient -drwx------. 2 0 0 40 Jun 28 06:56 unit-root -drwxr-xr-x. 2 0 0 1100 Jun 28 09:44 units -drwxr-xr-x. 2 0 0 60 Jun 28 09:44 users - -/run/systemd/ask-password: -total 0 -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. - -/run/systemd/generator: -total 4 -drwxr-xr-x. 4 0 0 100 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 getty.target.wants -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 local-fs.target.requires --rw-r--r--. 1 0 0 250 Jun 28 06:56 -.mount - -/run/systemd/generator/getty.target.wants: -total 4 -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 . -drwxr-xr-x. 4 0 0 100 Jun 28 06:56 .. --rw-r--r--. 1 0 0 1486 Feb 26 2019 serial-getty@ttyS0.service - -/run/systemd/generator/local-fs.target.requires: -total 4 -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 . -drwxr-xr-x. 4 0 0 100 Jun 28 06:56 .. --rw-r--r--. 1 0 0 250 Jun 28 06:56 -.mount - -/run/systemd/inhibit: -total 4 -drwxr-xr-x. 2 0 0 80 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. --rw-r--r--. 1 0 0 171 Jun 28 06:56 1 -prw-------. 1 0 0 0 Jun 28 06:56 1.ref - -/run/systemd/journal: -total 4 -drwxr-xr-x. 3 0 0 160 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. -srw-rw-rw-. 1 0 0 0 Jun 28 06:56 dev-log --rw-r--r--. 1 0 0 0 Jun 28 06:56 flushed --rw-r--r--. 1 0 0 8 Jun 28 06:56 kernel-seqnum -srw-rw-rw-. 1 0 0 0 Jun 28 06:56 socket -srw-rw-rw-. 1 0 0 0 Jun 28 06:56 stdout -drwxr-xr-x. 2 0 0 300 Jun 28 09:44 streams - -/run/systemd/journal/streams: -total 52 -drwxr-xr-x. 2 0 0 300 Jun 28 09:44 . -drwxr-xr-x. 3 0 0 160 Jun 28 06:56 .. --rw-------. 1 0 0 206 Jun 28 06:56 9:18798 --rw-------. 1 0 0 218 Jun 28 06:56 9:19287 --rw-------. 1 0 0 207 Jun 28 06:56 9:19451 --rw-------. 1 0 0 200 Jun 28 06:56 9:19575 --rw-------. 1 0 0 212 Jun 28 06:56 9:19630 --rw-------. 1 0 0 200 Jun 28 06:56 9:19632 --rw-------. 1 0 0 208 Jun 28 06:56 9:19698 --rw-------. 1 0 0 220 Jun 28 06:56 9:20300 --rw-------. 1 0 0 220 Jun 28 06:56 9:21974 --rw-------. 1 0 0 202 Jun 28 06:56 9:22048 --rw-------. 1 0 0 202 Jun 28 06:56 9:24955 --rw-------. 1 0 0 200 Jun 28 06:56 9:25790 --rw-------. 1 0 0 185 Jun 28 09:44 9:32559 - -/run/systemd/machines: -total 0 -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. - -/run/systemd/seats: -total 4 -drwxr-xr-x. 2 0 0 60 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. --rw-r--r--. 1 0 0 95 Jun 28 06:56 seat0 - -/run/systemd/sessions: -total 4 -drwxr-xr-x. 2 0 0 80 Jun 28 09:44 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. --rw-r--r--. 1 0 0 287 Jun 28 09:44 5 -prw-------. 1 0 0 0 Jun 28 09:44 5.ref - -/run/systemd/shutdown: -total 0 -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. - -/run/systemd/system: -total 0 -drwxr-xr-x. 2 0 0 40 Jun 28 06:56 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. - -/run/systemd/transient: -total 4 -drwxr-xr-x. 2 0 0 60 Jun 28 09:44 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. --rw-r--r--. 1 0 0 278 Jun 28 09:44 session-5.scope - -/run/systemd/units: -total 0 -drwxr-xr-x. 2 0 0 1100 Jun 28 09:44 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. -l?????????? ? ? ? ? ? invocation:auditd.service -l?????????? ? ? ? ? ? invocation:chronyd.service -l?????????? ? ? ? ? ? invocation:cloud-config.service -l?????????? ? ? ? ? ? invocation:cloud-final.service -l?????????? ? ? ? ? ? invocation:cloud-init-local.service -l?????????? ? ? ? ? ? invocation:cloud-init.service -l?????????? ? ? ? ? ? invocation:crond.service -l?????????? ? ? ? ? ? invocation:dbus.service -l?????????? ? ? ? ? ? invocation:dev-hugepages.mount -l?????????? ? ? ? ? ? invocation:dev-mqueue.mount -l?????????? ? ? ? ? ? invocation:dracut-shutdown.service -l?????????? ? ? ? ? ? invocation:getty@tty1.service -l?????????? ? ? ? ? ? invocation:gssproxy.service -l?????????? ? ? ? ? ? invocation:import-state.service -l?????????? ? ? ? ? ? invocation:irqbalance.service -l?????????? ? ? ? ? ? invocation:kdump.service -l?????????? ? ? ? ? ? invocation:kmod-static-nodes.service -l?????????? ? ? ? ? ? invocation:ldconfig.service -l?????????? ? ? ? ? ? invocation:NetworkManager.service -l?????????? ? ? ? ? ? invocation:NetworkManager-wait-online.service -l?????????? ? ? ? ? ? invocation:nis-domainname.service -l?????????? ? ? ? ? ? invocation:polkit.service -l?????????? ? ? ? ? ? invocation:rngd.service -l?????????? ? ? ? ? ? invocation:rpcbind.service -l?????????? ? ? ? ? ? invocation:rpc-statd-notify.service -l?????????? ? ? ? ? ? invocation:rsyslog.service -l?????????? ? ? ? ? ? invocation:serial-getty@ttyS0.service -l?????????? ? ? ? ? ? invocation:session-5.scope -l?????????? ? ? ? ? ? invocation:sshd.service -l?????????? ? ? ? ? ? invocation:sssd.service -l?????????? ? ? ? ? ? invocation:sys-kernel-config.mount -l?????????? ? ? ? ? ? invocation:sys-kernel-debug.mount -l?????????? ? ? ? ? ? invocation:systemd-hwdb-update.service -l?????????? ? ? ? ? ? invocation:systemd-journal-catalog-update.service -l?????????? ? ? ? ? ? invocation:systemd-journald.service -l?????????? ? ? ? ? ? invocation:systemd-journal-flush.service -l?????????? ? ? ? ? ? invocation:systemd-logind.service -l?????????? ? ? ? ? ? invocation:systemd-machine-id-commit.service -l?????????? ? ? ? ? ? invocation:systemd-random-seed.service -l?????????? ? ? ? ? ? invocation:systemd-remount-fs.service -l?????????? ? ? ? ? ? invocation:systemd-sysctl.service -l?????????? ? ? ? ? ? invocation:systemd-sysusers.service -l?????????? ? ? ? ? ? invocation:systemd-tmpfiles-setup-dev.service -l?????????? ? ? ? ? ? invocation:systemd-tmpfiles-setup.service -l?????????? ? ? ? ? ? invocation:systemd-udevd.service -l?????????? ? ? ? ? ? invocation:systemd-udev-trigger.service -l?????????? ? ? ? ? ? invocation:systemd-update-done.service -l?????????? ? ? ? ? ? invocation:systemd-update-utmp.service -l?????????? ? ? ? ? ? invocation:systemd-user-sessions.service -l?????????? ? ? ? ? ? invocation:tuned.service -l?????????? ? ? ? ? ? invocation:user@1000.service -l?????????? ? ? ? ? ? invocation:user-runtime-dir@1000.service -l?????????? ? ? ? ? ? invocation:var-lib-nfs-rpc_pipefs.mount - -/run/systemd/users: -total 4 -drwxr-xr-x. 2 0 0 60 Jun 28 09:44 . -drwxr-xr-x. 16 0 0 420 Jun 28 07:38 .. --rw-r--r--. 1 0 0 230 Jun 28 09:44 1000 - -/usr/lib/systemd: -total 10000 -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 . -dr-xr-xr-x. 31 0 0 4096 Apr 4 2019 .. -drwxr-xr-x. 3 0 0 17 Apr 4 2019 boot -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 catalog --rwxr-xr-x. 1 0 0 4652600 Feb 26 2019 libsystemd-shared-239.so -drwxr-xr-x. 2 0 0 29 Apr 4 2019 network -drwxr-xr-x. 2 0 0 29 Apr 4 2019 ntp-units.d -drwxr-xr-x. 3 0 0 21 Apr 4 2019 portable --rwxr-xr-x. 1 0 0 46000 Feb 26 2019 portablectl --rwxr-xr-x. 1 0 0 2351 Feb 26 2019 purge-nobody-user --rw-r--r--. 1 0 0 678 Jun 22 2018 resolv.conf -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 system --rwxr-xr-x. 1 0 0 2336312 Feb 26 2019 systemd --rwxr-xr-x. 1 0 0 13024 Feb 26 2019 systemd-ac-power --rwxr-xr-x. 1 0 0 23200 Feb 26 2019 systemd-backlight --rwxr-xr-x. 1 0 0 17952 Feb 26 2019 systemd-binfmt --rwxr-xr-x. 1 0 0 13264 Feb 26 2019 systemd-cgroups-agent --rwxr-xr-x. 1 0 0 73640 Feb 26 2019 systemd-coredump --rwxr-xr-x. 1 0 0 30840 Feb 26 2019 systemd-cryptsetup --rwxr-xr-x. 1 0 0 17368 Feb 26 2019 systemd-dissect --rwxr-xr-x. 1 0 0 56624 Feb 26 2019 systemd-export --rwxr-xr-x. 1 0 0 26728 Feb 26 2019 systemd-fsck --rwxr-xr-x. 1 0 0 22040 Feb 26 2019 systemd-growfs --rwxr-xr-x. 1 0 0 13264 Feb 26 2019 systemd-hibernate-resume --rwxr-xr-x. 1 0 0 36704 Feb 26 2019 systemd-hostnamed --rwxr-xr-x. 1 0 0 22592 Feb 26 2019 systemd-initctl --rwxr-xr-x. 1 0 0 211568 Feb 26 2019 systemd-journald --rwxr-xr-x. 1 0 0 61992 Feb 26 2019 systemd-localed --rwxr-xr-x. 1 0 0 435880 Feb 26 2019 systemd-logind --rwxr-xr-x. 1 0 0 13824 Feb 26 2019 systemd-makefs --rwxr-xr-x. 1 0 0 23808 Feb 26 2019 systemd-modules-load --rwxr-xr-x. 1 0 0 131592 Feb 26 2019 systemd-portabled --rwxr-xr-x. 1 0 0 13624 Feb 26 2019 systemd-quotacheck --rwxr-xr-x. 1 0 0 17360 Feb 26 2019 systemd-random-seed --rwxr-xr-x. 1 0 0 19176 Feb 26 2019 systemd-remount-fs --rwxr-xr-x. 1 0 0 13264 Feb 26 2019 systemd-reply-password --rwxr-xr-x. 1 0 0 782824 Feb 26 2019 systemd-resolved --rwxr-xr-x. 1 0 0 26736 Feb 26 2019 systemd-rfkill --rwxr-xr-x. 1 0 0 67632 Feb 26 2019 systemd-shutdown --rwxr-xr-x. 1 0 0 23208 Feb 26 2019 systemd-sleep --rwxr-xr-x. 1 0 0 31880 Feb 26 2019 systemd-socket-proxyd --rwxr-xr-x. 1 0 0 13272 Feb 26 2019 systemd-sulogin-shell --rwxr-xr-x. 1 0 0 17952 Feb 26 2019 systemd-sysctl --rwxr-xr-x. 1 0 0 46864 Sep 10 2018 systemd-sysv-install --rwxr-xr-x. 1 0 0 47064 Feb 26 2019 systemd-timedated --rwxr-xr-x. 1 0 0 524608 Feb 26 2019 systemd-udevd --rwxr-xr-x. 1 0 0 13832 Feb 26 2019 systemd-update-done --rwxr-xr-x. 1 0 0 17368 Feb 26 2019 systemd-update-utmp --rwxr-xr-x. 1 0 0 74120 Feb 26 2019 systemd-user-runtime-dir --rwxr-xr-x. 1 0 0 13040 Feb 26 2019 systemd-user-sessions --rwxr-xr-x. 1 0 0 23192 Feb 26 2019 systemd-vconsole-setup --rwxr-xr-x. 1 0 0 13256 Feb 26 2019 systemd-veritysetup --rwxr-xr-x. 1 0 0 13264 Feb 26 2019 systemd-volatile-root -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 system-generators -drwxr-xr-x. 2 0 0 122 Apr 4 2019 system-preset -drwxr-xr-x. 2 0 0 6 Feb 26 2019 system-shutdown -drwxr-xr-x. 2 0 0 6 Feb 26 2019 system-sleep -drwxr-xr-x. 4 0 0 4096 Apr 4 2019 user -drwxr-xr-x. 2 0 0 48 Apr 4 2019 user-environment-generators -drwxr-xr-x. 2 0 0 6 Feb 26 2019 user-generators -drwxr-xr-x. 2 0 0 31 Apr 4 2019 user-preset - -/usr/lib/systemd/boot: -total 4 -drwxr-xr-x. 3 0 0 17 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. -drwxr-xr-x. 2 0 0 58 Apr 4 2019 efi - -/usr/lib/systemd/boot/efi: -total 148 -drwxr-xr-x. 2 0 0 58 Apr 4 2019 . -drwxr-xr-x. 3 0 0 17 Apr 4 2019 .. --rwxr-xr-x. 1 0 0 59770 Feb 26 2019 linuxx64.efi.stub --rwxr-xr-x. 1 0 0 87426 Feb 26 2019 systemd-bootx64.efi - -/usr/lib/systemd/catalog: -total 164 -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 13109 Feb 26 2019 systemd.be.catalog --rw-r--r--. 1 0 0 10118 Feb 26 2019 systemd.be@latin.catalog --rw-r--r--. 1 0 0 14295 Feb 26 2019 systemd.bg.catalog --rw-r--r--. 1 0 0 12454 Feb 26 2019 systemd.catalog --rw-r--r--. 1 0 0 475 Feb 26 2019 systemd.de.catalog --rw-r--r--. 1 0 0 13358 Feb 26 2019 systemd.fr.catalog --rw-r--r--. 1 0 0 11351 Feb 26 2019 systemd.it.catalog --rw-r--r--. 1 0 0 13049 Feb 26 2019 systemd.pl.catalog --rw-r--r--. 1 0 0 8376 Feb 26 2019 systemd.pt_BR.catalog --rw-r--r--. 1 0 0 20471 Feb 26 2019 systemd.ru.catalog --rw-r--r--. 1 0 0 7360 Feb 26 2019 systemd.zh_CN.catalog --rw-r--r--. 1 0 0 7319 Feb 26 2019 systemd.zh_TW.catalog - -/usr/lib/systemd/network: -total 8 -drwxr-xr-x. 2 0 0 29 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 412 Jun 22 2018 99-default.link - -/usr/lib/systemd/ntp-units.d: -total 8 -drwxr-xr-x. 2 0 0 29 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 16 Aug 13 2018 50-chronyd.list - -/usr/lib/systemd/portable: -total 4 -drwxr-xr-x. 3 0 0 21 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. -drwxr-xr-x. 6 0 0 67 Apr 4 2019 profile - -/usr/lib/systemd/portable/profile: -total 0 -drwxr-xr-x. 6 0 0 67 Apr 4 2019 . -drwxr-xr-x. 3 0 0 21 Apr 4 2019 .. -drwxr-xr-x. 2 0 0 26 Apr 4 2019 default -drwxr-xr-x. 2 0 0 26 Apr 4 2019 nonetwork -drwxr-xr-x. 2 0 0 26 Apr 4 2019 strict -drwxr-xr-x. 2 0 0 26 Apr 4 2019 trusted - -/usr/lib/systemd/portable/profile/default: -total 4 -drwxr-xr-x. 2 0 0 26 Apr 4 2019 . -drwxr-xr-x. 6 0 0 67 Apr 4 2019 .. --rw-r--r--. 1 0 0 1101 Jun 22 2018 service.conf - -/usr/lib/systemd/portable/profile/nonetwork: -total 4 -drwxr-xr-x. 2 0 0 26 Apr 4 2019 . -drwxr-xr-x. 6 0 0 67 Apr 4 2019 .. --rw-r--r--. 1 0 0 1038 Jun 22 2018 service.conf - -/usr/lib/systemd/portable/profile/strict: -total 4 -drwxr-xr-x. 2 0 0 26 Apr 4 2019 . -drwxr-xr-x. 6 0 0 67 Apr 4 2019 .. --rw-r--r--. 1 0 0 775 Jun 22 2018 service.conf - -/usr/lib/systemd/portable/profile/trusted: -total 4 -drwxr-xr-x. 2 0 0 26 Apr 4 2019 . -drwxr-xr-x. 6 0 0 67 Apr 4 2019 .. --rw-r--r--. 1 0 0 182 Jun 22 2018 service.conf - -/usr/lib/systemd/system: -total 1044 -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 275 Sep 26 2018 arp-ethers.service --rw-r--r--. 1 0 0 1516 Jan 9 2019 auditd.service --rw-r--r--. 1 0 0 628 Feb 15 2019 auth-rpcgss-module.service --rw-r--r--. 1 0 0 1975 Feb 26 2019 autovt@.service --rw-r--r--. 1 0 0 956 Feb 26 2019 basic.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 basic.target.wants --rw-r--r--. 1 0 0 419 Jun 22 2018 bluetooth.target --rw-r--r--. 1 0 0 209 Aug 13 2018 chrony-dnssrv@.service --rw-r--r--. 1 0 0 138 Aug 13 2018 chrony-dnssrv@.timer --rw-r--r--. 1 0 0 495 Aug 13 2018 chronyd.service --rw-r--r--. 1 0 0 472 Apr 4 2018 chrony-wait.service --rw-r--r--. 1 0 0 491 Jan 23 2019 cloud-config.service --rw-r--r--. 1 0 0 536 Jan 23 2019 cloud-config.target --rw-r--r--. 1 0 0 514 Jan 23 2019 cloud-final.service --rw-r--r--. 1 0 0 878 Jan 23 2019 cloud-init-local.service --rw-r--r--. 1 0 0 648 Jan 23 2019 cloud-init.service --rw-r--r--. 1 0 0 222 Feb 8 2019 cockpit-motd.service --rw-r--r--. 1 0 0 305 Feb 8 2019 cockpit.service --rw-r--r--. 1 0 0 373 Feb 8 2019 cockpit.socket --rw-r--r--. 1 0 0 1082 Feb 26 2019 console-getty.service --rw-r--r--. 1 0 0 1263 Feb 26 2019 container-getty@.service --rw-r--r--. 1 0 0 294 Mar 13 2019 cpupower.service --rw-r--r--. 1 0 0 322 Oct 2 2018 crond.service --rw-r--r--. 1 0 0 465 Jun 22 2018 cryptsetup-pre.target --rw-r--r--. 1 0 0 412 Jun 22 2018 cryptsetup.target --rw-r--r--. 1 0 0 583 Jun 22 2018 ctrl-alt-del.target --rw-r--r--. 1 0 0 1081 Feb 26 2019 dbus-org.freedesktop.hostname1.service --rw-r--r--. 1 0 0 1050 Feb 26 2019 dbus-org.freedesktop.locale1.service --rw-r--r--. 1 0 0 1362 Feb 26 2019 dbus-org.freedesktop.login1.service --rw-r--r--. 1 0 0 987 Feb 26 2019 dbus-org.freedesktop.portable1.service --rw-r--r--. 1 0 0 1021 Feb 26 2019 dbus-org.freedesktop.timedate1.service --rw-r--r--. 1 0 0 380 Oct 24 2018 dbus.service --rw-r--r--. 1 0 0 102 Oct 24 2018 dbus.socket -drwxr-xr-x. 2 0 0 6 Feb 26 2019 dbus.target.wants --rw-r--r--. 1 0 0 1084 Feb 26 2019 debug-shell.service --rw-r--r--. 1 0 0 598 Jun 22 2018 default.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 default.target.wants --rw-r--r--. 1 0 0 750 Jun 22 2018 dev-hugepages.mount --rw-r--r--. 1 0 0 665 Jun 22 2018 dev-mqueue.mount --rw-r--r--. 1 0 0 457 Jan 4 2019 dnf-makecache.service --rw-r--r--. 1 0 0 301 Jan 4 2019 dnf-makecache.timer --rw-r--r--. 1 0 0 904 Oct 8 2018 dracut-cmdline.service --rw-r--r--. 1 0 0 821 Oct 8 2018 dracut-initqueue.service --rw-r--r--. 1 0 0 793 Oct 8 2018 dracut-mount.service --rw-r--r--. 1 0 0 822 Oct 8 2018 dracut-pre-mount.service --rw-r--r--. 1 0 0 1125 Oct 8 2018 dracut-pre-pivot.service --rw-r--r--. 1 0 0 914 Oct 8 2018 dracut-pre-trigger.service --rw-r--r--. 1 0 0 993 Oct 8 2018 dracut-pre-udev.service --rw-r--r--. 1 0 0 459 Oct 8 2018 dracut-shutdown.service --rw-r--r--. 1 0 0 801 Feb 26 2019 emergency.service --rw-r--r--. 1 0 0 471 Jun 22 2018 emergency.target --rw-r--r--. 1 0 0 541 Jun 22 2018 exit.target --rw-r--r--. 1 0 0 480 Jun 22 2018 final.target --rw-r--r--. 1 0 0 96 Dec 11 2018 fstrim.service --rw-r--r--. 1 0 0 170 Dec 11 2018 fstrim.timer --rw-r--r--. 1 0 0 506 Jun 22 2018 getty-pre.target --rw-r--r--. 1 0 0 1975 Feb 26 2019 getty@.service --rw-r--r--. 1 0 0 500 Jun 22 2018 getty.target --rw-r--r--. 1 0 0 598 Jun 22 2018 graphical.target -drwxr-xr-x. 2 0 0 50 Apr 4 2019 graphical.target.wants --rw-r--r--. 1 0 0 263 Dec 19 2018 grub-boot-indeterminate.service --rw-r--r--. 1 0 0 479 Aug 12 2018 gssproxy.service --rw-r--r--. 1 0 0 605 Feb 26 2019 halt-local.service --rw-r--r--. 1 0 0 527 Jun 22 2018 halt.target --rw-r--r--. 1 0 0 509 Jun 22 2018 hibernate.target --rw-r--r--. 1 0 0 530 Jun 22 2018 hybrid-sleep.target --rw-r--r--. 1 0 0 441 Aug 3 2018 import-state.service --rw-r--r--. 1 0 0 674 Feb 26 2019 initrd-cleanup.service --rw-r--r--. 1 0 0 593 Jun 22 2018 initrd-fs.target --rw-r--r--. 1 0 0 842 Feb 26 2019 initrd-parse-etc.service --rw-r--r--. 1 0 0 561 Jun 22 2018 initrd-root-device.target --rw-r--r--. 1 0 0 566 Jun 22 2018 initrd-root-fs.target --rw-r--r--. 1 0 0 593 Feb 26 2019 initrd-switch-root.service --rw-r--r--. 1 0 0 754 Jun 22 2018 initrd-switch-root.target --rw-r--r--. 1 0 0 763 Jun 22 2018 initrd.target -drwxr-xr-x. 2 0 0 225 Apr 4 2019 initrd.target.wants --rw-r--r--. 1 0 0 708 Feb 26 2019 initrd-udevadm-cleanup-db.service --rw-r--r--. 1 0 0 497 Apr 20 2018 insights-client.service --rw-r--r--. 1 0 0 193 Apr 20 2018 insights-client.timer --rw-r--r--. 1 0 0 224 Nov 6 2018 irqbalance.service --rw-r--r--. 1 0 0 349 Feb 22 2019 kdump.service --rw-r--r--. 1 0 0 541 Jun 22 2018 kexec.target --rw-r--r--. 1 0 0 721 Feb 26 2019 kmod-static-nodes.service --rw-r--r--. 1 0 0 687 Jun 22 2018 ldconfig.service --rw-r--r--. 1 0 0 355 Aug 3 2018 loadmodules.service --rw-r--r--. 1 0 0 435 Jun 22 2018 local-fs-pre.target --rw-r--r--. 1 0 0 547 Jun 22 2018 local-fs.target -drwxr-xr-x. 2 0 0 40 Apr 4 2019 local-fs.target.wants --rw-r--r--. 1 0 0 342 Nov 7 2018 man-db-cache-update.service --rw-r--r--. 1 0 0 380 Oct 24 2018 messagebus.service --rw-r--r--. 1 0 0 284 Nov 6 2018 microcode.service --rw-r--r--. 1 0 0 532 Jun 22 2018 multi-user.target -drwxr-xr-x. 2 0 0 195 Apr 4 2019 multi-user.target.wants --rw-r--r--. 1 0 0 353 Feb 8 2019 NetworkManager-dispatcher.service --rw-r--r--. 1 0 0 1341 Feb 8 2019 NetworkManager.service --rw-r--r--. 1 0 0 302 Feb 8 2019 NetworkManager-wait-online.service --rw-r--r--. 1 0 0 505 Jun 22 2018 network-online.target --rw-r--r--. 1 0 0 502 Jun 22 2018 network-pre.target --rw-r--r--. 1 0 0 521 Jun 22 2018 network.target --rw-r--r--. 1 0 0 295 Feb 15 2019 nfs-blkmap.service --rw-r--r--. 1 0 0 413 Feb 15 2019 nfs-client.target --rw-r--r--. 1 0 0 608 Feb 15 2019 nfs-convert.service --rw-r--r--. 1 0 0 222 Feb 15 2019 nfs-idmapd.service --rw-r--r--. 1 0 0 287 Feb 15 2019 nfs-mountd.service --rw-r--r--. 1 0 0 931 Feb 15 2019 nfs-server.service --rw-r--r--. 1 0 0 567 Feb 15 2019 nfs-utils.service --rw-r--r--. 1 0 0 378 Aug 12 2018 nis-domainname.service --rw-r--r--. 1 0 0 554 Jun 22 2018 nss-lookup.target --rw-r--r--. 1 0 0 513 Jun 22 2018 nss-user-lookup.target --rw-r--r--. 1 0 0 394 Jun 22 2018 paths.target --rw-r--r--. 1 0 0 172 Jan 22 2019 polkit.service --rw-r--r--. 1 0 0 592 Jun 22 2018 poweroff.target --rw-r--r--. 1 0 0 417 Jun 22 2018 printer.target --rw-r--r--. 1 0 0 98 Feb 15 2019 proc-fs-nfsd.mount --rw-r--r--. 1 0 0 745 Jun 22 2018 proc-sys-fs-binfmt_misc.automount --rw-r--r--. 1 0 0 655 Jun 22 2018 proc-sys-fs-binfmt_misc.mount --rw-r--r--. 1 0 0 522 Feb 26 2019 qemu-guest-agent.service --rw-r--r--. 1 0 0 617 Feb 26 2019 quotaon.service --rw-r--r--. 1 0 0 736 Feb 26 2019 rc-local.service --rw-r--r--. 1 0 0 208 Aug 12 2018 rdisc.service --rw-r--r--. 1 0 0 583 Jun 22 2018 reboot.target --rw-r--r--. 1 0 0 549 Jun 22 2018 remote-cryptsetup.target --rw-r--r--. 1 0 0 436 Jun 22 2018 remote-fs-pre.target --rw-r--r--. 1 0 0 522 Jun 22 2018 remote-fs.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 remote-fs.target.wants --rw-r--r--. 1 0 0 792 Feb 26 2019 rescue.service --rw-r--r--. 1 0 0 492 Jun 22 2018 rescue.target -drwxr-xr-x. 2 0 0 50 Apr 4 2019 rescue.target.wants --rw-r--r--. 1 0 0 260 Feb 4 2019 rhnsd.service --rw-r--r--. 1 0 0 184 Mar 6 2019 rhsmcertd.service --rw-r--r--. 1 0 0 212 Mar 6 2019 rhsm-facts.service --rw-r--r--. 1 0 0 187 Mar 6 2019 rhsm.service --rw-r--r--. 1 0 0 126 Dec 21 2018 rngd.service --rw-r--r--. 1 0 0 547 Oct 20 2018 rpcbind.service --rw-r--r--. 1 0 0 368 Oct 20 2018 rpcbind.socket --rw-r--r--. 1 0 0 540 Jun 22 2018 rpcbind.target --rw-r--r--. 1 0 0 281 Feb 15 2019 rpc-gssd.service --rw-r--r--. 1 0 0 80 Feb 15 2019 rpc_pipefs.target --rw-r--r--. 1 0 0 387 Feb 15 2019 rpc-statd-notify.service --rw-r--r--. 1 0 0 382 Feb 15 2019 rpc-statd.service --rw-r--r--. 1 0 0 583 Dec 17 2018 rsyslog.service --rw-r--r--. 1 0 0 592 Jun 22 2018 runlevel0.target --rw-r--r--. 1 0 0 492 Jun 22 2018 runlevel1.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 runlevel1.target.wants --rw-r--r--. 1 0 0 532 Jun 22 2018 runlevel2.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 runlevel2.target.wants --rw-r--r--. 1 0 0 532 Jun 22 2018 runlevel3.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 runlevel3.target.wants --rw-r--r--. 1 0 0 532 Jun 22 2018 runlevel4.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 runlevel4.target.wants --rw-r--r--. 1 0 0 598 Jun 22 2018 runlevel5.target -drwxr-xr-x. 2 0 0 6 Feb 26 2019 runlevel5.target.wants --rw-r--r--. 1 0 0 583 Jun 22 2018 runlevel6.target --rw-r--r--. 1 0 0 406 Dec 14 2018 selinux-autorelabel-mark.service --rw-r--r--. 1 0 0 288 Dec 14 2018 selinux-autorelabel.service --rw-r--r--. 1 0 0 230 Dec 14 2018 selinux-autorelabel.target --rw-r--r--. 1 0 0 1486 Feb 26 2019 serial-getty@.service --rw-r--r--. 1 0 0 442 Jun 22 2018 shutdown.target --rw-r--r--. 1 0 0 402 Jun 22 2018 sigpwr.target --rw-r--r--. 1 0 0 460 Jun 22 2018 sleep.target --rw-r--r--. 1 0 0 449 Jun 22 2018 slices.target --rw-r--r--. 1 0 0 420 Jun 22 2018 smartcard.target --rw-r--r--. 1 0 0 396 Jun 22 2018 sockets.target -drwxr-xr-x. 2 0 0 227 Apr 4 2019 sockets.target.wants --rw-r--r--. 1 0 0 420 Jun 22 2018 sound.target --rw-r--r--. 1 0 0 247 Nov 26 2018 sshd-keygen@.service --rw-r--r--. 1 0 0 123 Nov 26 2018 sshd-keygen.target --rw-r--r--. 1 0 0 456 Nov 26 2018 sshd.service --rw-r--r--. 1 0 0 342 Nov 26 2018 sshd@.service --rw-r--r--. 1 0 0 181 Nov 26 2018 sshd.socket --rw-r--r--. 1 0 0 472 Feb 11 2019 sssd-autofs.service --rw-r--r--. 1 0 0 371 Feb 11 2019 sssd-autofs.socket --rw-r--r--. 1 0 0 327 Feb 11 2019 sssd-kcm.service --rw-r--r--. 1 0 0 187 Feb 11 2019 sssd-kcm.socket --rw-r--r--. 1 0 0 351 Feb 11 2019 sssd-nss.service --rw-r--r--. 1 0 0 420 Feb 11 2019 sssd-nss.socket --rw-r--r--. 1 0 0 460 Feb 11 2019 sssd-pac.service --rw-r--r--. 1 0 0 362 Feb 11 2019 sssd-pac.socket --rw-r--r--. 1 0 0 443 Feb 11 2019 sssd-pam-priv.socket --rw-r--r--. 1 0 0 481 Feb 11 2019 sssd-pam.service --rw-r--r--. 1 0 0 391 Feb 11 2019 sssd-pam.socket --rw-r--r--. 1 0 0 420 Feb 11 2019 sssd.service --rw-r--r--. 1 0 0 460 Feb 11 2019 sssd-ssh.service --rw-r--r--. 1 0 0 362 Feb 11 2019 sssd-ssh.socket --rw-r--r--. 1 0 0 465 Feb 11 2019 sssd-sudo.service --rw-r--r--. 1 0 0 364 Feb 11 2019 sssd-sudo.socket --rw-r--r--. 1 0 0 503 Jun 22 2018 suspend.target --rw-r--r--. 1 0 0 577 Jun 22 2018 suspend-then-hibernate.target --rw-r--r--. 1 0 0 393 Jun 22 2018 swap.target --rw-r--r--. 1 0 0 795 Jun 22 2018 sys-fs-fuse-connections.mount --rw-r--r--. 1 0 0 558 Jun 22 2018 sysinit.target -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 sysinit.target.wants --rw-r--r--. 1 0 0 767 Jun 22 2018 sys-kernel-config.mount --rw-r--r--. 1 0 0 710 Jun 22 2018 sys-kernel-debug.mount --rw-r--r--. 1 0 0 1407 Jun 22 2018 syslog.socket -drwxr-xr-x. 2 0 0 6 Feb 26 2019 syslog.target.wants --rw-r--r--. 1 0 0 704 Jun 22 2018 systemd-ask-password-console.path --rw-r--r--. 1 0 0 728 Feb 26 2019 systemd-ask-password-console.service --rw-r--r--. 1 0 0 632 Jun 22 2018 systemd-ask-password-wall.path --rw-r--r--. 1 0 0 760 Feb 26 2019 systemd-ask-password-wall.service --rw-r--r--. 1 0 0 760 Feb 26 2019 systemd-backlight@.service --rw-r--r--. 1 0 0 1093 Feb 26 2019 systemd-binfmt.service --rw-r--r--. 1 0 0 1083 Feb 26 2019 systemd-coredump@.service --rw-r--r--. 1 0 0 537 Jun 22 2018 systemd-coredump.socket --rw-r--r--. 1 0 0 541 Feb 26 2019 systemd-exit.service --rw-r--r--. 1 0 0 799 Feb 26 2019 systemd-firstboot.service --rw-r--r--. 1 0 0 618 Feb 26 2019 systemd-fsck-root.service --rw-r--r--. 1 0 0 671 Feb 26 2019 systemd-fsck@.service --rw-r--r--. 1 0 0 588 Feb 26 2019 systemd-halt.service --rw-r--r--. 1 0 0 675 Feb 26 2019 systemd-hibernate-resume@.service --rw-r--r--. 1 0 0 545 Feb 26 2019 systemd-hibernate.service --rw-r--r--. 1 0 0 1081 Feb 26 2019 systemd-hostnamed.service --rw-r--r--. 1 0 0 826 Feb 26 2019 systemd-hwdb-update.service --rw-r--r--. 1 0 0 563 Feb 26 2019 systemd-hybrid-sleep.service --rw-r--r--. 1 0 0 550 Feb 26 2019 systemd-initctl.service --rw-r--r--. 1 0 0 546 Jun 22 2018 systemd-initctl.socket --rw-r--r--. 1 0 0 711 Feb 26 2019 systemd-journal-catalog-update.service --rw-r--r--. 1 0 0 1130 Jun 22 2018 systemd-journald-dev-log.socket --rw-r--r--. 1 0 0 1486 Feb 26 2019 systemd-journald.service --rw-r--r--. 1 0 0 882 Jun 22 2018 systemd-journald.socket --rw-r--r--. 1 0 0 775 Feb 26 2019 systemd-journal-flush.service --rw-r--r--. 1 0 0 601 Feb 26 2019 systemd-kexec.service --rw-r--r--. 1 0 0 1050 Feb 26 2019 systemd-localed.service --rw-r--r--. 1 0 0 1362 Feb 26 2019 systemd-logind.service --rw-r--r--. 1 0 0 737 Feb 26 2019 systemd-machine-id-commit.service --rw-r--r--. 1 0 0 1011 Feb 26 2019 systemd-modules-load.service --rw-r--r--. 1 0 0 987 Feb 26 2019 systemd-portabled.service --rw-r--r--. 1 0 0 597 Feb 26 2019 systemd-poweroff.service --rw-r--r--. 1 0 0 663 Feb 26 2019 systemd-quotacheck.service --rw-r--r--. 1 0 0 800 Feb 26 2019 systemd-random-seed.service --rw-r--r--. 1 0 0 592 Feb 26 2019 systemd-reboot.service --rw-r--r--. 1 0 0 802 Feb 26 2019 systemd-remount-fs.service --rw-r--r--. 1 0 0 1611 Feb 26 2019 systemd-resolved.service --rw-r--r--. 1 0 0 728 Feb 26 2019 systemd-rfkill.service --rw-r--r--. 1 0 0 657 Jun 22 2018 systemd-rfkill.socket --rw-r--r--. 1 0 0 541 Feb 26 2019 systemd-suspend.service --rw-r--r--. 1 0 0 600 Feb 26 2019 systemd-suspend-then-hibernate.service --rw-r--r--. 1 0 0 697 Feb 26 2019 systemd-sysctl.service --rw-r--r--. 1 0 0 704 Feb 26 2019 systemd-sysusers.service --rw-r--r--. 1 0 0 1021 Feb 26 2019 systemd-timedated.service --rw-r--r--. 1 0 0 663 Feb 26 2019 systemd-tmpfiles-clean.service --rw-r--r--. 1 0 0 490 Jun 22 2018 systemd-tmpfiles-clean.timer --rw-r--r--. 1 0 0 771 Feb 26 2019 systemd-tmpfiles-setup-dev.service --rw-r--r--. 1 0 0 751 Feb 26 2019 systemd-tmpfiles-setup.service --rw-r--r--. 1 0 0 635 Jun 22 2018 systemd-udevd-control.socket --rw-r--r--. 1 0 0 610 Jun 22 2018 systemd-udevd-kernel.socket --rw-r--r--. 1 0 0 1049 Feb 26 2019 systemd-udevd.service --rw-r--r--. 1 0 0 867 Feb 26 2019 systemd-udev-settle.service --rw-r--r--. 1 0 0 771 Feb 26 2019 systemd-udev-trigger.service -drwxr-xr-x. 2 0 0 49 Apr 4 2019 systemd-udev-trigger.service.d --rw-r--r--. 1 0 0 674 Feb 26 2019 systemd-update-done.service --rw-r--r--. 1 0 0 801 Feb 26 2019 systemd-update-utmp-runlevel.service --rw-r--r--. 1 0 0 802 Feb 26 2019 systemd-update-utmp.service --rw-r--r--. 1 0 0 636 Feb 26 2019 systemd-user-sessions.service --rw-r--r--. 1 0 0 622 Feb 26 2019 systemd-vconsole-setup.service --rw-r--r--. 1 0 0 694 Feb 26 2019 systemd-volatile-root.service --rw-r--r--. 1 0 0 1415 Jun 22 2018 system-update-cleanup.service --rw-r--r--. 1 0 0 543 Jun 22 2018 system-update-pre.target --rw-r--r--. 1 0 0 617 Jun 22 2018 system-update.target -drwxr-xr-x. 2 0 0 45 Apr 4 2019 system-update.target.wants --rw-r--r--. 1 0 0 128 Aug 12 2018 tcsd.service --rw-r--r--. 1 0 0 244 Mar 17 2017 teamd@.service --rw-r--r--. 1 0 0 238 Nov 7 2017 timedatex.service --rw-r--r--. 1 0 0 445 Jun 22 2018 timers.target -drwxr-xr-x. 2 0 0 42 Apr 4 2019 timers.target.wants --rw-r--r--. 1 0 0 435 Jun 22 2018 time-sync.target --rw-r--r--. 1 0 0 704 Jun 22 2018 tmp.mount --rw-r--r--. 1 0 0 376 Jul 4 2018 tuned.service --rw-r--r--. 1 0 0 457 Jun 22 2018 umount.target --rw-r--r--. 1 0 0 296 Aug 12 2018 unbound-anchor.service --rw-r--r--. 1 0 0 346 Aug 12 2018 unbound-anchor.timer --rw-r--r--. 1 0 0 551 Feb 26 2019 user-runtime-dir@.service --rw-r--r--. 1 0 0 671 Feb 26 2019 user@.service --rw-r--r--. 1 0 0 432 Jun 22 2018 user.slice -drwxr-xr-x. 2 0 0 30 Apr 4 2019 user-.slice.d --rw-r--r--. 1 0 0 191 Feb 15 2019 var-lib-nfs-rpc_pipefs.mount - -/usr/lib/systemd/system/basic.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/dbus.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/default.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/graphical.target.wants: -total 20 -drwxr-xr-x. 2 0 0 50 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 801 Feb 26 2019 systemd-update-utmp-runlevel.service - -/usr/lib/systemd/system/initrd.target.wants: -total 44 -drwxr-xr-x. 2 0 0 225 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 904 Oct 8 2018 dracut-cmdline.service --rw-r--r--. 1 0 0 821 Oct 8 2018 dracut-initqueue.service --rw-r--r--. 1 0 0 793 Oct 8 2018 dracut-mount.service --rw-r--r--. 1 0 0 822 Oct 8 2018 dracut-pre-mount.service --rw-r--r--. 1 0 0 1125 Oct 8 2018 dracut-pre-pivot.service --rw-r--r--. 1 0 0 914 Oct 8 2018 dracut-pre-trigger.service --rw-r--r--. 1 0 0 993 Oct 8 2018 dracut-pre-udev.service - -/usr/lib/systemd/system/local-fs.target.wants: -total 20 -drwxr-xr-x. 2 0 0 40 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 802 Feb 26 2019 systemd-remount-fs.service - -/usr/lib/systemd/system/multi-user.target.wants: -total 40 -drwxr-xr-x. 2 0 0 195 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 380 Oct 24 2018 dbus.service --rw-r--r--. 1 0 0 500 Jun 22 2018 getty.target --rw-r--r--. 1 0 0 632 Jun 22 2018 systemd-ask-password-wall.path --rw-r--r--. 1 0 0 1362 Feb 26 2019 systemd-logind.service --rw-r--r--. 1 0 0 801 Feb 26 2019 systemd-update-utmp-runlevel.service --rw-r--r--. 1 0 0 636 Feb 26 2019 systemd-user-sessions.service - -/usr/lib/systemd/system/remote-fs.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/rescue.target.wants: -total 20 -drwxr-xr-x. 2 0 0 50 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 801 Feb 26 2019 systemd-update-utmp-runlevel.service - -/usr/lib/systemd/system/runlevel1.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/runlevel2.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/runlevel3.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/runlevel4.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/runlevel5.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/sockets.target.wants: -total 44 -drwxr-xr-x. 2 0 0 227 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 102 Oct 24 2018 dbus.socket --rw-r--r--. 1 0 0 537 Jun 22 2018 systemd-coredump.socket --rw-r--r--. 1 0 0 546 Jun 22 2018 systemd-initctl.socket --rw-r--r--. 1 0 0 1130 Jun 22 2018 systemd-journald-dev-log.socket --rw-r--r--. 1 0 0 882 Jun 22 2018 systemd-journald.socket --rw-r--r--. 1 0 0 635 Jun 22 2018 systemd-udevd-control.socket --rw-r--r--. 1 0 0 610 Jun 22 2018 systemd-udevd-kernel.socket - -/usr/lib/systemd/system/sysinit.target.wants: -total 132 -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 412 Jun 22 2018 cryptsetup.target --rw-r--r--. 1 0 0 750 Jun 22 2018 dev-hugepages.mount --rw-r--r--. 1 0 0 665 Jun 22 2018 dev-mqueue.mount --rw-r--r--. 1 0 0 459 Oct 8 2018 dracut-shutdown.service --rw-r--r--. 1 0 0 721 Feb 26 2019 kmod-static-nodes.service --rw-r--r--. 1 0 0 687 Jun 22 2018 ldconfig.service --rw-r--r--. 1 0 0 745 Jun 22 2018 proc-sys-fs-binfmt_misc.automount --rw-r--r--. 1 0 0 795 Jun 22 2018 sys-fs-fuse-connections.mount --rw-r--r--. 1 0 0 767 Jun 22 2018 sys-kernel-config.mount --rw-r--r--. 1 0 0 710 Jun 22 2018 sys-kernel-debug.mount --rw-r--r--. 1 0 0 704 Jun 22 2018 systemd-ask-password-console.path --rw-r--r--. 1 0 0 1093 Feb 26 2019 systemd-binfmt.service --rw-r--r--. 1 0 0 799 Feb 26 2019 systemd-firstboot.service --rw-r--r--. 1 0 0 826 Feb 26 2019 systemd-hwdb-update.service --rw-r--r--. 1 0 0 711 Feb 26 2019 systemd-journal-catalog-update.service --rw-r--r--. 1 0 0 1486 Feb 26 2019 systemd-journald.service --rw-r--r--. 1 0 0 775 Feb 26 2019 systemd-journal-flush.service --rw-r--r--. 1 0 0 737 Feb 26 2019 systemd-machine-id-commit.service --rw-r--r--. 1 0 0 1011 Feb 26 2019 systemd-modules-load.service --rw-r--r--. 1 0 0 800 Feb 26 2019 systemd-random-seed.service --rw-r--r--. 1 0 0 697 Feb 26 2019 systemd-sysctl.service --rw-r--r--. 1 0 0 704 Feb 26 2019 systemd-sysusers.service --rw-r--r--. 1 0 0 771 Feb 26 2019 systemd-tmpfiles-setup-dev.service --rw-r--r--. 1 0 0 751 Feb 26 2019 systemd-tmpfiles-setup.service --rw-r--r--. 1 0 0 1049 Feb 26 2019 systemd-udevd.service --rw-r--r--. 1 0 0 771 Feb 26 2019 systemd-udev-trigger.service --rw-r--r--. 1 0 0 674 Feb 26 2019 systemd-update-done.service --rw-r--r--. 1 0 0 802 Feb 26 2019 systemd-update-utmp.service - -/usr/lib/systemd/system/syslog.target.wants: -total 16 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. - -/usr/lib/systemd/system/systemd-udev-trigger.service.d: -total 20 -drwxr-xr-x. 2 0 0 49 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 87 Feb 26 2019 systemd-udev-trigger-no-reload.conf - -/usr/lib/systemd/system/system-update.target.wants: -total 20 -drwxr-xr-x. 2 0 0 45 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 263 Dec 19 2018 grub-boot-indeterminate.service - -/usr/lib/systemd/system/timers.target.wants: -total 20 -drwxr-xr-x. 2 0 0 42 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 490 Jun 22 2018 systemd-tmpfiles-clean.timer - -/usr/lib/systemd/system/user-.slice.d: -total 20 -drwxr-xr-x. 2 0 0 30 Apr 4 2019 . -drwxr-xr-x. 23 0 0 12288 Apr 4 2019 .. --rw-r--r--. 1 0 0 430 Feb 26 2019 10-defaults.conf - -/usr/lib/systemd/system-generators: -total 396 -drwxr-xr-x. 2 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rwxr-xr-x. 1 0 0 504 Feb 22 2019 kdump-dep-generator.sh --rwxr-xr-x. 1 0 0 72424 Feb 15 2019 nfs-server-generator --rwxr-xr-x. 1 0 0 39920 Feb 15 2019 rpc-pipefs-generator --rwxr-xr-x. 1 0 0 743 Dec 14 2018 selinux-autorelabel-generator.sh --rwxr-xr-x. 1 0 0 32008 Feb 26 2019 systemd-cryptsetup-generator --rwxr-xr-x. 1 0 0 17944 Feb 26 2019 systemd-debug-generator --rwxr-xr-x. 1 0 0 51216 Feb 26 2019 systemd-fstab-generator --rwxr-xr-x. 1 0 0 19104 Feb 26 2019 systemd-getty-generator --rwxr-xr-x. 1 0 0 33168 Feb 26 2019 systemd-gpt-auto-generator --rwxr-xr-x. 1 0 0 13864 Feb 26 2019 systemd-hibernate-resume-generator --rwxr-xr-x. 1 0 0 13712 Feb 26 2019 systemd-rc-local-generator --rwxr-xr-x. 1 0 0 14304 Feb 26 2019 systemd-system-update-generator --rwxr-xr-x. 1 0 0 38408 Feb 26 2019 systemd-sysv-generator --rwxr-xr-x. 1 0 0 18560 Feb 26 2019 systemd-veritysetup-generator - -/usr/lib/systemd/system-preset: -total 20 -drwxr-xr-x. 2 0 0 122 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 264 Mar 5 2019 85-display-manager.preset --rw-r--r--. 1 0 0 3982 Mar 5 2019 90-default.preset --rw-r--r--. 1 0 0 951 Jun 22 2018 90-systemd.preset --rw-r--r--. 1 0 0 10 Mar 5 2019 99-default-disable.preset - -/usr/lib/systemd/system-shutdown: -total 4 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. - -/usr/lib/systemd/system-sleep: -total 4 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. - -/usr/lib/systemd/user: -total 96 -drwxr-xr-x. 4 0 0 4096 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 497 Jun 22 2018 basic.target --rw-r--r--. 1 0 0 419 Jun 22 2018 bluetooth.target --rw-r--r--. 1 0 0 360 Oct 24 2018 dbus.service --rw-r--r--. 1 0 0 178 Oct 24 2018 dbus.socket --rw-r--r--. 1 0 0 454 Jun 22 2018 default.target --rw-r--r--. 1 0 0 502 Jun 22 2018 exit.target --rw-r--r--. 1 0 0 147 Dec 3 2018 glib-pacrunner.service --rw-r--r--. 1 0 0 568 Jun 22 2018 graphical-session-pre.target --rw-r--r--. 1 0 0 484 Jun 22 2018 graphical-session.target --rw-r--r--. 1 0 0 119 Dec 19 2018 grub-boot-success.service --rw-r--r--. 1 0 0 133 Dec 19 2018 grub-boot-success.timer --rw-r--r--. 1 0 0 394 Jun 22 2018 paths.target --rw-r--r--. 1 0 0 417 Jun 22 2018 printer.target --rw-r--r--. 1 0 0 442 Jun 22 2018 shutdown.target --rw-r--r--. 1 0 0 420 Jun 22 2018 smartcard.target --rw-r--r--. 1 0 0 396 Jun 22 2018 sockets.target -drwxr-xr-x. 2 0 0 25 Apr 4 2019 sockets.target.wants --rw-r--r--. 1 0 0 420 Jun 22 2018 sound.target --rw-r--r--. 1 0 0 548 Feb 26 2019 systemd-exit.service --rw-r--r--. 1 0 0 661 Feb 26 2019 systemd-tmpfiles-clean.service --rw-r--r--. 1 0 0 533 Jun 22 2018 systemd-tmpfiles-clean.timer --rw-r--r--. 1 0 0 724 Feb 26 2019 systemd-tmpfiles-setup.service --rw-r--r--. 1 0 0 445 Jun 22 2018 timers.target -drwxr-xr-x. 2 0 0 37 Apr 4 2019 timers.target.wants - -/usr/lib/systemd/user/sockets.target.wants: -total 8 -drwxr-xr-x. 2 0 0 25 Apr 4 2019 . -drwxr-xr-x. 4 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 178 Oct 24 2018 dbus.socket - -/usr/lib/systemd/user/timers.target.wants: -total 8 -drwxr-xr-x. 2 0 0 37 Apr 4 2019 . -drwxr-xr-x. 4 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 133 Dec 19 2018 grub-boot-success.timer - -/usr/lib/systemd/user-environment-generators: -total 20 -drwxr-xr-x. 2 0 0 48 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rwxr-xr-x. 1 0 0 13280 Feb 26 2019 30-systemd-environment-d-generator - -/usr/lib/systemd/user-generators: -total 4 -drwxr-xr-x. 2 0 0 6 Feb 26 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. - -/usr/lib/systemd/user-preset: -total 8 -drwxr-xr-x. 2 0 0 31 Apr 4 2019 . -drwxr-xr-x. 16 0 0 4096 Apr 4 2019 .. --rw-r--r--. 1 0 0 513 Jun 22 2018 90-systemd.preset -""".strip() - - -def test_ls_systemd_units(): - systemd = LsSystemdUnits(context_wrap(LS_OUTPUT_FULL)) - assert systemd - assert len(systemd.listings) == 78 - assert systemd.dirs_of("/etc/systemd/system") == [ - '.', - '..', - 'basic.target.wants', - 'getty.target.wants', - 'multi-user.target.wants', - 'network-online.target.wants', - 'nfs-blkmap.service.requires', - 'nfs-idmapd.service.requires', - 'nfs-mountd.service.requires', - 'nfs-server.service.requires', - 'remote-fs.target.wants', - 'rpc-gssd.service.requires', - 'rpc-statd-notify.service.requires', - 'rpc-statd.service.requires', - 'sockets.target.wants', - 'sysinit.target.wants', - 'timers.target.wants' - ] - assert systemd.files_of("/etc/systemd/system") == [ - 'dbus-org.freedesktop.NetworkManager.service', - 'dbus-org.freedesktop.nm-dispatcher.service', - 'dbus-org.freedesktop.timedate1.service', - 'default.target', - 'syslog.service' - ] - assert systemd.specials_of("/etc/systemd/system") == [ - 'systemd-timedated.service' - ] - assert systemd.listing_of("/etc/systemd/system")["syslog.service"] == { - 'date': 'Dec 17 2018', - 'dir': '/etc/systemd/system', - 'group': '0', - 'links': 1, - 'name': 'syslog.service', - 'owner': '0', - 'perms': 'rw-r--r--.', - 'raw_entry': '-rw-r--r--. 1 0 0 583 Dec 17 2018 syslog.service', - 'size': 583, - 'type': '-' - } - - -def test_doc_examples(): - env = { - "ls_systemd_units": LsSystemdUnits(context_wrap(LS_OUTPUT_FULL)) - } - failed, total = doctest.testmod(ls_systemd_units, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_tmp.py b/insights/tests/parsers/test_ls_tmp.py deleted file mode 100644 index 7cd55d9bc4..0000000000 --- a/insights/tests/parsers/test_ls_tmp.py +++ /dev/null @@ -1,48 +0,0 @@ -import doctest -from insights.parsers import ls_tmp -from insights.parsers.ls_tmp import LsTmp -from insights.tests import context_wrap - -LS_TMP = """ -drwxrwxr-x. 2 whuser whuser 216 Jul 9 07:09 aws_sos --rw-r--r--. 1 rauser rauser 1123 Jul 10 00:00 clean-old-archive.log --rw-rw-r--. 1 whuser whuser 9620 Jul 9 07:09 daily-extraction-warehouse-run.log --rw-rw-r--. 1 whuser whuser 11214 Jul 9 07:09 dask_master.log --rw-rw-r--. 1 whuser whuser 27091 Jul 9 07:09 dask_worker.log --rw-r--r--. 1 user10 user10 29 Jul 10 00:00 date.out --rw-r--r--. 1 rauser rauser 325933528 Jul 10 00:18 delete-bad-pods.log --rw-rw-r--. 1 whuser whuser 0 Jul 9 07:08 extraction_driver.log -drwxrwxrwt. 2 root root 6 Mar 27 2017 .font-unix -drwxrwxr-x. 3 user1 user1 17 Oct 28 2019 hadoop-user1 -drwxr-xr-x. 2 user1 user1 32 Jul 4 18:29 hsperfdata_user1 -drwxr-xr-x. 2 rauser rauser 6 Jul 10 00:00 hsperfdata_rauser -drwxr-xr-x. 2 root root 6 Jul 1 14:53 hsperfdata_root -drwxrwxrwt. 2 root root 6 Mar 27 2017 .ICE-unix -srw-rw----. 1 user10 user10 0 Jan 6 2020 lh_pair -srw-rw----. 1 user10 user10 0 Jan 28 11:24 lh_pair_ex -""" - -path = 'insights_commands/ls_-la_.tmp' - - -def test_ls_tmp(): - ls_tmp = LsTmp(context_wrap(LS_TMP, path=path)) - assert len(ls_tmp.listing_of("/tmp")) == 16 - assert len(ls_tmp.dirs_of("/tmp")) == 7 - assert len(ls_tmp.files_of("/tmp")) == 9 - expected = sorted( - [ - 'clean-old-archive.log', 'daily-extraction-warehouse-run.log', - 'dask_master.log', 'dask_worker.log', 'date.out', - 'delete-bad-pods.log', 'extraction_driver.log', 'lh_pair', - 'lh_pair_ex' - ] - ) - actual = ls_tmp.listings.get("/tmp")['files'] - assert actual == expected - - -def test_doc_examples(): - env = {'ls_tmp': LsTmp(context_wrap(LS_TMP, path=path))} - failed, total = doctest.testmod(ls_tmp, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_usr_bin.py b/insights/tests/parsers/test_ls_usr_bin.py deleted file mode 100644 index 565bf733be..0000000000 --- a/insights/tests/parsers/test_ls_usr_bin.py +++ /dev/null @@ -1,52 +0,0 @@ -import doctest - -from collections import defaultdict - -from insights.core import filters -from insights.parsers import ls_usr_bin -from insights.parsers.ls_usr_bin import LsUsrBin -from insights.specs import Specs -from insights.tests import context_wrap - -LS_USR_BIN = """ -total 41472 -lrwxrwxrwx. 1 0 0 7 Oct 22 2019 python -> python2 --rwxr-xr-x. 1 0 0 2558 Apr 10 2019 python-argcomplete-check-easy-install-script --rwxr-xr-x. 1 0 0 318 Apr 10 2019 python-argcomplete-tcsh -lrwxrwxrwx. 1 0 0 14 Oct 22 2019 python-config -> python2-config -lrwxrwxrwx. 1 0 0 9 Oct 22 2019 python2 -> python2.7 -""" - - -def teardown_function(func): - filters._CACHE = {} - filters.FILTERS = defaultdict(set) - - -def test_ls_usr_bin(): - ls_usr_bin = LsUsrBin(context_wrap(LS_USR_BIN, path='insights_commands/ls_-ln_.usr.bin')) - assert ls_usr_bin.files_of('/usr/bin') == ['python', 'python-argcomplete-check-easy-install-script', 'python-argcomplete-tcsh', 'python-config', 'python2'] - python = ls_usr_bin.dir_entry('/usr/bin', 'python') - assert python is not None - assert python == {'date': 'Oct 22 2019', - 'dir': '/usr/bin', - 'group': '0', - 'link': 'python2', - 'links': 1, - 'name': 'python', - 'owner': '0', - 'perms': 'rwxrwxrwx.', - 'raw_entry': 'lrwxrwxrwx. 1 0 0 7 Oct 22 2019 python -> python2', - 'size': 7, - 'type': 'l'} - - -def test_ls_usr_bin_doc_examples(): - env = { - 'Specs': Specs, - 'add_filter': filters.add_filter, - 'LsUsrBin': LsUsrBin, - 'ls_usr_bin': LsUsrBin(context_wrap(LS_USR_BIN, path='insights_commands/ls_-ln_.usr.bin')), - } - failed, total = doctest.testmod(ls_usr_bin, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_usr_lib64.py b/insights/tests/parsers/test_ls_usr_lib64.py deleted file mode 100644 index 0a4267ecde..0000000000 --- a/insights/tests/parsers/test_ls_usr_lib64.py +++ /dev/null @@ -1,42 +0,0 @@ -import doctest -from insights.parsers import ls_usr_lib64 -from insights.parsers.ls_usr_lib64 import LsUsrLib64 -from insights.tests import context_wrap - -LS_USR_LIB64 = """ -total 447460 -dr-xr-xr-x. 150 0 0 77824 Jul 30 16:39 . -drwxr-xr-x. 13 0 0 4096 Apr 30 2017 .. -drwxr-xr-x. 3 0 0 20 Nov 3 2016 krb5 --rwxr-xr-x. 1 0 0 155464 Oct 28 2016 ld-2.17.so -drwxr-xr-x. 3 0 0 20 Jun 10 2016 ldb -lrwxrwxrwx. 1 0 0 10 Apr 30 2017 ld-linux-x86-64.so.2 -> ld-2.17.so -lrwxrwxrwx. 1 0 0 21 Apr 30 2017 libabrt_dbus.so.0 -> libabrt_dbus.so.0.0.1 -""" - - -def test_ls_usr_lib64(): - ls_usr_lib64 = LsUsrLib64(context_wrap(LS_USR_LIB64, path='insights_commands/ls_-lan_.usr.lib64')) - assert len(ls_usr_lib64.dirs_of('/usr/lib64')) == 4 - ret = ls_usr_lib64.dir_entry('/usr/lib64', 'libabrt_dbus.so.0') - assert ret == { - 'type': 'l', - 'perms': 'rwxrwxrwx.', - 'links': 1, - 'owner': '0', - 'group': '0', - 'size': 21, - 'date': 'Apr 30 2017', - 'name': 'libabrt_dbus.so.0', - 'link': 'libabrt_dbus.so.0.0.1', - 'raw_entry': 'lrwxrwxrwx. 1 0 0 21 Apr 30 2017 libabrt_dbus.so.0 -> libabrt_dbus.so.0.0.1', - 'dir': '/usr/lib64' - } - - -def test_ls_usr_lib64_doc_examples(): - env = { - 'ls_usr_lib64': LsUsrLib64(context_wrap(LS_USR_LIB64, path='insights_commands/ls_-lan_.usr.lib64')), - } - failed, total = doctest.testmod(ls_usr_lib64, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_usr_sbin.py b/insights/tests/parsers/test_ls_usr_sbin.py deleted file mode 100644 index 4aa2923fb3..0000000000 --- a/insights/tests/parsers/test_ls_usr_sbin.py +++ /dev/null @@ -1,52 +0,0 @@ -import doctest - -from collections import defaultdict - -from insights.core import filters -from insights.parsers import ls_usr_sbin -from insights.parsers.ls_usr_sbin import LsUsrSbin -from insights.specs import Specs -from insights.tests import context_wrap - -LS_USR_SBIN = """ -total 41472 --rwxr-xr-x. 1 0 0 11720 Mar 18 2014 accessdb --rwxr-xr-x. 1 0 0 3126 Oct 4 2013 addgnupghome --rwxr-xr-x. 1 0 0 20112 Jun 1 2017 addpart --rwxr-xr-x. 1 0 0 371912 Jan 27 2014 postconf --rwxr-sr-x. 1 0 90 218552 Jan 27 2014 postdrop -""" - - -def teardown_function(func): - filters._CACHE = {} - filters.FILTERS = defaultdict(set) - - -def test_ls_usr_sbin(): - ls_usr_sbin = LsUsrSbin(context_wrap(LS_USR_SBIN, path='insights_commands/ls_-ln_.usr.sbin')) - assert ls_usr_sbin.files_of('/usr/sbin') == ['accessdb', 'addgnupghome', 'addpart', 'postconf', 'postdrop'] - postdrop = ls_usr_sbin.dir_entry('/usr/sbin', 'postdrop') - assert postdrop is not None - assert postdrop == { - 'group': '90', - 'name': 'postdrop', - 'links': 1, - 'perms': 'rwxr-sr-x.', - 'raw_entry': '-rwxr-sr-x. 1 0 90 218552 Jan 27 2014 postdrop', - 'owner': '0', - 'date': 'Jan 27 2014', - 'type': '-', - 'size': 218552, - 'dir': '/usr/sbin'} - - -def test_ls_usr_sbin_doc_examples(): - env = { - 'Specs': Specs, - 'add_filter': filters.add_filter, - 'LsUsrSbin': LsUsrSbin, - 'ls_usr_sbin': LsUsrSbin(context_wrap(LS_USR_SBIN, path='insights_commands/ls_-ln_.usr.sbin')), - } - failed, total = doctest.testmod(ls_usr_sbin, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_cache_pulp.py b/insights/tests/parsers/test_ls_var_cache_pulp.py deleted file mode 100644 index fadaa7463b..0000000000 --- a/insights/tests/parsers/test_ls_var_cache_pulp.py +++ /dev/null @@ -1,31 +0,0 @@ -import doctest - -from insights.parsers import ls_var_cache_pulp -from insights.parsers.ls_var_cache_pulp import LsVarCachePulp -from insights.tests import context_wrap - -LS_VAR_CACHE_PULP = """ -total 0 -drwxrwxr-x. 5 48 1000 216 Jan 21 12:56 . -drwxr-xr-x. 10 0 0 121 Jan 20 13:57 .. -lrwxrwxrwx. 1 0 0 19 Jan 21 12:56 cache -> /var/lib/pulp/cache -drwxr-xr-x. 2 48 48 6 Jan 21 13:03 reserved_resource_worker-0@dhcp130-202.gsslab.pnq2.redhat.com -drwxr-xr-x. 2 48 48 6 Jan 21 02:03 reserved_resource_worker-1@dhcp130-202.gsslab.pnq2.redhat.com -drwxr-xr-x. 2 48 48 6 Jan 20 14:03 resource_manager@dhcp130-202.gsslab.pnq2.redhat.com -""" - - -def test_ls_var_cache_pulp(): - ls_var_cache_pulp = LsVarCachePulp(context_wrap(LS_VAR_CACHE_PULP, path="insights_commands/ls_-lan_.var.cache.pulp")) - assert ls_var_cache_pulp.files_of('/var/cache/pulp') == ['cache'] - cache_item = ls_var_cache_pulp.dir_entry('/var/cache/pulp', 'cache') - assert cache_item is not None - assert '/var/lib/pulp/' in cache_item['link'] - - -def test_ls_var_lib_mongodb_doc_examples(): - env = { - 'ls_var_cache_pulp': LsVarCachePulp(context_wrap(LS_VAR_CACHE_PULP, path="insights_commands/ls_-lan_.var.cache.pulp")), - } - failed, total = doctest.testmod(ls_var_cache_pulp, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_lib_mongodb.py b/insights/tests/parsers/test_ls_var_lib_mongodb.py deleted file mode 100644 index 1400fb7a95..0000000000 --- a/insights/tests/parsers/test_ls_var_lib_mongodb.py +++ /dev/null @@ -1,31 +0,0 @@ -import doctest - -from insights.parsers import ls_var_lib_mongodb -from insights.parsers.ls_var_lib_mongodb import LsVarLibMongodb -from insights.tests import context_wrap - -LS_VAR_LIB_MONGODB = """ -total 6322200 -drwxr-xr-x. 3 mongodb mongodb 256 Jun 7 10:07 . -drwxr-xr-x. 71 root root 4096 Jun 22 10:35 .. -drwxr-xr-x. 2 mongodb mongodb 65 Jul 10 09:33 journal --rw-------. 1 mongodb mongodb 67108864 Jul 10 09:32 local.0 --rw-------. 1 mongodb mongodb 16777216 Jul 10 09:32 local.ns -""" - - -def test_ls_var_lib_mongodb(): - ls_var_lib_mongodb = LsVarLibMongodb(context_wrap(LS_VAR_LIB_MONGODB, path="insights_commands/ls_-la_.var.lib.mongodb")) - assert ls_var_lib_mongodb.dirs_of('/var/lib/mongodb') == ['.', '..', 'journal'] - journal = ls_var_lib_mongodb.dir_entry('/var/lib/mongodb', 'journal') - assert journal is not None - assert journal == {'group': 'mongodb', 'name': 'journal', 'links': 2, 'perms': 'rwxr-xr-x.', 'raw_entry': 'drwxr-xr-x. 2 mongodb mongodb 65 Jul 10 09:33 journal', 'owner': 'mongodb', 'date': 'Jul 10 09:33', 'type': 'd', 'dir': '/var/lib/mongodb', 'size': 65} - - -def test_ls_var_lib_mongodb_doc_examples(): - env = { - 'LsVarLibMongodb': LsVarLibMongodb, - 'ls_var_lib_mongodb': LsVarLibMongodb(context_wrap(LS_VAR_LIB_MONGODB, path="insights_commands/ls_-la_.var.lib.mongodb")), - } - failed, total = doctest.testmod(ls_var_lib_mongodb, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_lib_nova_instances.py b/insights/tests/parsers/test_ls_var_lib_nova_instances.py deleted file mode 100644 index f870fcd27f..0000000000 --- a/insights/tests/parsers/test_ls_var_lib_nova_instances.py +++ /dev/null @@ -1,87 +0,0 @@ -import doctest -from insights.parsers import ls_var_lib_nova_instances as ls_instances -from insights.tests import context_wrap - - -LS_VAR_LIB_NOVA_INSTANCES = ''' -/var/lib/nova/instances/: -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 11415c6c-a2a5-45f0-a198-724246b96631 -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 _base --rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 compute_nodes -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 locks - -/var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631: -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. --rw-------. root root system_u:object_r:nova_var_lib_t:s0 console.log --rw-r--r--. qemu qemu system_u:object_r:svirt_image_t:s0:c92,c808 disk --rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 disk.info - -/var/lib/nova/instances/_base: -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. --rw-r--r--. qemu qemu system_u:object_r:virt_content_t:s0 572dfdb7e1d9304342cbe1fd5e3da4ff2e55c7a6 - -/var/lib/nova/instances/locks: -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 . -drwxr-xr-x. nova nova system_u:object_r:nova_var_lib_t:s0 .. --rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-572dfdb7e1d9304342cbe1fd5e3da4ff2e55c7a6 --rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-storage-registry-lock -'''.strip() - - -LS_R_VAR_LIB_NOVA_INSTANCES = ''' -/var/lib/nova/instances: -total 4 -drwxr-xr-x. 5 nova nova 97 Feb 20 2017 . -drwxr-xr-x. 9 nova nova 111 Feb 17 2017 .. -drwxr-xr-x. 2 nova nova 54 Feb 17 2017 _base --rw-r--r--. 1 nova nova 44 May 26 2017 compute_nodes -drwxr-xr-x. 2 nova nova 54 Feb 17 2017 e560e649-41fd-46a2-a3d2-5f4750ba2bb4 -drwxr-xr-x. 2 nova nova 93 Feb 17 2017 locks - -/var/lib/nova/instances/_base: -total 18176 -drwxr-xr-x. 2 nova nova 54 Feb 17 2017 . -drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. --rw-r--r--. 1 qemu qemu 41126400 May 26 2017 faf1184c098da91e90290a920b8fab1ee6e1d4c4 - -/var/lib/nova/instances/e560e649-41fd-46a2-a3d2-5f4750ba2bb4: -total 2104 -drwxr-xr-x. 2 nova nova 54 Feb 17 2017 . -drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. --rw-r--r--. 1 qemu qemu 48957 Feb 20 2017 console.log --rw-r--r--. 1 qemu qemu 2097152 Feb 20 2017 disk --rw-r--r--. 1 nova nova 79 Feb 17 2017 disk.info - -/var/lib/nova/instances/locks: -total 0 -drwxr-xr-x. 2 nova nova 93 Feb 17 2017 . -drwxr-xr-x. 5 nova nova 97 Feb 20 2017 .. --rw-r--r--. 1 nova nova 0 Feb 17 2017 nova-faf1184c098da91e90290a920b8fab1ee6e1d4c4 --rw-r--r--. 1 nova nova 0 Feb 17 2017 nova-storage-registry-lock -'''.strip() - - -def test_ls_var_lib_nova_instances(): - ls_var_lib_nova_instances = ls_instances.LsVarLibNovaInstances(context_wrap(LS_VAR_LIB_NOVA_INSTANCES)) - assert ls_var_lib_nova_instances.dirs_of('/var/lib/nova/instances/') == ['.', '..', '11415c6c-a2a5-45f0-a198-724246b96631', '_base', 'locks'] - assert ls_var_lib_nova_instances.listings['/var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631']['entries']['console.log']['se_type'] == 'nova_var_lib_t' - assert ls_var_lib_nova_instances.dir_entry('/var/lib/nova/instances/locks', 'nova-storage-registry-lock') == {'se_type': 'nova_var_lib_t', 'name': 'nova-storage-registry-lock', 'perms': 'rw-r--r--.', 'se_user': 'system_u', 'raw_entry': '-rw-r--r--. nova nova system_u:object_r:nova_var_lib_t:s0 nova-storage-registry-lock', 'se_mls': 's0', 'se_role': 'object_r', 'owner': 'nova', 'group': 'nova', 'type': '-', 'dir': '/var/lib/nova/instances/locks'} - assert ls_var_lib_nova_instances.dir_entry('/var/lib/nova/instances/11415c6c-a2a5-45f0-a198-724246b96631', 'console.log')['owner'] == 'root' - - -def test_ls_r_var_lib_nova_instances(): - ls_r_instances = ls_instances.LsRVarLibNovaInstances(context_wrap(LS_R_VAR_LIB_NOVA_INSTANCES)) - assert ls_r_instances.dir_entry('/var/lib/nova/instances/e560e649-41fd-46a2-a3d2-5f4750ba2bb4', 'console.log')['size'] == 48957 - - -def test_ls_var_lib_nova_instances_doc_examples(): - failed, total = doctest.testmod( - ls_instances, - globs={'ls_var_lib_nova_instances': ls_instances.LsVarLibNovaInstances(context_wrap(LS_VAR_LIB_NOVA_INSTANCES)), - 'ls_r_var_lib_nova_instances': ls_instances.LsRVarLibNovaInstances(context_wrap(LS_R_VAR_LIB_NOVA_INSTANCES))} - ) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_lib_pcp.py b/insights/tests/parsers/test_ls_var_lib_pcp.py deleted file mode 100644 index 1ac185211b..0000000000 --- a/insights/tests/parsers/test_ls_var_lib_pcp.py +++ /dev/null @@ -1,29 +0,0 @@ -import doctest - -from insights.parsers import ls_var_lib_pcp -from insights.parsers.ls_var_lib_pcp import LsVarLibPcp -from insights.tests import context_wrap - -LS_VAR_LIB_PCP = """ -total 16 -drwxr-xr-x. 4 root root 33 Dec 15 08:12 . -drwxr-xr-x. 20 root root 278 Dec 15 08:12 .. -drwxr-xr-x. 2 root root 6 Oct 3 09:37 pmcd -drwxr-xr-x. 2 root root 6 Oct 3 09:37 pmie -drwxrwxr-x. 4 root root 128 Aug 22 17:55 pmdas -""" - - -def test_ls_var_lib_pcp(): - ls_var_lib_pcp = LsVarLibPcp(context_wrap(LS_VAR_LIB_PCP, path="insights_commands/ls_-la_.var.lib.pcp")) - assert ls_var_lib_pcp.dirs_of('/var/lib/pcp') == ['.', '..', 'pmcd', 'pmie', 'pmdas'] - journal = ls_var_lib_pcp.dir_entry('/var/lib/pcp', 'pmdas') - assert journal is not None - - -def test_ls_var_lib_pcp_doc_examples(): - env = { - 'ls_var_lib_pcp': LsVarLibPcp(context_wrap(LS_VAR_LIB_PCP, path="insights_commands/ls_-la_.var.lib.pcp")), - } - failed, total = doctest.testmod(ls_var_lib_pcp, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_lib_rpm.py b/insights/tests/parsers/test_ls_var_lib_rpm.py deleted file mode 100644 index 8f05d655a4..0000000000 --- a/insights/tests/parsers/test_ls_var_lib_rpm.py +++ /dev/null @@ -1,62 +0,0 @@ -from insights.parsers import ls_var_lib_rpm -from insights.parsers.ls_var_lib_rpm import LsVarLibRpm -from insights.tests import context_wrap -import doctest - -LS_VAR_LIB_RPM = """ -total 172400 -drwxr-xr-x. 2 0 0 4096 Oct 19 2022 . -drwxr-xr-x. 31 0 0 4096 Nov 26 2021 .. --rw-r--r--. 1 0 0 4034560 Apr 17 16:06 Basenames --rw-r--r--. 1 0 0 8192 Apr 17 16:06 Conflictname --rw-r--r--. 1 0 0 270336 Apr 24 10:31 __db.001 --rw-r--r--. 1 0 0 81920 Apr 24 10:31 __db.002 --rw-r--r--. 1 0 0 1318912 Apr 24 10:31 __db.003 --rw-r--r--. 1 0 0 0 Nov 9 2021 .dbenv.lock --rw-r--r--. 1 0 0 2707456 Apr 17 16:06 Dirnames --rw-r--r--. 1 0 0 8192 Nov 9 2021 Enhancename --rw-r--r--. 1 0 0 8192 Nov 26 2021 Filetriggername --rw-r--r--. 1 0 0 12288 Apr 17 16:06 Group --rw-r--r--. 1 0 0 20480 Apr 17 16:06 Installtid --rw-r--r--. 1 0 0 45056 Apr 17 16:06 Name --rw-r--r--. 1 0 0 16384 Apr 17 10:43 Obsoletename --rw-r--r--. 1 0 0 165253120 Apr 17 16:06 Packages --rw-r--r--. 1 0 0 2461696 Apr 17 16:06 Providename --rw-r--r--. 1 0 0 8192 Apr 17 10:42 Recommendname --rw-r--r--. 1 0 0 245760 Apr 17 16:06 Requirename --rw-r--r--. 1 0 0 0 Nov 9 2021 .rpm.lock --rw-r--r--. 1 0 0 77824 Apr 17 16:06 Sha1header --rw-r--r--. 1 0 0 40960 Apr 17 16:06 Sigmd5 --rw-r--r--. 1 0 0 8192 Apr 17 10:42 Suggestname --rw-r--r--. 1 0 0 8192 Apr 17 10:42 Supplementname --rw-r--r--. 1 0 0 8192 Apr 17 10:42 Transfiletriggername --rw-r--r--. 1 0 0 8192 Apr 17 10:44 Triggername -""" - -LS_VAR_LIB_RPM_DOC_EXAMPLE = """ -total 172400 -drwxr-xr-x. 2 0 0 4096 Oct 19 2022 . -drwxr-xr-x. 31 0 0 4096 Nov 26 2021 .. --rw-r--r--. 1 0 0 4034560 Apr 17 16:06 Basenames --rw-r--r--. 1 0 0 8192 Apr 17 16:06 Conflictname --rw-r--r--. 1 0 0 16384 Apr 17 10:43 Obsoletename --rw-r--r--. 1 0 0 165253120 Apr 17 16:06 Packages --rw-r--r--. 1 0 0 2461696 Apr 17 16:06 Providename --rw-r--r--. 1 0 0 8192 Apr 17 10:42 Recommendname -""" - - -def test_ls_var_lib_rpm(): - var_lib_rpm = LsVarLibRpm(context_wrap(LS_VAR_LIB_RPM, path="insights_commands/ls_-lan_.var.lib.rpm")) - assert len(var_lib_rpm.files_of('/var/lib/rpm')) == 24 - assert 'Recommendname' in var_lib_rpm.files_of('/var/lib/rpm') - assert var_lib_rpm.dir_contains('/var/lib/rpm', 'Packages') is True - assert var_lib_rpm.dir_entry('/var/lib/rpm', 'Triggername') == {'type': '-', 'perms': 'rw-r--r--.', 'links': 1, 'owner': '0', 'group': '0', 'size': 8192, 'date': 'Apr 17 10:44', 'name': 'Triggername', 'raw_entry': '-rw-r--r--. 1 0 0 8192 Apr 17 10:44 Triggername', 'dir': '/var/lib/rpm'} - - -def test_ls_var_lib_rpm_doc_examples(): - env = { - 'var_lib_rpm': LsVarLibRpm(context_wrap(LS_VAR_LIB_RPM_DOC_EXAMPLE, path="insights_commands/ls_-lan_.var.lib.rpm")) - } - failed, total = doctest.testmod(ls_var_lib_rpm, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_lib_rsyslog.py b/insights/tests/parsers/test_ls_var_lib_rsyslog.py deleted file mode 100644 index 1e668fffff..0000000000 --- a/insights/tests/parsers/test_ls_var_lib_rsyslog.py +++ /dev/null @@ -1,32 +0,0 @@ -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 diff --git a/insights/tests/parsers/test_ls_var_log.py b/insights/tests/parsers/test_ls_var_log.py deleted file mode 100644 index dd0b8c7356..0000000000 --- a/insights/tests/parsers/test_ls_var_log.py +++ /dev/null @@ -1,150 +0,0 @@ -from insights.parsers.ls_var_log import LsVarLog -from insights.tests import context_wrap -from insights.util.file_permissions import FilePermissions - -# from RHEL 7.2 -LS_1 = """ -/var/log: -total 1016 -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 . -drwxr-xr-x. 19 root root 4096 Oct 19 15:38 .. -drwxr-xr-x. 2 root root 4096 Jun 28 10:26 anaconda -drwxr-x---. 2 root root 22 Jun 28 10:26 audit --rw-r--r--. 1 root root 8433 Oct 19 15:38 boot.log --rw-------. 1 root utmp 0 Oct 19 05:39 btmp --rw-------. 1 root root 11370 Oct 19 22:01 cron --rw-r--r--. 1 root root 32226 Oct 19 15:38 dmesg --rw-r--r--. 1 root root 34423 Oct 19 15:27 dmesg.old --rw-------. 1 root root 5466 Oct 19 05:40 grubby --rw-r--r--. 1 root root 292292 Oct 19 22:42 lastlog --rw-------. 1 root root 1386 Oct 19 15:39 maillog --rw-------. 1 root root 609617 Oct 19 22:42 messages -drwx------. 2 root root 6 Jan 26 2014 ppp -drwxr-xr-x. 2 root root 41 Jun 28 10:28 rhsm --rw-------. 1 root root 18185 Oct 19 22:42 secure --rw-------. 1 root root 0 Jun 28 10:20 spooler --rw-------. 1 root root 0 Jun 28 10:19 tallylog -drwxr-xr-x. 2 root root 22 Sep 1 07:32 tuned --rw-r--r--. 1 root root 1854 Oct 19 22:38 up2date --rw-r--r--. 1 root root 211784 Jun 28 10:41 vboxadd-install.log --rw-r--r--. 1 root root 73 Oct 19 05:17 vboxadd-install-x11.log --rw-r--r--. 1 root root 1 Jun 28 10:40 VBoxGuestAdditions.log --rw-r--r--. 1 root root 280 Oct 19 15:38 wpa_supplicant.log --rw-rw-r--. 1 root utmp 21504 Oct 19 22:42 wtmp --rw-------. 1 root root 8423 Oct 19 15:29 yum.log - -/var/log/anaconda: -total 1048 -drwxr-xr-x. 2 root root 4096 Jun 28 10:26 . -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 .. --rw-------. 1 root root 17862 Jun 28 10:26 anaconda.log --rw-------. 1 root root 1726 Jun 28 10:26 ifcfg.log --rw-------. 1 root root 680224 Jun 28 10:26 journal.log --rw-------. 1 root root 0 Jun 28 10:26 ks-script-2aaku7.log --rw-------. 1 root root 114262 Jun 28 10:26 packaging.log --rw-------. 1 root root 30137 Jun 28 10:26 program.log --rw-------. 1 root root 88243 Jun 28 10:26 storage.log --rw-------. 1 root root 63190 Jun 28 10:26 syslog --rw-------. 1 root root 52756 Jun 28 10:26 X.log - -/var/log/audit: -total 1288 -drwxr-x---. 2 root root 22 Jun 28 10:26 . -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 .. --rw-------. 1 root root 1259137 Oct 19 22:42 audit.log - -/var/log/ppp: -total 4 -drwx------. 2 root root 6 Jan 26 2014 . -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 .. - -/var/log/rhsm: -total 32 -drwxr-xr-x. 2 root root 41 Jun 28 10:28 . -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 .. --rw-r--r--. 1 root root 4279 Oct 19 19:39 rhsmcertd.log --rw-r--r--. 1 root root 18331 Oct 19 19:39 rhsm.log - -/var/log/tuned: -total 16 -drwxr-xr-x. 2 root root 22 Sep 1 07:32 . -drwxr-xr-x. 7 root root 4096 Oct 19 15:38 .. --rw-r--r--. 1 root root 8834 Oct 19 15:39 tuned.log - -""".strip() - - -""" -These tests are mainly derived from the old implementation of LsVarLog, -which did its own parsing and used FilePermissions objects throughout. -The new implementation used the more completely tested and more robust -FileListing parser. So some tests are a bit ... odd. -""" - - -def test_smoketest(): - context = context_wrap(LS_1) - result = LsVarLog(context) - - assert "/var/log" in result - assert "/var/log/audit" in result - assert "/var/log/ppp" in result - assert "/var/log/rhsm" in result - assert "/var/log/tuned" in result - assert "audit.log" in result.listings["/var/log/audit"]['entries'] - assert "audit.log" == result.get_filepermissions("/var/log/audit", "audit.log").path - - -def test_dir_parsed(): - context = context_wrap(LS_1) - result = LsVarLog(context) - ls = {} - current_dir = "" - test_lines = LS_1.splitlines() - for line in test_lines: - # wonky parsing from memory to test the actual implementation; doesn't expect evil input! - if line.endswith(":"): - current_dir = line.split(":")[0] - ls[current_dir] = [] - elif line.startswith("total"): - pass - elif line: - fileperm = FilePermissions(line) - ls[current_dir].append(fileperm.path) - for dir in ls: - assert dir in result - dir_from_parser = result.listings[dir]['entries'] - # Two way cross-check: - # Were all files in our simple parse found in the parser? - for fil in ls[dir]: - assert fil in dir_from_parser - # Were all files in the parser found in our simple parse? - - for fil in dir_from_parser: - assert fil in ls[dir] - - -def test_get_filepermissions(): - context = context_wrap(LS_1) - result = LsVarLog(context) - ls = {} - current_dir = "" - test_lines = LS_1.splitlines() - for line in test_lines: - # wonky parsing from memory to test the actual implementation; doesn't expect evil input! - if line.endswith(":"): - current_dir = line.split(":")[0] - ls[current_dir] = [] - elif line.startswith("total"): - pass - elif line: - fileperm = FilePermissions(line) - ls[current_dir].append(fileperm) - for dir in ls: - assert dir in result - for fil in ls[dir]: - found = result.get_filepermissions(dir, fil.path) - assert found is not None - assert fil.line == found.line - not_found = result.get_filepermissions(dir, "nonexisting" + fil.path) - assert not_found is None diff --git a/insights/tests/parsers/test_ls_var_opt_mssql.py b/insights/tests/parsers/test_ls_var_opt_mssql.py deleted file mode 100644 index c189475ff4..0000000000 --- a/insights/tests/parsers/test_ls_var_opt_mssql.py +++ /dev/null @@ -1,57 +0,0 @@ -import doctest -from insights.parsers import ls_var_opt_mssql -from insights.tests import context_wrap - - -LS_VAR_OPT_MSSQL_WRONG_PERM = """ -drwxrwx---. 5 root root 58 Apr 16 07:20 /var/opt/mssql -""".strip() - -LS_VAR_OPT_MSSQL_WRONG_PERM_2 = """ -drwxrwx---. 5 mssql root 58 Apr 16 07:20 /var/opt/mssql -""".strip() - -LS_VAR_OPT_MSSQL = """ -drwxrwx---. 5 mssql mssql 58 Apr 16 07:20 /var/opt/mssql -""".strip() - - -def test_ls_var_opt_mssql(): - content = ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL_WRONG_PERM, path='ls_-ld_.var.opt.mssql')) - content_attr = content.listing_of('/var/opt/mssql').get('/var/opt/mssql') - assert content_attr.get('owner') != "mssql" - assert content_attr.get('group') != "mssql" - - content = ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL_WRONG_PERM_2, path='ls_-ld_.var.opt.mssql')) - content_attr = content.listing_of('/var/opt/mssql').get('/var/opt/mssql') - assert content_attr.get('owner') == "mssql" - assert content_attr.get('group') != "mssql" - - content = ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL, path='ls_-ld_.var.opt.mssql')) - content_attr = content.listing_of('/var/opt/mssql').get('/var/opt/mssql') - assert content_attr.get('owner') == "mssql" - assert content_attr.get('group') == "mssql" - - -def _failed_without_insights_command_as_path(): - # Fails with KeyError: '/var/opt/mssql'" unless path is defined - foo = ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL_WRONG_PERM_2)) - content_attr = foo.listing_of('/var/opt/mssql').get('/var/opt/mssql') - assert content_attr.get('owner') != "mssql" - assert content_attr.get('group') != "mssql" - - -def _failed_with_standard_path(): - # Fails with KeyError: '/var/opt/mssql'". - bar = ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL_WRONG_PERM_2, path='/var/opt/mssql')) - content_attr = bar.listing_of('/var/opt/mssql').get('/var/opt/mssql') - assert content_attr.get('owner') != "mssql" - assert content_attr.get('group') != "mssql" - - -def test_ls_var_opt_mssql_docs(): - failed_count, tests = doctest.testmod( - ls_var_opt_mssql, - globs={'content': ls_var_opt_mssql.LsDVarOptMSSql(context_wrap(LS_VAR_OPT_MSSQL_WRONG_PERM, path='ls_-ld_.var.opt.mssql'))} - ) - assert failed_count == 0 diff --git a/insights/tests/parsers/test_ls_var_opt_mssql_log.py b/insights/tests/parsers/test_ls_var_opt_mssql_log.py deleted file mode 100644 index 88f2eb30d3..0000000000 --- a/insights/tests/parsers/test_ls_var_opt_mssql_log.py +++ /dev/null @@ -1,32 +0,0 @@ -import doctest -from insights.parsers import ls_var_opt_mssql_log -from insights.parsers.ls_var_opt_mssql_log import LsVarOptMssqlLog -from insights.tests import context_wrap - -MSSQL_LOG = """ -total 6322200 -drwxr-xr-x. 3 mssql mssql 256 Jun 7 10:07 . -drwxr-xr-x. 71 root root 4096 Jun 22 10:35 .. -drwxr-xr-x. 2 mssql mssql 65 Jul 10 09:33 journal --rw-------. 1 mssql mssql 67108864 Jul 10 09:32 local.0 -""" - - -def test_ls_var_opt_mssql_log(): - log = LsVarOptMssqlLog(context_wrap(MSSQL_LOG, path="insights_commands/ls_-la_.var.opt.mssql.log")) - assert log.dirs_of('/var/opt/mssql/log') == ['.', '..', 'journal'] - journal = log.dir_entry('/var/opt/mssql/log', 'journal') - print(journal) - assert journal == { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'links': 2, 'owner': 'mssql', - 'group': 'mssql', 'size': 65, 'date': 'Jul 10 09:33', - 'raw_entry': 'drwxr-xr-x. 2 mssql mssql 65 Jul 10 09:33 journal', - 'name': 'journal', 'dir': '/var/opt/mssql/log'} - - -def test_ls_var_opt_mssql_log_examples(): - env = { - 'ls_mssql_log': LsVarOptMssqlLog(context_wrap(MSSQL_LOG, path="insights_commands/ls_-la_.var.opt.mssql.log")), - } - failed, total = doctest.testmod(ls_var_opt_mssql_log, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_run.py b/insights/tests/parsers/test_ls_var_run.py deleted file mode 100644 index 8e2be79db3..0000000000 --- a/insights/tests/parsers/test_ls_var_run.py +++ /dev/null @@ -1,44 +0,0 @@ -import doctest - -from insights.parsers import ls_var_run -from insights.parsers.ls_var_run import LsVarRun -from insights.tests import context_wrap - -LS_VAR_RUN = """ -total 20 -drwx--x---. 2 0 984 40 May 15 09:29 openvpn -drwxr-xr-x. 2 0 0 40 May 15 09:30 plymouth -drwxr-xr-x. 2 0 0 40 May 15 09:29 ppp -drwxr-xr-x. 2 75 75 40 May 15 09:29 radvd --rw-r--r--. 1 0 0 5 May 15 09:30 rhnsd.pid -drwxr-xr-x. 2 0 0 60 May 30 09:31 rhsm -drwx------. 2 32 32 40 May 15 09:29 rpcbind --r--r--r--. 1 0 0 0 May 17 16:26 rpcbind.lock -""" - - -def test_ls_var_run(): - ls_var_run = LsVarRun(context_wrap(LS_VAR_RUN, path='insights_commands/ls_-lnL_.var.run')) - assert ls_var_run.dirs_of('/var/run') == ['openvpn', 'plymouth', 'ppp', 'radvd', 'rhsm', 'rpcbind'] - foreman = ls_var_run.dir_entry('/var/run', 'openvpn') - assert foreman is not None - assert foreman == { - 'group': '984', - 'name': 'openvpn', - 'links': 2, - 'perms': 'rwx--x---.', - 'raw_entry': 'drwx--x---. 2 0 984 40 May 15 09:29 openvpn', - 'owner': '0', - 'date': 'May 15 09:29', - 'type': 'd', - 'size': 40, - 'dir': '/var/run'} - - -def test_ls_var_run_doc_examples(): - env = { - 'LsVarRun': LsVarRun, - 'ls_var_run': LsVarRun(context_wrap(LS_VAR_RUN, path='insights_commands/ls_-lnL_.var.run')), - } - failed, total = doctest.testmod(ls_var_run, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_spool_clientmq.py b/insights/tests/parsers/test_ls_var_spool_clientmq.py deleted file mode 100644 index 555dba781d..0000000000 --- a/insights/tests/parsers/test_ls_var_spool_clientmq.py +++ /dev/null @@ -1,31 +0,0 @@ -import doctest - -from insights.parsers import ls_var_spool_clientmq -from insights.parsers.ls_var_spool_clientmq import LsVarSpoolClientmq -from insights.tests import context_wrap - -LS_VAR_SPOOL_CLIENTMQ = """ -total 40 --rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6Wilr002718 --rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6WixJ002715 --rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6WjP6002721 --rw-rw---- 1 51 51 817 Jul 11 03:35 dfw6B7Z8BB002906 --rw-rw---- 1 51 51 817 Jul 11 04:02 dfw6B822T0011150 -""" - - -def test_ls_var_spool_clientmq(): - ls_var_spool_clientmq = LsVarSpoolClientmq(context_wrap(LS_VAR_SPOOL_CLIENTMQ, path='insights_commands/ls_-ln_.var.spool.clientmqueue')) - assert ls_var_spool_clientmq.files_of('/var/spool/clientmqueue') == ['dfw6B6Wilr002718', 'dfw6B6WixJ002715', 'dfw6B6WjP6002721', 'dfw6B7Z8BB002906', 'dfw6B822T0011150'] - onemail = ls_var_spool_clientmq.dir_entry('/var/spool/clientmqueue', 'dfw6B6Wilr002718') - assert onemail is not None - assert onemail == {'group': '51', 'name': 'dfw6B6Wilr002718', 'links': 1, 'perms': 'rw-rw----', 'raw_entry': '-rw-rw---- 1 51 51 4 Jul 11 02:32 dfw6B6Wilr002718', 'owner': '51', 'date': 'Jul 11 02:32', 'type': '-', 'dir': '/var/spool/clientmqueue', 'size': 4} - - -def test_ls_var_spool_clientmq_doc_examples(): - env = { - 'LsVarSpoolClientmq': LsVarSpoolClientmq, - 'ls_var_spool_clientmq': LsVarSpoolClientmq(context_wrap(LS_VAR_SPOOL_CLIENTMQ, path='insights_commands/ls_-ln_.var.spool.clientmqueue')), - } - failed, total = doctest.testmod(ls_var_spool_clientmq, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_spool_postfix_maildrop.py b/insights/tests/parsers/test_ls_var_spool_postfix_maildrop.py deleted file mode 100644 index ea4b6e5e13..0000000000 --- a/insights/tests/parsers/test_ls_var_spool_postfix_maildrop.py +++ /dev/null @@ -1,28 +0,0 @@ -import doctest - -from insights.parsers import ls_var_spool_postfix_maildrop -from insights.parsers.ls_var_spool_postfix_maildrop import LsVarSpoolPostfixMaildrop -from insights.tests import context_wrap - -LS_VAR_SPOOL_POSTFIX_MAILDROP = """ -total 20 --rwxr--r--. 1 0 90 258 Jul 11 15:54 55D6821C286 --rwxr--r--. 1 0 90 282 Jul 11 15:54 5852121C284 --rwxr--r--. 1 0 90 258 Jul 11 15:54 9FFEC21C287 --rwxr--r--. 1 0 90 258 Jul 11 15:54 E9A4521C285 --rwxr--r--. 1 0 90 258 Jul 11 15:54 EA60F21C288 -""" - - -def test_ls_var_spool_postfix_maildrop(): - ls_var_spool_postfix_maildrop = LsVarSpoolPostfixMaildrop(context_wrap(LS_VAR_SPOOL_POSTFIX_MAILDROP, path='nsights_commands/ls_-ln_.var.spool.postfix.maildrop')) - assert ls_var_spool_postfix_maildrop.files_of('/var/spool/postfix/maildrop') == ['55D6821C286', '5852121C284', '9FFEC21C287', 'E9A4521C285', 'EA60F21C288'] - - -def test_ls_var_spool_postfix_maildrop_doc_examples(): - env = { - 'LsVarSpoolPostfixMaildrop': LsVarSpoolPostfixMaildrop, - 'ls_var_spool_postfix_maildrop': LsVarSpoolPostfixMaildrop(context_wrap(LS_VAR_SPOOL_POSTFIX_MAILDROP, path='nsights_commands/ls_-ln_.var.spool.postfix.maildrop')), - } - failed, total = doctest.testmod(ls_var_spool_postfix_maildrop, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_tmp.py b/insights/tests/parsers/test_ls_var_tmp.py deleted file mode 100644 index ade7aa49d2..0000000000 --- a/insights/tests/parsers/test_ls_var_tmp.py +++ /dev/null @@ -1,40 +0,0 @@ -import doctest - -from insights.parsers import ls_var_tmp -from insights.parsers.ls_var_tmp import LsVarTmp -from insights.tests import context_wrap - -LS_VAR_TMP = """ -/var/tmp: -total 20 -drwxr-xr-x. 2 0 0 4096 Mar 26 02:25 a1 -drwxr-xr-x. 2 0 0 4096 Mar 26 02:25 a2 -drwxr-xr-x. 3 0 0 4096 Apr 3 02:50 foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad -""" - - -def test_ls_var_tmp(): - ls_var_tmp = LsVarTmp(context_wrap(LS_VAR_TMP)) - assert ls_var_tmp.dirs_of('/var/tmp') == ['a1', 'a2', 'foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad'] - foreman = ls_var_tmp.dir_entry('/var/tmp', 'foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad') - assert foreman is not None - assert foreman == { - 'group': '0', - 'name': 'foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad', - 'links': 3, - 'perms': 'rwxr-xr-x.', - 'raw_entry': 'drwxr-xr-x. 3 0 0 4096 Apr 3 02:50 foreman-ssh-cmd-fc3f65c9-2b35-480d-87e3-1d971433d6ad', - 'owner': '0', - 'date': 'Apr 3 02:50', - 'type': 'd', - 'size': 4096, - 'dir': '/var/tmp'} - - -def test_ls_var_tmp_doc_examples(): - env = { - 'LsVarTmp': LsVarTmp, - 'ls_var_tmp': LsVarTmp(context_wrap(LS_VAR_TMP)), - } - failed, total = doctest.testmod(ls_var_tmp, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_ls_var_www_perms.py b/insights/tests/parsers/test_ls_var_www_perms.py deleted file mode 100644 index 74f7779374..0000000000 --- a/insights/tests/parsers/test_ls_var_www_perms.py +++ /dev/null @@ -1,71 +0,0 @@ -import doctest -import pytest - -from insights.parsers import ls_var_www_perms -from insights.parsers.ls_var_www_perms import LsVarWwwPerms -from insights.tests import context_wrap -from insights.util.file_permissions import FilePermissions - - -GOOD_FOLDER_OUTPUT = """ -crw-rw-rw-. 1 root root 1, 3 Dec 18 09:18 /dev/null - -/var/www: -total 16 -drwxr-xr-x. 4 root root 33 Dec 15 08:12 . -drwxr-xr-x. 20 root root 278 Dec 15 08:12 .. -drwxr-xr-x. 2 root root 6 Oct 3 09:37 cgi-bin -drwxr-xr-x. 2 root root 6 Oct 3 09:37 html -""" - -GOOD_FOLDER_EXPECTED_OUTPUT = [ - "drwxr-xr-x. 4 root root 33 Dec 15 08:12 .", - "drwxr-xr-x. 20 root root 278 Dec 15 08:12 ..", - "drwxr-xr-x. 2 root root 6 Oct 3 09:37 cgi-bin", - "drwxr-xr-x. 2 root root 6 Oct 3 09:37 html", -] - -EMPTY_FOLDER_OUTPUT = """ -crw-rw-rw-. 1 root root 1, 3 Dec 18 09:18 /dev/null - -/var/www: -total 0 -drwxr-xr-x. 4 root root 33 Dec 15 08:12 . -drwxr-xr-x. 20 root root 278 Dec 15 08:12 .. -""" - -EMPTY_FOLDER_EXPECTED_OUTPUT = [ - "drwxr-xr-x. 4 root root 33 Dec 15 08:12 .", - "drwxr-xr-x. 20 root root 278 Dec 15 08:12 ..", -] - -NO_FOLDER_OUTPUT = """ -/bin/ls: cannot access '/var/www': No such file or directory -crw-rw-rw-. 1 root root 1, 3 Dec 18 09:18 /dev/null -""" - -NO_FOLDER_EXPECTED_OUTPUT = [ -] - -OUTPUTS_FROM_FOLDERS = [ - (GOOD_FOLDER_OUTPUT, GOOD_FOLDER_EXPECTED_OUTPUT), - (EMPTY_FOLDER_OUTPUT, EMPTY_FOLDER_EXPECTED_OUTPUT), - (NO_FOLDER_OUTPUT, NO_FOLDER_EXPECTED_OUTPUT) -] - - -@pytest.mark.parametrize("output, expected_output", OUTPUTS_FROM_FOLDERS) -def test_ls_var(output, expected_output): - test = LsVarWwwPerms(context_wrap(output)) - assert len(test.file_permissions) == len(expected_output) - for test_line, expected_line in zip(test.file_permissions, expected_output): - assert repr(test_line) == repr(FilePermissions(expected_line)) - assert test_line.line == FilePermissions(expected_line).line - - -def test_doc_examples(): - env = { - "ls_var_www_perms": LsVarWwwPerms(context_wrap(GOOD_FOLDER_OUTPUT)) - } - failed, total = doctest.testmod(ls_var_www_perms, globs=env) - assert failed == 0 diff --git a/insights/tests/parsers/test_rpm_v_packages.py b/insights/tests/parsers/test_rpm_v_packages.py index ac14ba8361..c880313596 100644 --- a/insights/tests/parsers/test_rpm_v_packages.py +++ b/insights/tests/parsers/test_rpm_v_packages.py @@ -3,24 +3,10 @@ from insights.core.exceptions import SkipComponent from insights.parsers import rpm_v_packages -from insights.parsers.rpm_v_packages import RpmVPackages, RpmVPackage +from insights.parsers.rpm_v_packages import RpmVPackage from insights.tests import context_wrap -TEST_RPM = """ -package procps is not installed -..?...... c /etc/sudoers -..?...... /usr/bin/sudo -..?...... /usr/bin/sudoreplay -missing /var/db/sudo/lectured (Permission denied) -""" - -TEST_RPM_2 = """ -package procps is not installed -S.5....T. c /etc/sudoers -S.5....T. c /etc/chrony.conf -""" - TEST_RPM_V_PACKAGE_1 = """ ..?...... c /etc/sudoers ..?...... /usr/bin/sudo @@ -35,43 +21,33 @@ CONTEXT_PATH_1 = "insights_commands/rpm_-V_sudo" -def test_rpm_empty(): - rpm_pkgs = RpmVPackages(context_wrap([])) - assert rpm_pkgs.packages_list == [] - - -def test_rpm(): - line_1 = {'attributes': None, 'file': None, - 'line': 'package procps is not installed', 'mark': None} - line_2 = {'attributes': '..?......', 'file': '/etc/sudoers', - 'line': '..?...... c /etc/sudoers', 'mark': 'c'} - line_3 = {'attributes': '..?......', 'file': '/usr/bin/sudo', - 'line': '..?...... /usr/bin/sudo', 'mark': None} - line_4 = {'attributes': '..?......', 'file': '/usr/bin/sudoreplay', - 'line': '..?...... /usr/bin/sudoreplay', 'mark': None} - line_5 = {'attributes': None, 'file': None, - 'line': 'missing /var/db/sudo/lectured (Permission denied)', 'mark': None} - - rpm_pkgs = RpmVPackages(context_wrap(TEST_RPM)) - assert rpm_pkgs.packages_list[0] == line_1 - assert rpm_pkgs.packages_list[1] == line_2 - assert rpm_pkgs.packages_list[2] == line_3 - assert rpm_pkgs.packages_list[3] == line_4 - assert rpm_pkgs.packages_list[4] == line_5 - - rpm_pkgs_2 = RpmVPackages(context_wrap(TEST_RPM_2)) - assert rpm_pkgs_2.packages_list[2].get('file', None) == '/etc/chrony.conf' - - def test_rpm_pkg(): - line = [{'attributes': '..?......', 'file': '/etc/sudoers', - 'line': '..?...... c /etc/sudoers', 'mark': 'c'}, - {'attributes': '..?......', 'file': '/usr/bin/sudo', - 'line': '..?...... /usr/bin/sudo', 'mark': None}, - {'attributes': '..?......', 'file': '/usr/bin/sudoreplay', - 'line': '..?...... /usr/bin/sudoreplay', 'mark': None}, - {'attributes': None, 'file': None, - 'line': 'missing /var/db/sudo/lectured (Permission denied)', 'mark': None}] + line = [ + { + 'attributes': '..?......', + 'file': '/etc/sudoers', + 'line': '..?...... c /etc/sudoers', + 'mark': 'c', + }, + { + 'attributes': '..?......', + 'file': '/usr/bin/sudo', + 'line': '..?...... /usr/bin/sudo', + 'mark': None, + }, + { + 'attributes': '..?......', + 'file': '/usr/bin/sudoreplay', + 'line': '..?...... /usr/bin/sudoreplay', + 'mark': None, + }, + { + 'attributes': None, + 'file': None, + 'line': 'missing /var/db/sudo/lectured (Permission denied)', + 'mark': None, + }, + ] rpm_pkg = RpmVPackage(context_wrap(TEST_RPM_V_PACKAGE_1, CONTEXT_PATH_1)) for index in range(4): @@ -92,9 +68,6 @@ def test_rpm_pkg_not_installed(): def test_doc_examples(): - env = { - "rpm_v_packages": RpmVPackages(context_wrap(TEST_RPM)), - "rpm_v_pkg": RpmVPackage(context_wrap(TEST_RPM_V_PACKAGE_1, CONTEXT_PATH_1)) - } + env = {"rpm_v_pkg": RpmVPackage(context_wrap(TEST_RPM_V_PACKAGE_1, CONTEXT_PATH_1))} failed, total = doctest.testmod(rpm_v_packages, globs=env) assert failed == 0 diff --git a/insights/tests/test_file_listing.py b/insights/tests/test_file_listing.py deleted file mode 100644 index 6985fb295c..0000000000 --- a/insights/tests/test_file_listing.py +++ /dev/null @@ -1,317 +0,0 @@ -# -*- coding: UTF-8 -*- -from insights.core import FileListing -from insights.tests import context_wrap - -SINGLE_DIRECTORY = """ -total 32 -drwxr-xr-x. 5 root root 4096 Jun 28 2017 . -drwxr-xr-x. 15 root root 4096 Aug 10 09:42 .. -lrwxrwxrwx. 1 root root 49 Jun 28 2017 cert.pem -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem -drwxr-xr-x. 2 root root 4096 Jun 28 2017 certs -drwxr-xr-x. 2 root root 4096 Mar 29 2017 misc --rw-r--r--. 1 root root 10923 Feb 7 2017 openssl.cnf -drwxr-xr-x. 2 root root 4096 Feb 7 2017 private -""" - -MULTIPLE_DIRECTORIES = """ -/etc/sysconfig: -total 96 -drwxr-xr-x. 7 0 0 4096 Jul 6 23:41 . -drwxr-xr-x. 77 0 0 8192 Jul 13 03:55 .. -drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq -drwxr-xr-x. 2 0 0 6 Sep 16 2015 console --rw-------. 1 0 0 1390 Mar 4 2014 ebtables-config --rw-r--r--. 1 0 0 72 Sep 15 2015 firewalld -lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub - -/etc/rc.d/rc3.d: -total 4 -drwxr-xr-x. 2 0 0 58 Jul 6 23:32 . -drwxr-xr-x. 10 0 0 4096 Sep 16 2015 .. -lrwxrwxrwx. 1 0 0 20 Jul 6 23:32 K50netconsole -> ../init.d/netconsole -lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 S10network -> ../init.d/network -lrwxrwxrwx. 1 0 0 15 Jul 6 23:32 S97rhnsd -> ../init.d/rhnsd -""" - -COMPLICATED_FILES = """ -/tmp: -total 16 -dr-xr-xr-x. 2 0 0 4096 Mar 4 16:19 . -dr-xr-xr-x. 10 0 0 4096 Mar 4 16:19 .. --rw-r--r--. 1 0 0 123891 Aug 25 2015 config-3.10.0-229.14.1.el7.x86_64 -lrwxrwxrwx. 1 0 0 11 Aug 4 2014 menu.lst -> ./grub.conf -brw-rw----. 1 0 6 253, 10 Aug 4 16:56 dm-10 -crw-------. 1 0 0 10, 236 Jul 25 10:00 control -srw-------. 1 26214 17738 0 Oct 19 08:48 geany_socket.c46453c2 --rw-rw-r--. 1 24306 24306 13895 Oct 21 15:42 File name with spaces in it! --rw-rw-r--. 1 24306 24306 13895 Oct 21 15:42 Unicode ÅÍÎÏÓÔÒÚÆ☃ madness.txt -drwxr-xr-x+ 2 0 0 41 Jul 6 23:32 additional_ACLs --rw-rw----. 1 0 6 253, 10 Aug 4 16:56 comma in size currently valid -brw-rw----. 1 0 6 1048576 Aug 4 16:56 block dev with no comma also valid --rwxr-xr-x. 2 0 0 1024 Jul 6 23:32 file_name_ending_with_colon: -lrwxrwxrwx. 1 0 0 11 Aug 4 2014 link with spaces -> ../file with spaces -""" - -SELINUX_DIRECTORY = """ -/boot: -total 3 --rw-r--r--. root root system_u:object_r:boot_t:s0 config-3.10.0-267 -drwxr-xr-x. root root system_u:object_r:boot_t:s0 grub2 --rw-r--r--. root root system_u:object_r:boot_t:s0 initramfs-0-rescue -""" - -FILES_CREATED_WITH_SELINUX_DISABLED = """ -/dev/mapper: -total 2 -lrwxrwxrwx 1 0 0 7 Apr 27 05:34 lv_cpwtk001_data01 -> ../dm-7 -lrwxrwxrwx 1 0 0 7 Apr 27 05:34 lv_cpwtk001_redo01 -> ../dm-8 -""" - -BAD_DIRECTORY_ENTRIES = """ -dr-xr-xr-x. 2 0 0 4096 Mar 4 16:19 dir entry with no dir header -total 3 - -/badness: - -rwxr-xr-x. 0 0 1 Sep 12 2010 indented entry -xr-xr--r--. 0 0 1 Sep 12 2010 bad file type --rxr-xr-x. 0 0 1 Sep 12 2010 missing user w permission --rwxr-xr-x 0 0 1 Sep 12 2010 missing ACL dot --rw-r--r--. user with spaces group 2 Oct 3 2011 user with spaces --rw-r--r--. user group with spaces 2 Oct 3 2011 group with spaces -dr-xr-xr-x. -42 -63 1271 Jan 6 2008 Negative user and group numbers -dr-xr-xr-x. 1 7 123, 124, 125 Jan 6 2008 Three comma blocks in size -brw-rw----. 1 0 6 123456 Aug 4 16:56 two size blocks -prw-rw----. 1000 1000 0 6 2007 Month missing -prw-rw----. 1000 1000 0 No 6 2007 Month too short -prw-rw----. 1000 1000 0 November 6 2007 Month too long -prw-rw----. 1000 1000 0 Nov 2007 Day too long -prw-rw----. 1000 1000 0 Nov 126 2007 Day too long -prw-rw----. 1000 1000 0 Nov 126 Year missing -prw-rw----. 1000 1000 0 Nov 126 20107 Year too long -prw-rw----. 1000 1000 0 Nov 12 :56 Missing hour -prw-rw----. 1000 1000 0 Nov 12 723:56 Hour too long -prw-rw----. 1000 1000 0 Nov 12 23: Missing minute -prw-rw----. 1000 1000 0 Nov 12 23:3 Minute too short -prw-rw----. 1000 1000 0 Nov 12 23:357 Minute too long --rw------ 1 root root 762 Sep 23 002 permission too short -bash: ls: command not found --rw------ 1 root root 762 Se --rw------- 1 ro:t root 762 Sep 23 002 colon in uid --rw------- 1 root r:ot 762 Sep 23 002 colon in gid --rwasdfas- 1 root root 762 Sep 23 002 bad permissions block --rwx/----- 1 root root 762 Sep 23 002 slash in permissions block --rwx------ 1 root root 762 Sep 23 002 /slashes/in/filename -/rwasdfas- 1 root root 762 Sep 23 002 slash in file type and no colon on end -/usr/bin/ls: cannot access /boot/grub2/grub.cfg: No such file or directory -cannot access /boot/grub2/grub.cfg: No such file or directory -No such file or directory -adsf -""" - -# Note - should we test for anomalous but parseable entries? E.g. block -# devices without a major/minor number? Or non-devices that have a comma in -# the size? Permissions that don't make sense? Dates that don't make sense -# but still fit the patterns? What should the parser do with such entries? - - -def test_single_directory(): - # Mainly just testing that we can read a single directory and - # recognise it via the path rather than the directory in the output. - # Testing of the main functionality is mostly done below. - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la_.etc.pki.tls') - dirs = FileListing(ctx) - - assert '/etc/pki/tls' in dirs - assert '/etc/pki/tls' in dirs.listings - assert '/etc/pki/tls/certs' not in dirs - assert '/etc/pki' not in dirs - assert '/etc' not in dirs - assert dirs.listings['/etc/pki/tls']['name'] == '/etc/pki/tls' - - assert dirs.files_of('/etc/pki/tls') == ['cert.pem', 'openssl.cnf'] - assert dirs.dirs_of('/etc/pki/tls') == ['.', '..', 'certs', 'misc', 'private'] - assert dirs.total_of('/etc/pki/tls') == 32 - - -def test_multiple_directories(): - dirs = FileListing(context_wrap(MULTIPLE_DIRECTORIES, path='ls_-la_.etc')) - - assert '/etc/sysconfig' in dirs - assert '/etc/sysconfig' in dirs.listings - assert '/etc/rc.d/rc3.d' in dirs - assert '/etc/rc.d/rc4.d' not in dirs - - esc = dirs.listings['/etc/sysconfig'] - assert sorted(esc.keys()) == sorted(['entries', 'files', 'dirs', 'specials', 'total', 'name']) - - assert dirs.files_of('/etc/sysconfig') == ['ebtables-config', 'firewalld', 'grub'] - assert dirs.dirs_of('/etc/sysconfig') == ['.', '..', 'cbq', 'console'] - assert dirs.specials_of('/etc/sysconfig') == [] - - # Testing the main features - listing = dirs.listing_of('/etc/sysconfig') - assert listing['..'] == { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'links': 77, 'owner': '0', - 'group': '0', 'size': 8192, 'date': 'Jul 13 03:55', 'name': '..', - 'raw_entry': 'drwxr-xr-x. 77 0 0 8192 Jul 13 03:55 ..', - 'dir': '/etc/sysconfig' - } - assert listing['cbq'] == { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'links': 2, 'owner': '0', - 'group': '0', 'size': 41, 'date': 'Jul 6 23:32', 'name': 'cbq', - 'raw_entry': 'drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq', - 'dir': '/etc/sysconfig' - } - assert listing['firewalld'] == { - 'type': '-', 'perms': 'rw-r--r--.', 'links': 1, 'owner': '0', - 'group': '0', 'size': 72, 'date': 'Sep 15 2015', - 'name': 'firewalld', 'raw_entry': - '-rw-r--r--. 1 0 0 72 Sep 15 2015 firewalld', - 'dir': '/etc/sysconfig' - } - assert listing['grub'] == { - 'type': 'l', 'perms': 'rwxrwxrwx.', 'links': 1, 'owner': '0', - 'group': '0', 'size': 17, 'date': 'Jul 6 23:32', 'name': 'grub', - 'link': '/etc/default/grub', 'raw_entry': - 'lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub', - 'dir': '/etc/sysconfig' - } - - listing = dirs.listing_of('/etc/rc.d/rc3.d') - assert listing['..'] == { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'links': 10, 'owner': '0', - 'group': '0', 'size': 4096, 'date': 'Sep 16 2015', 'name': '..', - 'raw_entry': 'drwxr-xr-x. 10 0 0 4096 Sep 16 2015 ..', - 'dir': '/etc/rc.d/rc3.d' - } - assert listing['K50netconsole'] == { - 'type': 'l', 'perms': 'rwxrwxrwx.', 'links': 1, 'owner': '0', - 'group': '0', 'size': 20, 'date': 'Jul 6 23:32', - 'name': 'K50netconsole', 'link': '../init.d/netconsole', 'raw_entry': - 'lrwxrwxrwx. 1 0 0 20 Jul 6 23:32 K50netconsole -> ../init.d/netconsole', - 'dir': '/etc/rc.d/rc3.d' - } - - assert dirs.total_of('/etc/sysconfig') == 96 - assert dirs.total_of('/etc/rc.d/rc3.d') == 4 - - assert dirs.dir_contains('/etc/sysconfig', 'firewalld') - assert dirs.dir_entry('/etc/sysconfig', 'grub') == { - 'type': 'l', 'perms': 'rwxrwxrwx.', 'links': 1, 'owner': '0', - 'group': '0', 'size': 17, 'date': 'Jul 6 23:32', 'name': 'grub', - 'link': '/etc/default/grub', 'raw_entry': - 'lrwxrwxrwx. 1 0 0 17 Jul 6 23:32 grub -> /etc/default/grub', - 'dir': '/etc/sysconfig' - } - - assert dirs.path_entry('/etc/sysconfig/cbq') == { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'links': 2, 'owner': '0', - 'group': '0', 'size': 41, 'date': 'Jul 6 23:32', 'name': 'cbq', - 'raw_entry': 'drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq', - 'dir': '/etc/sysconfig' - } - assert dirs.path_entry('no_slash') is None - assert dirs.path_entry('/') is None - assert dirs.path_entry('/foo') is None - assert dirs.path_entry('/etc/sysconfig/notfound') is None - - -def test_complicated_directory(): - dirs = FileListing(context_wrap(COMPLICATED_FILES)) - - # Test the things we expect to be different: - listing = dirs.listing_of('/tmp') - assert listing['config-3.10.0-229.14.1.el7.x86_64']['type'] == '-' - assert listing['menu.lst']['type'] == 'l' - assert listing['menu.lst']['link'] == './grub.conf' - assert dirs.dir_entry('/tmp', 'dm-10') == { - 'type': 'b', 'perms': 'rw-rw----.', 'links': 1, 'owner': '0', - 'group': '6', 'major': 253, 'minor': 10, 'date': 'Aug 4 16:56', - 'name': 'dm-10', 'dir': '/tmp', 'raw_entry': - 'brw-rw----. 1 0 6 253, 10 Aug 4 16:56 dm-10' - } - assert listing['dm-10']['type'] == 'b' - assert listing['dm-10']['major'] == 253 - assert listing['dm-10']['minor'] == 10 - assert listing['control']['type'] == 'c' - assert listing['control']['major'] == 10 - assert listing['control']['minor'] == 236 - assert listing['geany_socket.c46453c2']['type'] == 's' - assert listing['geany_socket.c46453c2']['size'] == 0 - assert listing['link with spaces']['type'] == 'l' - assert listing['link with spaces']['link'] == '../file with spaces' - - # Check that things that _shouldn't_ be there _aren't_ - assert 'size' not in listing['dm-10'] - assert 'size' not in listing['control'] - - # Tricky file names - assert 'File name with spaces in it!' in listing - assert 'Unicode ÅÍÎÏÓÔÒÚÆ☃ madness.txt' in listing - assert 'file_name_ending_with_colon:' in listing - assert dirs.dir_contains('/tmp', 'File name with spaces in it!') - assert dirs.dir_contains('/tmp', 'Unicode ÅÍÎÏÓÔÒÚÆ☃ madness.txt') - assert dirs.dir_contains('/tmp', 'file_name_ending_with_colon:') - - # For devices missing a comma in their 'size', size is also unconverted - assert 'block dev with no comma also valid' in listing - assert listing['block dev with no comma also valid']['size'] == 1048576 - assert 'major' not in listing['block dev with no comma also valid'] - assert 'minor' not in listing['block dev with no comma also valid'] - - # Extended ACLs - assert 'additional_ACLs' in listing - assert listing['additional_ACLs']['perms'] == 'rwxr-xr-x+' - - -def test_selinux_directory(): - dirs = FileListing(context_wrap(SELINUX_DIRECTORY)) - - # Test that one entry is exactly what we expect it to be. - expected = { - 'type': 'd', 'perms': 'rwxr-xr-x.', 'owner': 'root', 'group': 'root', - 'se_user': 'system_u', 'se_role': 'object_r', 'se_type': 'boot_t', - 'se_mls': 's0', 'name': 'grub2', 'raw_entry': - 'drwxr-xr-x. root root system_u:object_r:boot_t:s0 grub2', - 'dir': '/boot' - } - actual = dirs.dir_entry('/boot', 'grub2') - assert actual == expected - - -def test_files_created_with_selinux_disabled(): - dirs = FileListing(context_wrap(FILES_CREATED_WITH_SELINUX_DISABLED)) - - # Test that one entry is exactly what we expect it to be. - assert dirs.dir_entry('/dev/mapper', 'lv_cpwtk001_data01') == { - 'group': '0', 'name': 'lv_cpwtk001_data01', 'links': 1, 'perms': 'rwxrwxrwx', - 'raw_entry': 'lrwxrwxrwx 1 0 0 7 Apr 27 05:34 lv_cpwtk001_data01 -> ../dm-7', 'owner': '0', - 'link': '../dm-7', 'date': 'Apr 27 05:34', 'type': 'l', 'dir': '/dev/mapper', 'size': 7 - } - - -def test_single_directory_with_special_path(): - def _content_asserts(dirs, path): - assert path in dirs - assert path in dirs.listings - assert '/etc/pki/tls/certs' not in dirs - assert '/etc' not in dirs - assert dirs.listings[path]['name'] == path - - assert dirs.files_of(path) == ['cert.pem', 'openssl.cnf'] - assert dirs.dirs_of(path) == ['.', '..', 'certs', 'misc', 'private'] - - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la_.etc.pki.tls') - _content_asserts(FileListing(ctx), '/etc/pki/tls') - - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la_.etc.pki') - _content_asserts(FileListing(ctx), '/etc/pki') - - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la_.') - _content_asserts(FileListing(ctx), '/') - - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la_') - _content_asserts(FileListing(ctx), '/') - - ctx = context_wrap(SINGLE_DIRECTORY, path='ls_-la') - _content_asserts(FileListing(ctx), '/') diff --git a/insights/tests/test_file_permissions.py b/insights/tests/test_file_permissions.py deleted file mode 100644 index d5c1d9c890..0000000000 --- a/insights/tests/test_file_permissions.py +++ /dev/null @@ -1,128 +0,0 @@ -import pytest -from insights.util.file_permissions import FilePermissions -from insights.core import FileListing -from insights.tests import test_file_listing, context_wrap - -PERMISSIONS_TEST_EXCEPTION_VECTORS = [ - ('-rw------ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), - ('bash: ls: command not found', True), - ('-rw------ 1 root root 762 Se', True), - ('-rw------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw-------. 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw-------@ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw-------+ 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw-------* 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw-------asdf 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False), - ('-rw------- 1 ro:t root 762 Sep 23 002 /etc/ssh/sshd_config', True), - ('-rw------- 1 root r:ot 762 Sep 23 002 /etc/ssh/sshd_config', True), - ('-rwasdfas- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), - ('-rwx/----- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True), - ('/usr/bin/ls: cannot access /boot/grub2/grub.cfg: No such file or directory', True), - ('cannot access /boot/grub2/grub.cfg: No such file or directory', True), - ('No such file or directory', True), - ('adsf', True), -] - -PERMISSIONS_TEST_VECTORS = [ - ('-rw------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False, - 'rw-', '---', '---', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - True, True), - ('-rw------- 1 root root 762 Sep 23 002 /a path/with/spaces everywhere', False, - 'rw-', '---', '---', 'root', 'root', '/a path/with/spaces everywhere', - True, True, - True, True), - ('-rw------- 1 root root 762 Sep 23 002 no_slash_here', False, - 'rw-', '---', '---', 'root', 'root', 'no_slash_here', - True, True, - True, True), - ('-rw-------. 1 root root 4308 Apr 22 15:57 /etc/ssh/sshd_config', False, - 'rw-', '---', '---', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - True, True), - ('-rw-rw-rw-. 1 root root 4308 Apr 22 15:57 /etc/ssh/sshd_config', False, - 'rw-', 'rw-', 'rw-', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - False, False), - ('-rw-rw---- 1 root user 762 Sep 23 002 /etc/ssh/sshd_config', True, - 'rw-', 'rw-', '---', 'root', 'user', '/etc/ssh/sshd_config', - True, False, - False, False), - ('-rw------- 1 root user 762 Sep 23 002 /etc/ssh/sshd_config', False, - 'rw-', '---', '---', 'root', 'user', '/etc/ssh/sshd_config', - True, False, - True, True), - ('-rw------- 1 user root 762 Sep 23 002 /etc/ssh/sshd_config', False, - 'rw-', '---', '---', 'user', 'root', '/etc/ssh/sshd_config', - False, False, - False, False), - ('-rw-rw---- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True, - 'rw-', 'rw-', '---', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - True, True), - ('-rw-rw-r-- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True, - 'rw-', 'rw-', 'r--', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - False, True), - ('-rw-rw--w- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', True, - 'rw-', 'rw-', '-w-', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - True, False), - ('---------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config', False, - '---', '---', '---', 'root', 'root', '/etc/ssh/sshd_config', - True, True, - True, True), -] - - -def test_permissions(): - for vector in PERMISSIONS_TEST_VECTORS: - (line, with_group, - permissions_owner, permissions_group, permissions_other, owner, group, path, - owned_by_root_user, owned_by_root_user_and_group, - only_root_can_read, only_root_can_write) = vector - p = FilePermissions(line) - assert p.perms_owner == permissions_owner - assert p.perms_group == permissions_group - assert p.perms_other == permissions_other - assert p.owner == owner - assert p.group == group - assert p.owned_by('root', also_check_group=False) == owned_by_root_user - assert p.owned_by('root', also_check_group=True) == owned_by_root_user_and_group - assert p.only_root_can_read(root_group_can_read=with_group) == only_root_can_read - assert p.only_root_can_write(root_group_can_write=with_group) == only_root_can_write - assert p.all_zero() == all((p.perms_owner == '---', p.perms_group == '---', - p.perms_other == '---')) - assert p.owner_can_read() == ('r' in p.perms_owner) - assert p.owner_can_write() == ('w' in p.perms_owner) - assert p.owner_can_only_read() == ('r--' == p.perms_owner) - assert p.group_can_read() == ('r' in p.perms_group) - assert p.group_can_write() == ('w' in p.perms_group) - assert p.group_can_only_read() == ('r--' == p.perms_group) - assert p.others_can_read() == ('r' in p.perms_other) - assert p.others_can_write() == ('w' in p.perms_other) - assert p.others_can_only_read() == ('r--' == p.perms_other) - - -def test_permissions_invalid(): - for vector in PERMISSIONS_TEST_EXCEPTION_VECTORS: - garbage, should_raise = vector - if should_raise: - with pytest.raises(ValueError): - FilePermissions(garbage) - else: - # shouldn't raise an exception - FilePermissions(garbage) - - -def test_multiple_directories(): - dirs = FileListing(context_wrap(test_file_listing.MULTIPLE_DIRECTORIES)) - assert '/etc/sysconfig' in dirs - assert 'cbq' in dirs.dirs_of('/etc/sysconfig') - # drwxr-xr-x. 2 0 0 41 Jul 6 23:32 cbq - obj = FilePermissions.from_dict(dirs.path_entry('/etc/sysconfig/cbq')) - assert hasattr(obj, 'name') - assert obj.name == 'cbq' - assert obj.perms_owner == 'rwx' - assert obj.perms_group == 'r-x' - assert obj.perms_other == 'r-x'