From d6f13f5c054cb0f4f4a8921d82be6358ca5e5286 Mon Sep 17 00:00:00 2001 From: Ryan Blakley Date: Wed, 18 Jan 2023 21:12:23 -0500 Subject: [PATCH 01/14] Move remaining exceptions to the new exceptions module (#3656) * Moved the remaining exceptions that were defined in various other modules to the new separate exceptions module. That way all exceptions are defined in their own module. * Updated all imports to reference the new path. Signed-off-by: Ryan Blakley --- docs/api_index.rst | 12 +++- insights/__init__.py | 4 +- .../client/apps/malware_detection/__init__.py | 3 +- insights/collect.py | 7 ++- insights/combiners/cloud_instance.py | 6 +- insights/core/__init__.py | 3 +- insights/core/archives.py | 16 +---- insights/core/dr.py | 11 +--- insights/core/exceptions.py | 63 +++++++++++++++++++ insights/core/hydration.py | 11 ++-- insights/core/plugins.py | 21 +------ insights/core/serde.py | 3 +- insights/core/spec_factory.py | 4 +- .../container/containers_inspect.py | 4 +- .../client/apps/test_malware_detection.py | 3 +- .../tests/combiners/test_cloud_instance.py | 20 +++--- insights/tests/core/test_plugins.py | 12 ++-- .../datasources/test_datasource_timeout.py | 3 +- insights/tests/parsers/test_awx_manage.py | 3 +- insights/tests/parsers/test_azure_instance.py | 3 +- .../tests/parsers/test_azure_instance_type.py | 3 +- .../tests/parsers/test_corosync_cmapctl.py | 3 +- insights/tests/parsers/test_dotnet.py | 3 +- insights/tests/parsers/test_du.py | 3 +- insights/tests/parsers/test_firewall_cmd.py | 3 +- .../parsers/test_numeric_user_group_name.py | 3 +- insights/tests/parsers/test_postconf.py | 3 +- .../test_puppet_ca_cert_expire_date.py | 3 +- .../test_satellite_content_hosts_count.py | 3 +- .../test_satellite_postgresql_query.py | 3 +- .../tests/parsers/test_ssl_certificate.py | 3 +- insights/tests/parsers/test_systemd_config.py | 3 +- insights/tests/test_add_exception.py | 3 +- insights/tests/test_collect.py | 2 +- insights/tests/test_commandparser.py | 5 +- insights/tests/test_serde.py | 20 +++--- insights/tests/test_specs.py | 17 +++-- insights/tests/test_subproc.py | 5 +- insights/util/subproc.py | 38 +---------- 39 files changed, 163 insertions(+), 175 deletions(-) diff --git a/docs/api_index.rst b/docs/api_index.rst index ce4d689fa8..da0a097d89 100644 --- a/docs/api_index.rst +++ b/docs/api_index.rst @@ -30,6 +30,14 @@ insights.core.dr :members: :exclude-members: requires, optional, metadata, group, tags +insights.core.exceptions +------------------------ + +.. automodule:: insights.core.exceptions + :members: + :show-inheritance: + :undoc-members: + insights.core.filters --------------------- @@ -74,8 +82,8 @@ insights.parsers ---------------- .. automodule:: insights.parsers - :members: ParseException, SkipException, calc_offset, get_active_lines, - keyword_search, optlist_to_dict, parse_delimited_table, + :members: calc_offset, get_active_lines, keyword_search, + optlist_to_dict, parse_delimited_table, parse_fixed_table, split_kv_pairs, unsplit_lines :show-inheritance: :undoc-members: diff --git a/insights/__init__.py b/insights/__init__.py index 33a76fe637..16247cb42e 100644 --- a/insights/__init__.py +++ b/insights/__init__.py @@ -30,10 +30,10 @@ from insights.core import (CommandParser, ContainerParser, FileListing, IniConfigFile, JSONParser, LegacyItemAccess, # noqa: F401 LogFileOutput, Parser, Scannable, SysconfigOptions, Syslog, XMLParser, YAMLParser, dr, # noqa: F401 taglang) -from insights.core.archives import COMPRESSION_TYPES, InvalidArchive, InvalidContentType, extract +from insights.core.archives import COMPRESSION_TYPES, extract from insights.core.context import (ClusterArchiveContext, ExecutionContext, HostContext, # noqa: F401 HostArchiveContext, SerializedArchiveContext) -from insights.core.exceptions import SkipComponent # noqa: F401 +from insights.core.exceptions import InvalidArchive, InvalidContentType, SkipComponent # noqa: F401 from insights.core.filters import add_filter, apply_filters, get_filters # noqa: F401 from insights.core.hydration import create_context, initialize_broker # noqa: F401 from insights.core.plugins import (combiner, condition, datasource, fact, incident, make_fail, make_fingerprint, # noqa: F401 diff --git a/insights/client/apps/malware_detection/__init__.py b/insights/client/apps/malware_detection/__init__.py index 1accea5f6f..7f391f5a04 100644 --- a/insights/client/apps/malware_detection/__init__.py +++ b/insights/client/apps/malware_detection/__init__.py @@ -21,7 +21,8 @@ from insights.client.utilities import ( generate_machine_id, write_data_to_file, get_time ) -from insights.util.subproc import call, CalledProcessError +from insights.core.exceptions import CalledProcessError +from insights.util.subproc import call logger = logging.getLogger(__name__) MIN_YARA_VERSION = "4.1.0" diff --git a/insights/collect.py b/insights/collect.py index c7176206f4..ac14dc296f 100755 --- a/insights/collect.py +++ b/insights/collect.py @@ -17,11 +17,12 @@ from datetime import datetime -from insights import apply_configs, apply_default_enabled, dr, get_pool -from insights.core import blacklist, filters +from insights import apply_configs, apply_default_enabled, get_pool +from insights.core import blacklist, dr, filters +from insights.core.exceptions import CalledProcessError from insights.core.serde import Hydration from insights.util import fs -from insights.util.subproc import call, CalledProcessError +from insights.util.subproc import call SAFE_ENV = { "PATH": os.path.pathsep.join([ diff --git a/insights/combiners/cloud_instance.py b/insights/combiners/cloud_instance.py index 8b50bd4b40..77787ec86e 100644 --- a/insights/combiners/cloud_instance.py +++ b/insights/combiners/cloud_instance.py @@ -13,13 +13,13 @@ * :py:class:`insights.parsers.subscription_manager.SubscriptionManagerFacts` """ -from insights import SkipComponent -from insights.core.plugins import combiner, ContentException +from insights.combiners.cloud_provider import CloudProvider +from insights.core.exceptions import ContentException, SkipComponent +from insights.core.plugins import combiner from insights.parsers.aws_instance_id import AWSInstanceIdDoc from insights.parsers.azure_instance import AzureInstanceID, AzureInstanceType from insights.parsers.gcp_instance_type import GCPInstanceType from insights.parsers.subscription_manager import SubscriptionManagerFacts -from insights.combiners.cloud_provider import CloudProvider # "google" is used in class:`insights.combiners.cloud_provider.CloudProvider`. diff --git a/insights/core/__init__.py b/insights/core/__init__.py index ae8d2fde6f..0a96d9a554 100644 --- a/insights/core/__init__.py +++ b/insights/core/__init__.py @@ -14,8 +14,7 @@ from insights.contrib.ConfigParser import NoOptionError, NoSectionError from insights.core import ls_parser -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.core.serde import deserializer, serializer from insights.parsr import iniparser from insights.parsr.query import Directive, Entry, Result, Section, compile_queries diff --git a/insights/core/archives.py b/insights/core/archives.py index 4ec97f8637..97fa86e529 100644 --- a/insights/core/archives.py +++ b/insights/core/archives.py @@ -3,7 +3,10 @@ import logging import os import tempfile + from contextlib import contextmanager + +from insights.core.exceptions import InvalidContentType from insights.util import fs, subproc, which from insights.util.content_type import from_file as content_type_from_file @@ -13,19 +16,6 @@ COMPRESSION_TYPES = ("zip", "tar", "gz", "bz2", "xz") -class InvalidArchive(Exception): - def __init__(self, msg): - super(InvalidArchive, self).__init__(msg) - self.msg = msg - - -class InvalidContentType(InvalidArchive): - def __init__(self, content_type): - self.msg = 'Invalid content type: "%s"' % content_type - super(InvalidContentType, self).__init__(self.msg) - self.content_type = content_type - - class ZipExtractor(object): def __init__(self, timeout=None): self.content_type = "application/zip" diff --git a/insights/core/dr.py b/insights/core/dr.py index c15a95f132..a90c76aeb2 100644 --- a/insights/core/dr.py +++ b/insights/core/dr.py @@ -64,7 +64,7 @@ def add(a, b): from insights.contrib import importlib from insights.contrib.toposort import toposort_flatten -from insights.core.exceptions import SkipComponent, ParseException +from insights.core.exceptions import MissingRequirements, ParseException, SkipComponent from insights.util import defaults, enum, KeyPassingDefaultDict log = logging.getLogger(__name__) @@ -222,15 +222,6 @@ def add_dependency(component, dep): get_delegate(component).add_dependency(dep) -class MissingRequirements(Exception): - """ - Raised during evaluation if a component's dependencies aren't met. - """ - def __init__(self, requirements): - self.requirements = requirements - super(MissingRequirements, self).__init__(requirements) - - def get_name(component): """ Attempt to get the string name of component, including module and class if diff --git a/insights/core/exceptions.py b/insights/core/exceptions.py index 51e2ce5643..ae71bffd3b 100644 --- a/insights/core/exceptions.py +++ b/insights/core/exceptions.py @@ -1,3 +1,42 @@ +class CalledProcessError(Exception): + """ + Raised if call fails. + + Parameters: + returncode (int): The return code of the process executing the command. + cmd (str): The command that was executed. + output (str): Any output the command produced. + """ + + def __init__(self, returncode, cmd, output=None): + self.returncode = returncode + self.cmd = cmd + self.output = output + super(CalledProcessError, self).__init__(returncode, cmd, output) + + def __unicode__(self): + name = self.__class__.__name__ + rc = self.returncode + cmd = self.cmd + output = self.output + return '<{}({}, {!r}, {!r})>'.format(name, rc, cmd, output) + + +class InvalidArchive(Exception): + def __init__(self, msg): + super(InvalidArchive, self).__init__(msg) + self.msg = msg + + +class MissingRequirements(Exception): + """ + Raised during evaluation if a component's dependencies aren't met. + """ + def __init__(self, requirements): + self.requirements = requirements + super(MissingRequirements, self).__init__(requirements) + + class ParseException(Exception): """ Exception that should be thrown from parsers that encounter @@ -16,6 +55,30 @@ class SkipComponent(Exception): pass +class TimeoutException(Exception): + """ Raised whenever a :class:`datasource` hits the set timeout value. """ + pass + + +class ValidationException(Exception): + def __init__(self, msg, r=None): + if r: + msg = "%s: %s" % (msg, r) + super(ValidationException, self).__init__(msg) + + +class ContentException(SkipComponent): + """ Raised whenever a :class:`datasource` fails to get data. """ + pass + + +class InvalidContentType(InvalidArchive): + def __init__(self, content_type): + self.msg = 'Invalid content type: "%s"' % content_type + super(InvalidContentType, self).__init__(self.msg) + self.content_type = content_type + + class SkipException(SkipComponent): """ Exception that should be thrown from parsers that are explicitly diff --git a/insights/core/hydration.py b/insights/core/hydration.py index c9310d5f25..9a0d7c5d1f 100644 --- a/insights/core/hydration.py +++ b/insights/core/hydration.py @@ -2,11 +2,10 @@ import os from insights.core import archives, dr -from insights.core.serde import Hydration -from insights.core.context import (ClusterArchiveContext, - ExecutionContextMeta, - HostArchiveContext, +from insights.core.context import (ClusterArchiveContext, ExecutionContextMeta, HostArchiveContext, SerializedArchiveContext) +from insights.core.exceptions import InvalidArchive +from insights.core.serde import Hydration log = logging.getLogger(__name__) @@ -40,7 +39,7 @@ def identify(files): common_path = os.path.dirname(os.path.commonprefix(files)) if not common_path: - raise archives.InvalidArchive("Unable to determine common path") + raise InvalidArchive("Unable to determine common path") return common_path, HostArchiveContext @@ -55,7 +54,7 @@ def create_context(path, context=None): all_files = list(get_all_files(path)) if not all_files: - raise archives.InvalidArchive("No files in archive") + raise InvalidArchive("No files in archive") common_path, ctx = identify(all_files) context = context or ctx diff --git a/insights/core/plugins.py b/insights/core/plugins.py index 9a4c84c4b3..adaf13d778 100644 --- a/insights/core/plugins.py +++ b/insights/core/plugins.py @@ -36,22 +36,12 @@ from insights import settings from insights.core import dr from insights.core.context import HostContext -from insights.core.exceptions import SkipComponent -from insights.util.subproc import CalledProcessError +from insights.core.exceptions import (CalledProcessError, ContentException, SkipComponent, TimeoutException, + ValidationException) log = logging.getLogger(__name__) -class ContentException(SkipComponent): - """ Raised whenever a :class:`datasource` fails to get data. """ - pass - - -class TimeoutException(Exception): - """ Raised whenever a :class:`datasource` hits the set timeout value. """ - pass - - class PluginType(dr.ComponentType): """ PluginType is the base class of plugin types like datasource, rule, etc. @@ -393,13 +383,6 @@ def is_component(obj): return bool(dr.get_component_type(obj)) -class ValidationException(Exception): - def __init__(self, msg, r=None): - if r: - msg = "%s: %s" % (msg, r) - super(ValidationException, self).__init__(msg) - - class Response(dict): """ Response is the base class of response types that can be returned from diff --git a/insights/core/serde.py b/insights/core/serde.py index 9c0138aa5d..04e0168e0d 100644 --- a/insights/core/serde.py +++ b/insights/core/serde.py @@ -11,10 +11,12 @@ import os import time import traceback + from glob import glob from functools import partial from insights.core import dr +from insights.core.exceptions import ContentException from insights.util import fs log = logging.getLogger(__name__) @@ -165,7 +167,6 @@ def hydrate(self, broker=None): Loads a Broker from a previously saved one. A Broker is created if one isn't provided. """ - from insights.core.spec_factory import ContentException broker = broker or dr.Broker() for path in glob(os.path.join(self.meta_data, "*")): diff --git a/insights/core/spec_factory.py b/insights/core/spec_factory.py index 18a4999c32..5d433f9230 100644 --- a/insights/core/spec_factory.py +++ b/insights/core/spec_factory.py @@ -14,9 +14,9 @@ from insights.core import blacklist, dr from insights.core.context import ExecutionContext, FSRoots, HostContext -from insights.core.exceptions import SkipComponent +from insights.core.exceptions import ContentException, SkipComponent from insights.core.filters import _add_filter, get_filters -from insights.core.plugins import ContentException, component, datasource, is_datasource +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.subproc import Pipeline diff --git a/insights/specs/datasources/container/containers_inspect.py b/insights/specs/datasources/container/containers_inspect.py index db7e0ecbd7..83f09a5b77 100644 --- a/insights/specs/datasources/container/containers_inspect.py +++ b/insights/specs/datasources/container/containers_inspect.py @@ -5,9 +5,9 @@ import os from insights.core.context import HostContext -from insights.core.exceptions import SkipComponent +from insights.core.exceptions import ContentException, SkipComponent from insights.core.filters import get_filters -from insights.core.plugins import datasource, ContentException +from insights.core.plugins import datasource from insights.core.spec_factory import DatasourceProvider, foreach_execute from insights.specs import Specs from insights.specs.datasources.container import running_rhel_containers diff --git a/insights/tests/client/apps/test_malware_detection.py b/insights/tests/client/apps/test_malware_detection.py index 44bd7dcd82..51816556b5 100644 --- a/insights/tests/client/apps/test_malware_detection.py +++ b/insights/tests/client/apps/test_malware_detection.py @@ -16,9 +16,10 @@ from urllib.parse import quote as urlencode # python 3 from insights.client.apps.manifests import manifests, content_types -from insights.util.subproc import call, CalledProcessError from insights.client.config import InsightsConfig +from insights.core.exceptions import CalledProcessError from insights.tests.helpers import getenv_bool +from insights.util.subproc import call from insights.client.apps.malware_detection import ( DEFAULT_MALWARE_CONFIG, MalwareDetectionClient, InsightsConnection, diff --git a/insights/tests/combiners/test_cloud_instance.py b/insights/tests/combiners/test_cloud_instance.py index 9ca952d728..cbe18cab46 100644 --- a/insights/tests/combiners/test_cloud_instance.py +++ b/insights/tests/combiners/test_cloud_instance.py @@ -1,21 +1,21 @@ -import pytest import doctest -from insights import SkipComponent -from insights.core.plugins import ContentException -from insights.parsers.installed_rpms import InstalledRpms -from insights.parsers.gcp_instance_type import GCPInstanceType -from insights.parsers.aws_instance_id import AWSInstanceIdDoc -from insights.parsers.azure_instance import AzureInstanceID, AzureInstanceType -from insights.parsers.subscription_manager import SubscriptionManagerFacts +import pytest + from insights.combiners import cloud_instance from insights.combiners.cloud_provider import CloudProvider from insights.combiners.cloud_instance import CloudInstance +from insights.core.exceptions import ContentException, SkipComponent +from insights.parsers.aws_instance_id import AWSInstanceIdDoc +from insights.parsers.azure_instance import AzureInstanceID, AzureInstanceType +from insights.parsers.gcp_instance_type import GCPInstanceType +from insights.parsers.installed_rpms import InstalledRpms +from insights.parsers.subscription_manager import SubscriptionManagerFacts from insights.tests import context_wrap -from insights.tests.parsers.test_gcp_instance_type import GOOGLE_TYPE_1 +from insights.tests.combiners.test_cloud_provider import RPMS_AWS, RPMS_GOOGLE, RPMS_AZURE from insights.tests.parsers.test_aws_instance_id import AWS_ID_DOC from insights.tests.parsers.test_azure_instance import AZURE_ID, AZURE_TYPE_2 +from insights.tests.parsers.test_gcp_instance_type import GOOGLE_TYPE_1 from insights.tests.parsers.test_subscription_manager import INPUT_NORMAL_1 -from insights.tests.combiners.test_cloud_provider import RPMS_AWS, RPMS_GOOGLE, RPMS_AZURE GOOGLE_RHSM_FACTS = """ gcp_instance_id: 567890567890 diff --git a/insights/tests/core/test_plugins.py b/insights/tests/core/test_plugins.py index 7c40af24f4..1320bbf82c 100644 --- a/insights/tests/core/test_plugins.py +++ b/insights/tests/core/test_plugins.py @@ -1,6 +1,8 @@ import json import pytest + from insights.core import plugins +from insights.core.exceptions import ValidationException def test_validate_good_response(): @@ -37,21 +39,21 @@ def test_validate_good_response(): def test_disallow_invalid_keys(): for bad in [[], None, set(), "", 1, lambda x: x]: - with pytest.raises(plugins.ValidationException): + with pytest.raises(ValidationException): plugins.make_response(bad) - with pytest.raises(plugins.ValidationException): + with pytest.raises(ValidationException): plugins.make_metadata_key(bad, "foo") def test_disallow_type_key(): - with pytest.raises(plugins.ValidationException): + with pytest.raises(ValidationException): plugins.make_response("foo", type="dance off") def test_missing_error_key(): - with pytest.raises(plugins.ValidationException): + with pytest.raises(ValidationException): plugins.make_response(None, foo="bar") - with pytest.raises(plugins.ValidationException): + with pytest.raises(ValidationException): plugins.make_metadata_key(None, "foo") diff --git a/insights/tests/datasources/test_datasource_timeout.py b/insights/tests/datasources/test_datasource_timeout.py index 485bbe757d..a4da9a1e61 100644 --- a/insights/tests/datasources/test_datasource_timeout.py +++ b/insights/tests/datasources/test_datasource_timeout.py @@ -3,7 +3,8 @@ from insights.core import dr from insights.core.dr import run from insights.core.context import HostContext, SosArchiveContext -from insights.core.plugins import TimeoutException, datasource, make_info, rule +from insights.core.exceptions import TimeoutException +from insights.core.plugins import datasource, make_info, rule from insights.core.spec_factory import DatasourceProvider, RegistryPoint, SpecSet, foreach_execute diff --git a/insights/tests/parsers/test_awx_manage.py b/insights/tests/parsers/test_awx_manage.py index 6bc8e4e293..9145d82d5b 100644 --- a/insights/tests/parsers/test_awx_manage.py +++ b/insights/tests/parsers/test_awx_manage.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import awx_manage from insights.parsers.awx_manage import AnsibleTowerLicenseType, AnsibleTowerLicense, AwxManagePrintSettings from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_azure_instance.py b/insights/tests/parsers/test_azure_instance.py index 53b0989444..a88299a7e5 100644 --- a/insights/tests/parsers/test_azure_instance.py +++ b/insights/tests/parsers/test_azure_instance.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import azure_instance from insights.parsers.azure_instance import AzureInstanceID, AzureInstancePlan, AzureInstanceType from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_azure_instance_type.py b/insights/tests/parsers/test_azure_instance_type.py index 4c04fecd42..3e2c5b685b 100644 --- a/insights/tests/parsers/test_azure_instance_type.py +++ b/insights/tests/parsers/test_azure_instance_type.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import azure_instance_type from insights.parsers.azure_instance_type import AzureInstanceType from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_corosync_cmapctl.py b/insights/tests/parsers/test_corosync_cmapctl.py index 850d6dfb13..2c5b9cb2dc 100644 --- a/insights/tests/parsers/test_corosync_cmapctl.py +++ b/insights/tests/parsers/test_corosync_cmapctl.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import corosync_cmapctl from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_dotnet.py b/insights/tests/parsers/test_dotnet.py index 104f5e1340..3ddb8600ed 100644 --- a/insights/tests/parsers/test_dotnet.py +++ b/insights/tests/parsers/test_dotnet.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import dotnet from insights.parsers.dotnet import DotNetVersion, ContainerDotNetVersion from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_du.py b/insights/tests/parsers/test_du.py index c72cafc471..75782e7de1 100644 --- a/insights/tests/parsers/test_du.py +++ b/insights/tests/parsers/test_du.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import du from insights.parsers.du import DiskUsage from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_firewall_cmd.py b/insights/tests/parsers/test_firewall_cmd.py index 4890cd20c6..5af93b9620 100644 --- a/insights/tests/parsers/test_firewall_cmd.py +++ b/insights/tests/parsers/test_firewall_cmd.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException from insights.parsers import firewall_cmd from insights.parsers.firewall_cmd import FirewallCmdListALLZones from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_numeric_user_group_name.py b/insights/tests/parsers/test_numeric_user_group_name.py index 53802d3279..bee6636349 100644 --- a/insights/tests/parsers/test_numeric_user_group_name.py +++ b/insights/tests/parsers/test_numeric_user_group_name.py @@ -1,5 +1,4 @@ -from insights.core.exceptions import ParseException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException from insights.parsers.numeric_user_group_name import NumericUserGroupName from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_postconf.py b/insights/tests/parsers/test_postconf.py index 630b6872a4..d7dfc19acc 100644 --- a/insights/tests/parsers/test_postconf.py +++ b/insights/tests/parsers/test_postconf.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, SkipException from insights.parsers import postconf from insights.parsers.postconf import PostconfBuiltin, Postconf, _Postconf from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_puppet_ca_cert_expire_date.py b/insights/tests/parsers/test_puppet_ca_cert_expire_date.py index 20b96a8fe3..d8507240c7 100644 --- a/insights/tests/parsers/test_puppet_ca_cert_expire_date.py +++ b/insights/tests/parsers/test_puppet_ca_cert_expire_date.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import puppet_ca_cert_expire_date from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_satellite_content_hosts_count.py b/insights/tests/parsers/test_satellite_content_hosts_count.py index 8a1a89ecdd..43043bd46f 100644 --- a/insights/tests/parsers/test_satellite_content_hosts_count.py +++ b/insights/tests/parsers/test_satellite_content_hosts_count.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import satellite_content_hosts_count from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_satellite_postgresql_query.py b/insights/tests/parsers/test_satellite_postgresql_query.py index 2f532f11d9..d1d70ce5cb 100644 --- a/insights/tests/parsers/test_satellite_postgresql_query.py +++ b/insights/tests/parsers/test_satellite_postgresql_query.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipException from insights.parsers import satellite_postgresql_query from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_ssl_certificate.py b/insights/tests/parsers/test_ssl_certificate.py index 2f3634e369..322115fa07 100644 --- a/insights/tests/parsers/test_ssl_certificate.py +++ b/insights/tests/parsers/test_ssl_certificate.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipComponent, SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, ParseException, SkipComponent, SkipException from insights.parsers import ssl_certificate from insights.tests import context_wrap diff --git a/insights/tests/parsers/test_systemd_config.py b/insights/tests/parsers/test_systemd_config.py index 296518b5b9..4932ca33d0 100644 --- a/insights/tests/parsers/test_systemd_config.py +++ b/insights/tests/parsers/test_systemd_config.py @@ -1,8 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException, SkipException from insights.parsers.systemd import config from insights.tests import context_wrap diff --git a/insights/tests/test_add_exception.py b/insights/tests/test_add_exception.py index a09441bef1..c0f6bb4b78 100644 --- a/insights/tests/test_add_exception.py +++ b/insights/tests/test_add_exception.py @@ -1,5 +1,6 @@ from insights.core import dr -from insights.core.plugins import datasource, rule, make_info, ContentException +from insights.core.exceptions import ContentException +from insights.core.plugins import datasource, rule, make_info from insights.core.spec_factory import RegistryPoint, SpecSet diff --git a/insights/tests/test_collect.py b/insights/tests/test_collect.py index dcb813967b..1cd78569f2 100644 --- a/insights/tests/test_collect.py +++ b/insights/tests/test_collect.py @@ -2,7 +2,7 @@ from insights.collect import _parse_broker_exceptions from insights.core.dr import Broker -from insights.core.plugins import ContentException +from insights.core.exceptions import ContentException def test_parse_broker_exceptions_no_errors(): diff --git a/insights/tests/test_commandparser.py b/insights/tests/test_commandparser.py index d74354f55e..9100d14c67 100644 --- a/insights/tests/test_commandparser.py +++ b/insights/tests/test_commandparser.py @@ -1,7 +1,8 @@ +import pytest + from insights.core import CommandParser +from insights.core.exceptions import ContentException from insights.tests import context_wrap -from insights.core.plugins import ContentException -import pytest CMF = "blah: Command not found" NO_FILES_FOUND = "No files found for docker.service" diff --git a/insights/tests/test_serde.py b/insights/tests/test_serde.py index 4557f850b0..ee28bebfc4 100644 --- a/insights/tests/test_serde.py +++ b/insights/tests/test_serde.py @@ -1,20 +1,14 @@ -import os import json +import os from tempfile import mkdtemp -from insights import dr -from insights.core.plugins import (component, - datasource, - rule, - make_info, - ContentException) -from insights.core.serde import (serializer, - deserializer, - Hydration, - marshal, - unmarshal) -from insights.util import fs + +from insights.core import dr +from insights.core.exceptions import ContentException +from insights.core.plugins import component, datasource, make_info, rule +from insights.core.serde import Hydration, deserializer, marshal, serializer, unmarshal from insights.core.spec_factory import RegistryPoint, SpecSet +from insights.util import fs class Foo(object): diff --git a/insights/tests/test_specs.py b/insights/tests/test_specs.py index 3d035c3747..b9f3c5df6e 100644 --- a/insights/tests/test_specs.py +++ b/insights/tests/test_specs.py @@ -1,15 +1,14 @@ +import glob import os +import pytest +import tempfile -from insights import add_filter, dr -from insights.core import Parser +from insights.core import Parser, dr from insights.core.context import HostContext -from insights.core.plugins import ContentException -from insights.core.spec_factory import (SpecSet, DatasourceProvider, - RegistryPoint, simple_file, - simple_command, glob_file) -import tempfile -import pytest -import glob +from insights.core.exceptions import ContentException +from insights.core.filters import add_filter +from insights.core.spec_factory import (DatasourceProvider, RegistryPoint, SpecSet, glob_file, simple_command, + simple_file) here = os.path.abspath(os.path.dirname(__file__)) diff --git a/insights/tests/test_subproc.py b/insights/tests/test_subproc.py index 75b0cd8ce3..a480a43afd 100644 --- a/insights/tests/test_subproc.py +++ b/insights/tests/test_subproc.py @@ -1,7 +1,8 @@ -import sys import pytest import shlex +import sys +from insights.core.exceptions import CalledProcessError from insights.util import subproc @@ -20,5 +21,5 @@ def test_call_list_of_lists(): def test_call_timeout(): # Timeouts don't work on OS X if sys.platform != "darwin": - with pytest.raises(subproc.CalledProcessError): + with pytest.raises(CalledProcessError): subproc.call('sleep 3', timeout=1) diff --git a/insights/util/subproc.py b/insights/util/subproc.py index cf7fec50f5..547ff0e5ca 100644 --- a/insights/util/subproc.py +++ b/insights/util/subproc.py @@ -4,49 +4,15 @@ import signal import six import sys + from subprocess import Popen, PIPE, STDOUT +from insights.core.exceptions import CalledProcessError from insights.util import which log = logging.getLogger(__name__) -class CalledProcessError(Exception): - """Raised if call fails. - - Parameters - ---------- - returncode : int - The return code of the process executing the command. - cmd : str - The command that was executed. - output : str - Any output the command produced. - - Attributes - ---------- - returncode : int - The return code of the process executing the command. - cmd : str - The command that was executed. - output : str - Any output the command produced. - """ - - def __init__(self, returncode, cmd, output=None): - self.returncode = returncode - self.cmd = cmd - self.output = output - super(CalledProcessError, self).__init__(returncode, cmd, output) - - def __unicode__(self): - name = self.__class__.__name__ - rc = self.returncode - cmd = self.cmd - output = self.output - return '<{}({}, {!r}, {!r})>'.format(name, rc, cmd, output) - - class Pipeline(object): """ Connect a list of lists of commands together with the stdout of one as the From 39ababca74057fdf8039b3d9f369c010382bd02d Mon Sep 17 00:00:00 2001 From: Chenlizhong Date: Thu, 19 Jan 2023 10:28:22 +0800 Subject: [PATCH 02/14] feat: add JbossRuntimeVersions parser (#3639) * feat: add JbossRuntimeVersions parser Signed-off-by: Chen lizhong * fix: implement iterator and get for JbossRuntimeVersions class Signed-off-by: Chenlizhong * fix: fix the error in python2 Signed-off-by: Chenlizhong * fix: use Context class directly instead of tests/context_wrap Signed-off-by: Chenlizhong * fix: use nametuple and private function to parse the line of version Signed-off-by: Chenlizhong * resort the importings Signed-off-by: Xiangce Liu --- insights/parsers/jboss_version.py | 143 +++++++++++++------ insights/tests/parsers/test_jboss_version.py | 50 ++++++- 2 files changed, 144 insertions(+), 49 deletions(-) diff --git a/insights/parsers/jboss_version.py b/insights/parsers/jboss_version.py index 3cfd79febd..1c97a7959c 100644 --- a/insights/parsers/jboss_version.py +++ b/insights/parsers/jboss_version.py @@ -1,75 +1,126 @@ """ -JBoss version - File ``$JBOSS_HOME/version.txt`` -================================================ - -This module provides plugins access to file ``$JBOSS_HOME/version.txt`` - -Typical content of file ``$JBOSS_HOME/version.txt`` is:: - - Red Hat JBoss Enterprise Application Platform - Version 6.4.3.GA - -This module parses the file content and stores data in the dict ``self.parsed``. -The version info can also be got via ``obj.major`` and ``obj.minor``, etc. - -Examples: - >>> jboss_version.file_path - '/home/test/jboss/jboss-eap-6.4/version.txt' - >>> jboss_version.raw - 'Red Hat JBoss Enterprise Application Platform - Version 6.4.3.GA' - >>> jboss_version.major - 6 - >>> jboss_version.minor - 4 - >>> jboss_version.release - 3 - >>> jboss_version.version - '6.4.3' - >>> jboss_version.code_name - 'GA' +JBoss version +============= +Provide information about the versions of all running Jboss on a system. """ -from .. import Parser, parser -from ..specs import Specs +import json + +from collections import namedtuple +from insights import Parser, parser +from insights.specs import Specs + +# define namedtuple to store the property of version +_VersionNameTuple = namedtuple("_VersionNameTuple", ["file_path", "product", "version", "code_name", "major", "minor", "release"]) + + +def _get_version_tuple(version_line, i_file_path): + """ + Perform the version line parsing, returning a nametuple of the values of one jboss version + """ + product, _, version_name = [v.strip() for v in version_line.partition("- Version")] + if " GA" in version_name: + # handle Red Hat JBoss Web Server - Version 5.6 GA + version = version_name.split(' GA')[0] + code_name = "GA" + updated_version = version + ".0" + major, minor, release = updated_version.split('.')[0:3] + else: + # add empty code name for Red Hat Data Grid - Version 7.3.0 + version_name = version_name.strip() + "." + major, minor, release, code_name = version_name.split(".")[0:4] + version = '.'.join([major, minor, release]) + + return _VersionNameTuple(i_file_path, product, version, code_name, int(major), int(minor), int(release)) @parser(Specs.jboss_version) class JbossVersion(Parser): - """Parses the content of file ``$JBOSS_HOME/version.txt``.""" + """ + This class is to access to file ``$JBOSS_HOME/version.txt`` + + Typical content of file ``$JBOSS_HOME/version.txt`` is:: + + Red Hat JBoss Enterprise Application Platform - Version 6.4.3.GA + + This class parses the file content and stores data in the dict ``self.parsed``. + The version info can also be got via ``obj.major`` and ``obj.minor``, etc. + + Examples: + >>> jboss_version.file_path + '/home/test/jboss/jboss-eap-6.4/version.txt' + >>> jboss_version.raw + 'Red Hat JBoss Enterprise Application Platform - Version 6.4.3.GA' + >>> jboss_version.major + 6 + >>> jboss_version.minor + 4 + >>> jboss_version.release + 3 + >>> jboss_version.version + '6.4.3' + >>> jboss_version.code_name + 'GA' + """ def parse_content(self, content): self.raw = content[0] - product, _, version_name = [v.strip() for v in content[0].partition("- Version")] - version, code_name = version_name.strip().rsplit(".", 1) - major, minor, release = version.split(".") - self.parsed = { - "product": product, - "version": version, - "code_name": code_name, - "major": int(major), - "minor": int(minor), - "release": int(release) - } + self._parsed = _get_version_tuple(content[0], self.file_path) + + @property + def product(self): + """string: the version of this running JBoss progress.""" + return self._parsed.product @property def version(self): """string: the version of this running JBoss progress.""" - return self.parsed["version"] + return self._parsed.version @property def major(self): """int: the major version of this running JBoss progress.""" - return self.parsed["major"] + return self._parsed.major @property def minor(self): """int: the minor version of this running JBoss progress.""" - return self.parsed["minor"] + return self._parsed.minor @property def release(self): """int: release of this running JBoss progress.""" - return self.parsed["release"] + return self._parsed.release @property def code_name(self): """string: code name of this running JBoss progress.""" - return self.parsed["code_name"] + return self._parsed.code_name + + +@parser(Specs.jboss_runtime_versions) +class JbossRuntimeVersions(Parser, list): + """ + This class is to access to file ``data/insights_commands/jboss_versions`` + + Typical content of file ``data/insights_commands/jboss_versions`` is:: + + {"/opt/jboss-datagrid-7.3.0-server": "Red Hat Data Grid - Version 7.3.0"} + + This class parses the file content and stores data in the list. + + Examples: + >>> len(all_jboss_versions) + 1 + >>> all_jboss_versions[0].major + 7 + >>> all_jboss_versions[0].minor + 3 + >>> all_jboss_versions[0].release + 0 + """ + + def parse_content(self, content): + jboss_version_dict = json.loads(' '.join(content)) + for j_path, version_content in jboss_version_dict.items(): + lines = version_content.strip().splitlines() + self.append(_get_version_tuple(lines[0], j_path)) diff --git a/insights/tests/parsers/test_jboss_version.py b/insights/tests/parsers/test_jboss_version.py index 56547a7acd..3e3555e427 100644 --- a/insights/tests/parsers/test_jboss_version.py +++ b/insights/tests/parsers/test_jboss_version.py @@ -1,4 +1,4 @@ -from insights.parsers.jboss_version import JbossVersion +from insights.parsers.jboss_version import JbossVersion, JbossRuntimeVersions from insights.tests import context_wrap import doctest from insights.parsers import jboss_version @@ -34,11 +34,55 @@ def test_jboss7(): assert release7.release == 0 +SINGLE_JBOSS = """ +{"/opt/jboss-datagrid-7.3.0-server": "Red Hat Data Grid - Version 7.3.0"} +""" + +MULTI_JBOSS = """ +{"/opt/jboss": "Red Hat JBoss Enterprise Application Platform - Version 7.3.0.GA\n", "/opt/jboss-sss": "Red Hat Single Sign-On - Version 7.4.10.GA\n", "/opt/jboss-keycloak": "Keycloak - Version 3.4.3.Final\n"} +""" +WEB_SERVER_RUNTIME = """ +{"/opt/jboss-web-server": "Red Hat JBoss Web Server - Version 5.6 GA\n\nJava Components:\nApache Tomcat 9.0.50-3.redhat_00004.1.el7jws\nTomcat Vault 1.1.8-4.Final_redhat_00004.1.el7jws\nJBoss mod_cluster 1.4.3-2.Final_redhat_00002.1.el7jws\n\nNative Components:\nApache Tomcat Native 1.2.30-3.redhat_3.el7jws\\nApache Portable Runtime (APR) 1.6.3-107.jbcs.el7\nOpenSSL 1.1.1g-8.jbcs.el7\n"} +""" + + +def test_JbossRuntimeVersions(): + jboss_runtimes = JbossRuntimeVersions(context_wrap(SINGLE_JBOSS)) + jboss_v = jboss_runtimes[0] + assert jboss_v.file_path == "/opt/jboss-datagrid-7.3.0-server" + assert jboss_v.product == "Red Hat Data Grid" + assert jboss_v.version == "7.3.0" + assert jboss_v.major == 7 + assert jboss_v.minor == 3 + assert jboss_v.release == 0 + jboss_runtimes = JbossRuntimeVersions(context_wrap(MULTI_JBOSS)) + for j in jboss_runtimes: + assert 'Red Hat' in j.product or 'Keycloak' in j.product + jboss_v = jboss_runtimes[0] + assert jboss_v.file_path == "/opt/jboss" + assert jboss_v.version == "7.3.0" + assert jboss_v.code_name == "GA" + jboss_v = jboss_runtimes[2] + assert jboss_v.file_path == "/opt/jboss-keycloak" + assert jboss_v.version == "3.4.3" + assert jboss_v.code_name == "Final" + jboss_runtimes = JbossRuntimeVersions(context_wrap(WEB_SERVER_RUNTIME)) + jboss_v = jboss_runtimes[0] + assert jboss_v.product == "Red Hat JBoss Web Server" + assert jboss_v.file_path == "/opt/jboss-web-server" + assert jboss_v.code_name == "GA" + assert jboss_v.version == "5.6" + assert jboss_v.major == 5 + assert jboss_v.minor == 6 + assert jboss_v.release == 0 + + def test_jboss_version_doc_examples(): env = { - 'JbossVersion': JbossVersion, 'jboss_version': JbossVersion(context_wrap(JBOSS_6, - path='/home/test/jboss/jboss-eap-6.4/version.txt')) + path='/home/test/jboss/jboss-eap-6.4/version.txt')), + 'all_jboss_versions': JbossRuntimeVersions(context_wrap(SINGLE_JBOSS, + path='/home/test/jboss/jboss_versions')) } failed, total = doctest.testmod(jboss_version, globs=env) assert failed == 0 From 5d0ac7d120a7ebf81a6501374c14feda143ed220 Mon Sep 17 00:00:00 2001 From: Xiangce Liu Date: Thu, 19 Jan 2023 14:26:45 +0800 Subject: [PATCH 03/14] fix: add '-d 2' to yum_repolist spec (#3660) * fix: add '-d 0' to yum_repolist spec Signed-off-by: Xiangce Liu * change to '-d 2' Signed-off-by: Xiangce Liu --- insights/specs/default.py | 2 +- insights/specs/insights_archive.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/insights/specs/default.py b/insights/specs/default.py index 561b8e3cfb..e16eafbbc0 100644 --- a/insights/specs/default.py +++ b/insights/specs/default.py @@ -675,7 +675,7 @@ class DefaultSpecs(Specs): yum_conf = simple_file("/etc/yum.conf") yum_list_available = simple_command("yum -C --noplugins list available", signum=signal.SIGTERM) yum_log = simple_file("/var/log/yum.log") - yum_repolist = simple_command("/usr/bin/yum -C --noplugins repolist", override_env={"LC_ALL": ""}, + yum_repolist = simple_command("/usr/bin/yum -d 2 -C --noplugins repolist", override_env={"LC_ALL": ""}, signum=signal.SIGTERM) yum_repos_d = glob_file("/etc/yum.repos.d/*.repo") yum_updates = yum_updates.yum_updates diff --git a/insights/specs/insights_archive.py b/insights/specs/insights_archive.py index fb1fe1df42..f3d51ead0e 100644 --- a/insights/specs/insights_archive.py +++ b/insights/specs/insights_archive.py @@ -278,5 +278,8 @@ class InsightsArchiveSpecs(Specs): virt_what = simple_file("insights_commands/virt-what") wc_proc_1_mountinfo = simple_file("insights_commands/wc_-l_.proc.1.mountinfo") yum_list_available = simple_file("insights_commands/yum_-C_--noplugins_list_available") - yum_repolist = first_file(["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") From 078ba673de57ff205cbcc2cec43775ec9a5605fb Mon Sep 17 00:00:00 2001 From: Mark Huth Date: Thu, 26 Jan 2023 02:33:11 +1000 Subject: [PATCH 04/14] Exclude malware-detection rules files in /var/tmp (and other locations) (#3665) Signed-off-by: Mark Huth Signed-off-by: Mark Huth --- .../client/apps/malware_detection/__init__.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/insights/client/apps/malware_detection/__init__.py b/insights/client/apps/malware_detection/__init__.py index 7f391f5a04..3c138d8ef1 100644 --- a/insights/client/apps/malware_detection/__init__.py +++ b/insights/client/apps/malware_detection/__init__.py @@ -7,7 +7,7 @@ import logging from glob import glob from datetime import datetime -from tempfile import NamedTemporaryFile +from tempfile import NamedTemporaryFile, gettempdir try: # python 2 from urllib import quote as urlencode @@ -605,11 +605,12 @@ def _get_rules(self): # However it can happen that the rules file isn't removed for some reason, so remove any existing # rules files before beginning a new scan, otherwise they may show up as matches in the scan results. old_rules_files = sum([glob(os.path.join(path, rules)) - for path in ('/tmp', '/var/tmp') + for path in ('/tmp', '/var/tmp', '/usr/tmp', gettempdir()) for rules in ('.tmpmdsigs*', 'tmp_malware-detection-client_rules.*')], []) for old_rules_file in old_rules_files: - logger.debug("Removing old rules file %s", old_rules_file) - os.remove(old_rules_file) + if os.path.exists(old_rules_file): + logger.debug("Removing old rules file %s", old_rules_file) + os.remove(old_rules_file) self.rules_location = self._get_config_option('rules_location', '') @@ -742,8 +743,16 @@ def scan_filesystem(self): return False # Exclude the rules file and insights-client log files, unless they are things we specifically want to scan - if self.rules_file not in self.scan_fsobjects: - self.filesystem_scan_exclude_list.append(self.rules_file) + # Get a list of potential rules files locations,eg /tmp, /var/tmp, /usr/tmp and gettempdir() + # eg customers may have /tmp linked to /var/tmp so both must be checked for excluding the downloaded rules + rules_file_name = os.path.basename(self.rules_file) + potential_tmp_dirs = set([gettempdir(), '/tmp', '/var/tmp', '/usr/tmp']) + potential_rules_files = set(list(map(lambda d: os.path.join(d, rules_file_name), potential_tmp_dirs)) + [self.rules_file]) + rules_files = list(filter(lambda f: os.path.isfile(f), potential_rules_files)) + for rules_file in rules_files: + if rules_file not in self.scan_fsobjects: + self.filesystem_scan_exclude_list.append(rules_file) + logger.debug("Excluding rules file: %s", rules_file) insights_log_files = glob(constants.default_log_file + '*') self.filesystem_scan_exclude_list.extend(list(set(insights_log_files) - set(self.scan_fsobjects))) From cc0293255dde9ee94e6859d5361921e6beb9cd58 Mon Sep 17 00:00:00 2001 From: Mark Huth Date: Tue, 31 Jan 2023 11:44:36 +1000 Subject: [PATCH 05/14] Make malware-detection app more resilient to unexpected errors (#3661) * Print log and traceback of unexpected error Signed-off-by: Mark Huth --- .../client/apps/malware_detection/__init__.py | 35 ++++++++++++++----- .../specs/datasources/malware_detection.py | 14 +++++--- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/insights/client/apps/malware_detection/__init__.py b/insights/client/apps/malware_detection/__init__.py index 3c138d8ef1..e09cbeb851 100644 --- a/insights/client/apps/malware_detection/__init__.py +++ b/insights/client/apps/malware_detection/__init__.py @@ -187,6 +187,7 @@ def __init__(self, insights_config): self.add_metadata = self._get_config_option('add_metadata', False) self.matches = 0 + self.potential_matches = 0 def run(self): # Start the scans and record the time they were started @@ -202,7 +203,11 @@ def run(self): # Write a message to user informing them if there were matches or not and what to do next if self.matches == 0: - logger.info("No rule matches found.\n") + if self.potential_matches == 0: + logger.info("No rule matches found.\n") + else: + logger.info("Rule matches potentially found but problems encountered parsing them, so no match data to upload.") + logger.info("Please contact support.\n") else: logger.info("Found %d rule match%s.", self.matches, 'es' if self.matches > 1 else '') if not self.test_scan: @@ -805,7 +810,12 @@ def scan_filesystem(self): logger.debug("Unable to scan %s: %s", toplevel_dir, cpe.output.strip()) continue - self.parse_scan_output(output.strip()) + try: + self.parse_scan_output(output.strip()) + except Exception as e: + self.potential_matches += 1 + logger.exception("Rule match(es) potentially found in %s but problems encountered parsing the results: %s. Skipping ...", + toplevel_dir, str(e)) dir_scan_end = time.time() logger.info("Scan time for %s: %d seconds", toplevel_dir, (dir_scan_end - dir_scan_start)) @@ -872,7 +882,12 @@ def scan_processes(self): logger.debug("Unable to scan process %s: %s", scan_pid, cpe.output.strip()) continue - self.parse_scan_output(output) + try: + self.parse_scan_output(output) + except Exception as e: + self.potential_matches += 1 + logger.exception("Rule match(es) potentially found in process %s but problems encountered parsing the results: %s. Skipping ...", + scan_pid, str(e)) pid_scan_end = time.time() logger.info("Scan time for process %s: %d seconds", scan_pid, (pid_scan_end - pid_scan_start)) @@ -979,11 +994,15 @@ def skip_string_data_lines(string_data_lines): rule_match['matches'] = [rule_match_dict] if self.add_metadata: - # Add extra data to each rule match, beyond what yara provides - # Eg, for files: line numbers & context, checksums; for processes: process name - # TODO: find more pythonic ways of doing this stuff instead of using system commands - metadata_func = self._add_file_metadata if source_type == 'file' else self._add_process_metadata - metadata_func(rule_match['matches']) + try: + # Add extra data to each rule match, beyond what yara provides + # Eg, for files: line numbers & context, checksums; for processes: process name + # TODO: find more pythonic ways of doing this stuff instead of using system commands + metadata_func = self._add_file_metadata if source_type == 'file' else self._add_process_metadata + metadata_func(rule_match['matches']) + except Exception as e: + logger.error("Error adding metadata to rule match %s in %s %s: %s. Skipping ...", + rule_name, source_type, source, str(e)) self.matches += 1 logger.info("Matched rule %s in %s %s", rule_name, source_type, source) diff --git a/insights/specs/datasources/malware_detection.py b/insights/specs/datasources/malware_detection.py index 1acda69aef..e568312dc8 100644 --- a/insights/specs/datasources/malware_detection.py +++ b/insights/specs/datasources/malware_detection.py @@ -6,6 +6,8 @@ from insights.client.apps.malware_detection import MalwareDetectionClient from insights.client.config import InsightsConfig from insights.specs import Specs +import logging +logger = logging.getLogger(__name__) class MalwareDetectionSpecs(Specs): @@ -20,12 +22,16 @@ def malware_detection_app(broker): insights_config = InsightsConfig().load_all() auto_config.try_auto_configuration(insights_config) if not (insights_config and hasattr(insights_config, 'app') and insights_config.app == 'malware-detection'): - raise SkipComponent + raise SkipComponent("Only run malware-detection app when specifically requested via --collector option") mdc = MalwareDetectionClient(insights_config) scan_results = mdc.run() if scan_results: return DatasourceProvider(content=scan_results, relative_path="malware-detection-results.json") else: - raise SkipComponent - except Exception: - raise SkipComponent + raise SkipComponent("No scan results were produced") + except SkipComponent as msg: + raise SkipComponent("Skipping malware-detection app: {0}".format(str(msg))) + except Exception as err: + err_msg = "Unexpected exception in malware-detection app: {0}".format(str(err)) + logger.exception(err_msg) + raise SkipComponent(err_msg) From c35bbd107d2527caba3d5d9bb582c9f7ef99daae Mon Sep 17 00:00:00 2001 From: Mark Huth Date: Tue, 31 Jan 2023 11:55:23 +1000 Subject: [PATCH 06/14] Disable datasource timeout alarm for the malware-detection app (#3666) Signed-off-by: Mark Huth --- insights/specs/datasources/malware_detection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/insights/specs/datasources/malware_detection.py b/insights/specs/datasources/malware_detection.py index e568312dc8..15265fc94f 100644 --- a/insights/specs/datasources/malware_detection.py +++ b/insights/specs/datasources/malware_detection.py @@ -11,7 +11,8 @@ class MalwareDetectionSpecs(Specs): - @datasource(HostContext) + # timeout=0 disables the datasource timeout alarm, allowing malware-detection to run for as long as necessary + @datasource(HostContext, timeout=0) def malware_detection_app(broker): """ Custom datasource to collects content for malware scanner if a scanner is present on the system From b43d87cf94d4440f76964c6e7879d584c99f0144 Mon Sep 17 00:00:00 2001 From: Xiaoxue Wang Date: Tue, 31 Jan 2023 10:14:53 +0800 Subject: [PATCH 07/14] fix: Resolve VDOStatus excessive ParseException (#3668) Signed-off-by: XiaoXue Wang --- insights/parsers/vdo_status.py | 4 ++-- insights/tests/parsers/test_vdo_status.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/insights/parsers/vdo_status.py b/insights/parsers/vdo_status.py index a8ab96bbec..51534521a5 100644 --- a/insights/parsers/vdo_status.py +++ b/insights/parsers/vdo_status.py @@ -8,14 +8,14 @@ """ from __future__ import division -from insights.core import YAMLParser +from insights.core import CommandParser, YAMLParser from insights.core.exceptions import ParseException from insights.core.plugins import parser from insights.specs import Specs @parser(Specs.vdo_status) -class VDOStatus(YAMLParser): +class VDOStatus(CommandParser, YAMLParser): """ Class for parsing ``vdo status`` command output. diff --git a/insights/tests/parsers/test_vdo_status.py b/insights/tests/parsers/test_vdo_status.py index 2f3c6f8dec..024cd2333d 100644 --- a/insights/tests/parsers/test_vdo_status.py +++ b/insights/tests/parsers/test_vdo_status.py @@ -2,6 +2,7 @@ import pytest from insights.core.exceptions import ParseException +from insights.core.plugins import ContentException from insights.parsers import vdo_status from insights.parsers.vdo_status import VDOStatus from insights.tests import context_wrap @@ -552,6 +553,10 @@ write policy: sync """.strip() +VDO_STATUS_NO_COMMAND = """ +-bash: /usr/bin/vdo: No such file or directory +""".strip() + def test_vdo_status2(): vdo = VDOStatus(context_wrap(INPUT_STATUS_2)) @@ -668,3 +673,12 @@ def test_vdo_status_exp3(): vdo = VDOStatus(context_wrap(INPUT_STATUS_SIMPLE)) vdo.get_physical_blocks_of_vol('vdo3') assert "No key(s) named" in str(sc1) + + +def test_vdo_status_exp4(): + """ + Test for ContentException + """ + with pytest.raises(ContentException) as ce: + VDOStatus(context_wrap(VDO_STATUS_NO_COMMAND)) + assert "No such file or directory" in str(ce.value) From 75e437e4cf5ce909e4c2bab25c9f14a8bdc07a75 Mon Sep 17 00:00:00 2001 From: Ryan Blakley Date: Tue, 31 Jan 2023 14:14:28 -0500 Subject: [PATCH 08/14] feat: Add arg to capture skips in the broker (#3663) * Added the --show-skips cli arg to trigger SkipComponents to be captured in the broker for troubleshooting purposes. Signed-off-by: Ryan Blakley --- insights/__init__.py | 11 ++++++++--- insights/core/dr.py | 10 ++++++++-- insights/core/plugins.py | 10 +++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/insights/__init__.py b/insights/__init__.py index 16247cb42e..58910f7e8b 100644 --- a/insights/__init__.py +++ b/insights/__init__.py @@ -266,9 +266,8 @@ def _load_context(path): return dr.get_component(path) -def run(component=None, root=None, print_summary=False, - context=None, inventory=None, print_component=None): - +def run(component=None, root=None, print_summary=False, context=None, inventory=None, print_component=None, + store_skips=False): args = None formatters = None @@ -293,6 +292,8 @@ def run(component=None, root=None, print_summary=False, p.add_argument("--context", help="Execution Context. Defaults to HostContext if an archive isn't passed.") p.add_argument("--no-load-default", help="Don't load the default plugins.", action="store_true") p.add_argument("--parallel", help="Execute rules in parallel.", action="store_true") + p.add_argument("--show-skips", help="Capture skips in the broker for troubleshooting.", action="store_true", + default=False) p.add_argument("--tags", help="Expression to select rules by tag.") class Args(object): @@ -385,6 +386,10 @@ class Args(object): graph = dr.COMPONENTS[dr.GROUPS.single] broker = dr.Broker() + if args: + broker.store_skips = args.show_skips + else: + broker.store_skips = store_skips if args and args.bare: ctx = ExecutionContext() # dummy context that no spec depend on. needed for filters to work diff --git a/insights/core/dr.py b/insights/core/dr.py index a90c76aeb2..ee8ff64744 100644 --- a/insights/core/dr.py +++ b/insights/core/dr.py @@ -809,6 +809,7 @@ class Broker(object): :func:`time.time`. For components that produce multiple instances, the execution time here is the sum of their individual execution times. + store_skips (bool): Weather to store skips in the broker or not. """ def __init__(self, seed_broker=None): self.instances = dict(seed_broker.instances) if seed_broker else {} @@ -816,6 +817,7 @@ def __init__(self, seed_broker=None): self.exceptions = defaultdict(list) self.tracebacks = {} self.exec_times = {} + self.store_skips = False self.observers = defaultdict(set) if seed_broker is not None: @@ -1045,8 +1047,12 @@ def run_components(ordered_components, components, broker): except ParseException as pe: log.warning(pe) broker.add_exception(component, pe, traceback.format_exc()) - except SkipComponent: - pass + except SkipComponent as sc: + if broker.store_skips: + log.warning(sc) + broker.add_exception(component, sc, traceback.format_exc()) + else: + pass except Exception as ex: tb = traceback.format_exc() log.warning(tb) diff --git a/insights/core/plugins.py b/insights/core/plugins.py index adaf13d778..864194fab7 100644 --- a/insights/core/plugins.py +++ b/insights/core/plugins.py @@ -167,14 +167,18 @@ def invoke(self, broker): r = self.component(d) if r is not None: results.append(r) - except SkipComponent: - pass except ContentException as ce: log.debug(ce) broker.add_exception(self.component, ce, traceback.format_exc()) if not self.continue_on_error: exception = True break + except SkipComponent as sc: + if broker.store_skips: + log.warning(sc) + broker.add_exception(component, sc, traceback.format_exc()) + else: + pass except CalledProcessError as cpe: log.debug(cpe) broker.add_exception(self.component, cpe, traceback.format_exc()) @@ -183,7 +187,7 @@ def invoke(self, broker): break except Exception as ex: tb = traceback.format_exc() - log.warn(tb) + log.warning(tb) broker.add_exception(self.component, ex, tb) if not self.continue_on_error: exception = True From dc79de0397e09d4672277a34255b53a65e43ec2f Mon Sep 17 00:00:00 2001 From: Ryan Blakley Date: Wed, 1 Feb 2023 19:47:07 -0500 Subject: [PATCH 09/14] Deprecate SkipException to help avoid confusion (#3662) * Mark SkipException deprecated to help avoid confusion as the dirty parser difference isn't really needed. * Replaced all internal references with SkipComponent. Signed-off-by: Ryan Blakley --- docs/exception_model.rst | 8 +++--- insights/combiners/modinfo.py | 6 ++--- insights/combiners/nmcli_dev_show.py | 4 +-- insights/core/__init__.py | 18 ++++++------- insights/core/exceptions.py | 15 ++++++++++- insights/parsers/abrt_ccpp.py | 11 ++++---- insights/parsers/auditctl.py | 16 +++++------ insights/parsers/authselect.py | 8 +++--- insights/parsers/aws_instance_id.py | 10 +++---- insights/parsers/awx_manage.py | 4 +-- insights/parsers/azure_instance.py | 10 +++---- insights/parsers/azure_instance_plan.py | 6 ++--- insights/parsers/azure_instance_type.py | 6 ++--- insights/parsers/bond_dynamic_lb.py | 6 ++--- insights/parsers/ceph_cmd_json_parsing.py | 4 +-- insights/parsers/ceph_osd_tree_text.py | 4 +-- insights/parsers/ceph_version.py | 8 +++--- insights/parsers/certificates_enddate.py | 7 ++--- insights/parsers/chkconfig.py | 7 ++--- insights/parsers/cmdline.py | 4 +-- insights/parsers/corosync_cmapctl.py | 6 ++--- insights/parsers/cpu_vulns.py | 6 ++--- insights/parsers/cpupower_frequency_info.py | 6 ++--- insights/parsers/crypto_policies.py | 8 +++--- insights/parsers/cups_ppd.py | 6 ++--- insights/parsers/date.py | 4 +-- insights/parsers/db2.py | 6 ++--- insights/parsers/dig.py | 6 ++--- insights/parsers/dnf_module.py | 6 ++--- insights/parsers/docker_inspect.py | 8 +++--- insights/parsers/docker_list.py | 8 +++--- insights/parsers/dotnet.py | 4 +-- insights/parsers/du.py | 6 ++--- insights/parsers/fcoeadm_i.py | 6 ++--- insights/parsers/findmnt.py | 4 +-- insights/parsers/firewall_config.py | 4 +-- insights/parsers/gcp_instance_type.py | 6 ++--- insights/parsers/gcp_license_codes.py | 6 ++--- insights/parsers/getsebool.py | 6 ++--- .../parsers/gfs2_file_system_block_size.py | 6 ++--- insights/parsers/gluster_peer_status.py | 4 +-- insights/parsers/grub_conf.py | 8 +++--- insights/parsers/grubby.py | 10 +++---- insights/parsers/grubenv.py | 6 ++--- insights/parsers/hammer_ping.py | 4 +-- insights/parsers/hammer_task_list.py | 6 ++--- insights/parsers/hosts.py | 4 +-- insights/parsers/httpd_V.py | 8 +++--- insights/parsers/ibm_proc.py | 14 +++++----- insights/parsers/imagemagick_policy.py | 6 ++--- .../parsers/ip_netns_exec_namespace_lsof.py | 8 +++--- insights/parsers/ipcs.py | 4 +-- insights/parsers/ipsec_conf.py | 8 +++--- insights/parsers/kernel_config.py | 4 +-- insights/parsers/kpatch_list.py | 4 +-- insights/parsers/ksmstate.py | 6 ++--- insights/parsers/ktimer_lockless.py | 6 ++--- insights/parsers/ld_library_path.py | 6 ++--- insights/parsers/ldif_config.py | 4 +-- insights/parsers/libssh_config.py | 8 +++--- insights/parsers/losetup.py | 4 +-- insights/parsers/lpstat.py | 6 ++--- insights/parsers/lscpu.py | 4 +-- insights/parsers/lspci.py | 4 +-- insights/parsers/lssap.py | 6 ++--- insights/parsers/lvm.py | 6 ++--- insights/parsers/max_uid.py | 6 ++--- insights/parsers/mdadm.py | 4 +-- insights/parsers/mdstat.py | 6 ++--- insights/parsers/modinfo.py | 18 ++++++------- insights/parsers/mount.py | 6 ++--- insights/parsers/mpirun.py | 6 ++--- insights/parsers/multipath_conf.py | 4 +-- insights/parsers/mysqladmin.py | 6 ++--- insights/parsers/named_checkconf.py | 6 ++--- insights/parsers/named_conf.py | 6 ++--- insights/parsers/net_namespace.py | 4 +-- insights/parsers/netstat.py | 4 +-- insights/parsers/networkmanager_dhclient.py | 6 ++--- insights/parsers/nfnetlink_queue.py | 6 ++--- insights/parsers/nmcli.py | 8 +++--- insights/parsers/nova_user_ids.py | 10 +++---- insights/parsers/numa_cpus.py | 4 +-- insights/parsers/nvme_core_io_timeout.py | 6 ++--- insights/parsers/od_cpu_dma_latency.py | 4 +-- insights/parsers/open_vm_tools.py | 6 ++--- .../parsers/ovs_appctl_fdb_show_bridge.py | 8 +++--- insights/parsers/ovs_ofctl_dump_flows.py | 8 +++--- insights/parsers/ovs_vsctl.py | 6 ++--- insights/parsers/ovs_vsctl_list_bridge.py | 2 +- insights/parsers/package_provides.py | 6 ++--- insights/parsers/partitions.py | 6 ++--- insights/parsers/passenger_status.py | 8 +++--- .../parsers/pci_rport_target_disk_paths.py | 6 ++--- insights/parsers/pcs_quorum_status.py | 6 ++--- insights/parsers/php_ini.py | 4 +-- insights/parsers/pmrep.py | 4 +-- insights/parsers/podman_inspect.py | 8 +++--- insights/parsers/postconf.py | 6 ++--- insights/parsers/proc_environ.py | 6 ++--- insights/parsers/proc_keys.py | 6 ++--- .../parsers/puppet_ca_cert_expire_date.py | 6 ++--- insights/parsers/rdma_config.py | 4 +-- insights/parsers/readlink_e_mtab.py | 4 +-- insights/parsers/readlink_openshift_certs.py | 10 +++---- insights/parsers/rhev_data_center.py | 6 ++--- insights/parsers/rhsm_releasever.py | 6 ++--- insights/parsers/rndc_status.py | 6 ++--- insights/parsers/sap_hana_python_script.py | 6 ++--- insights/parsers/sap_hdb_version.py | 8 +++--- insights/parsers/sap_host_profile.py | 4 +-- insights/parsers/sapcontrol.py | 6 ++--- insights/parsers/saphostctrl.py | 6 ++--- insights/parsers/saphostexec.py | 7 ++--- insights/parsers/sat5_insights_properties.py | 6 ++--- .../parsers/satellite_content_hosts_count.py | 4 +-- .../parsers/satellite_enabled_features.py | 4 +-- .../satellite_installer_configurations.py | 4 +-- insights/parsers/satellite_mongodb.py | 10 +++---- .../parsers/satellite_postgresql_query.py | 6 ++--- insights/parsers/sctp.py | 10 +++---- insights/parsers/sealert.py | 7 +++-- insights/parsers/setup_named_chroot.py | 8 +++--- insights/parsers/slabinfo.py | 10 +++---- insights/parsers/smbstatus.py | 4 +-- insights/parsers/smt.py | 18 ++++++------- insights/parsers/sockstat.py | 6 ++--- insights/parsers/ssh_client_config.py | 9 ++++--- insights/parsers/ssl_certificate.py | 10 +++---- insights/parsers/subscription_manager.py | 4 +-- .../parsers/subscription_manager_release.py | 6 ++--- insights/parsers/sudoers.py | 4 +-- insights/parsers/sys_bus.py | 2 +- insights/parsers/sys_module.py | 10 +++---- insights/parsers/sys_vmbus.py | 10 +++---- insights/parsers/systemctl_show.py | 10 +++---- insights/parsers/systemd/unitfiles.py | 10 +++---- insights/parsers/systemd_analyze.py | 6 ++--- .../parsers/tomcat_virtual_dir_context.py | 4 +-- insights/parsers/tuned.py | 6 ++--- insights/parsers/upstart.py | 6 ++--- insights/parsers/user_group.py | 4 +-- insights/parsers/vma_ra_enabled_s390x.py | 6 ++--- insights/parsers/x86_debug.py | 14 +++++----- insights/parsers/yum.py | 8 +++--- insights/parsers/yum_updateinfo.py | 4 +-- insights/parsers/zdump_v.py | 6 ++--- .../tests/combiners/test_httpd_conf_tree.py | 4 +-- insights/tests/combiners/test_nginx_conf.py | 4 +-- insights/tests/parsers/__init__.py | 27 +++++++++++++++++-- insights/tests/parsers/test_abrt_ccpp.py | 4 +-- insights/tests/parsers/test_auditctl.py | 10 +++---- insights/tests/parsers/test_authselect.py | 6 ++--- .../tests/parsers/test_aws_instance_id.py | 10 +++---- insights/tests/parsers/test_awx_manage.py | 8 +++--- insights/tests/parsers/test_azure_instance.py | 20 +++++++------- .../tests/parsers/test_azure_instance_plan.py | 10 +++---- .../tests/parsers/test_azure_instance_type.py | 10 +++---- .../tests/parsers/test_bond_dynamic_lb.py | 4 +-- .../parsers/test_ceph_cmd_json_parsing.py | 20 +++++++------- insights/tests/parsers/test_ceph_conf.py | 4 +-- .../tests/parsers/test_ceph_osd_tree_text.py | 4 +-- insights/tests/parsers/test_ceph_version.py | 10 +++---- .../parsers/test_certificates_enddate.py | 4 +-- insights/tests/parsers/test_chkconfig.py | 4 +-- insights/tests/parsers/test_cloud_cfg.py | 4 +-- insights/tests/parsers/test_cmdline.py | 4 +-- .../parsers/test_cni_podman_bridge_conf.py | 4 +-- .../tests/parsers/test_containers_policy.py | 4 +-- insights/tests/parsers/test_corosync.py | 4 +-- .../tests/parsers/test_corosync_cmapctl.py | 4 +-- insights/tests/parsers/test_cpu_vulns.py | 10 +++---- .../parsers/test_cpupower_frequency_info.py | 4 +-- .../parsers/test_crypto_policies_bind.py | 4 +-- .../parsers/test_crypto_policies_config.py | 4 +-- .../test_crypto_policies_state_current.py | 4 +-- insights/tests/parsers/test_cups_ppd.py | 6 ++--- insights/tests/parsers/test_date.py | 4 +-- insights/tests/parsers/test_db2.py | 6 ++--- insights/tests/parsers/test_dig.py | 4 +-- insights/tests/parsers/test_dnf_module.py | 6 ++--- insights/tests/parsers/test_docker_inspect.py | 4 +-- insights/tests/parsers/test_docker_list.py | 8 +++--- insights/tests/parsers/test_dotnet.py | 4 +-- insights/tests/parsers/test_doveconf.py | 4 +-- insights/tests/parsers/test_du.py | 4 +-- .../tests/parsers/test_engine_db_query.py | 4 +-- insights/tests/parsers/test_etcd_conf.py | 4 +-- insights/tests/parsers/test_fcoeadm_i.py | 4 +-- insights/tests/parsers/test_findmnt.py | 4 +-- .../tests/parsers/test_firewall_config.py | 4 +-- .../parsers/test_freeipa_healthcheck_log.py | 4 +-- .../tests/parsers/test_gcp_instance_type.py | 10 +++---- .../tests/parsers/test_gcp_license_codes.py | 10 +++---- insights/tests/parsers/test_getsebool.py | 4 +-- .../test_gfs2_file_system_block_size.py | 8 +++--- .../tests/parsers/test_gluster_peer_status.py | 4 +-- insights/tests/parsers/test_grubby.py | 6 ++--- insights/tests/parsers/test_grubenv.py | 6 ++--- insights/tests/parsers/test_hammer_ping.py | 4 +-- insights/tests/parsers/test_hosts.py | 4 +-- insights/tests/parsers/test_httpd_V.py | 6 ++--- insights/tests/parsers/test_httpd_open_nfs.py | 4 +-- insights/tests/parsers/test_ibm_proc.py | 8 +++--- .../tests/parsers/test_imagemagick_policy.py | 4 +-- .../test_ip_netns_exec_namespace_lsof.py | 6 ++--- insights/tests/parsers/test_ipcs.py | 4 +-- insights/tests/parsers/test_ipsec_conf.py | 4 +-- insights/tests/parsers/test_kernel_config.py | 4 +-- insights/tests/parsers/test_kpatch_list.py | 4 +-- insights/tests/parsers/test_ksmstate.py | 4 +-- .../tests/parsers/test_ktimer_lockless.py | 4 +-- .../tests/parsers/test_ld_library_path.py | 4 +-- insights/tests/parsers/test_ldif_config.py | 4 +-- insights/tests/parsers/test_libssh_config.py | 4 +-- insights/tests/parsers/test_losetup.py | 4 +-- insights/tests/parsers/test_lpstat.py | 6 ++--- insights/tests/parsers/test_lscpu.py | 4 +-- insights/tests/parsers/test_lspci.py | 6 ++--- insights/tests/parsers/test_lssap.py | 4 +-- insights/tests/parsers/test_lvm.py | 4 +-- insights/tests/parsers/test_max_uid.py | 4 +-- insights/tests/parsers/test_mdstat.py | 6 ++--- insights/tests/parsers/test_modinfo.py | 6 ++--- insights/tests/parsers/test_mount.py | 4 +-- insights/tests/parsers/test_mpirun.py | 6 ++--- insights/tests/parsers/test_multipath_conf.py | 8 +++--- insights/tests/parsers/test_mysqladmin.py | 8 +++--- .../tests/parsers/test_named_checkconf.py | 4 +-- insights/tests/parsers/test_named_conf.py | 6 ++--- insights/tests/parsers/test_ndctl_list.py | 4 +-- insights/tests/parsers/test_net_namespace.py | 6 ++--- insights/tests/parsers/test_netstat.py | 4 +-- .../parsers/test_networkmanager_dhclient.py | 4 +-- .../tests/parsers/test_nfnetlink_queue.py | 4 +-- insights/tests/parsers/test_nmcli.py | 10 +++---- insights/tests/parsers/test_nova_user_ids.py | 10 +++---- insights/tests/parsers/test_numa_cpus.py | 4 +-- .../parsers/test_nvme_core_io_timeout.py | 6 ++--- .../tests/parsers/test_od_cpu_dma_latency.py | 4 +-- insights/tests/parsers/test_open_vm_tools.py | 6 ++--- .../test_ovs_appctl_fdb_show_bridge.py | 6 ++--- .../parsers/test_ovs_ofctl_dump_flows.py | 8 +++--- insights/tests/parsers/test_ovs_vsctl.py | 4 +-- .../parsers/test_ovs_vsctl_list_bridge.py | 4 +-- .../tests/parsers/test_package_provides.py | 4 +-- insights/tests/parsers/test_parsers_module.py | 6 ++--- insights/tests/parsers/test_partitions.py | 4 +-- .../tests/parsers/test_passenger_status.py | 4 +-- .../test_pci_rport_target_disk_paths.py | 4 +-- .../tests/parsers/test_pcs_quorum_status.py | 4 +-- insights/tests/parsers/test_php_ini.py | 4 +-- insights/tests/parsers/test_pmrep.py | 6 ++--- insights/tests/parsers/test_podman_inspect.py | 4 +-- insights/tests/parsers/test_podman_list.py | 4 +-- insights/tests/parsers/test_postconf.py | 14 +++++----- insights/tests/parsers/test_proc_environ.py | 4 +-- insights/tests/parsers/test_proc_keys.py | 6 ++--- .../test_puppet_ca_cert_expire_date.py | 4 +-- insights/tests/parsers/test_rdma_config.py | 4 +-- insights/tests/parsers/test_readlink_mtab.py | 4 +-- .../parsers/test_readlink_openshift_certs.py | 6 ++--- .../tests/parsers/test_rhev_data_center.py | 4 +-- .../tests/parsers/test_rhsm_releasever.py | 8 +++--- .../test_rhv_log_collector_analyzer.py | 4 +-- insights/tests/parsers/test_rndc_status.py | 4 +-- .../parsers/test_sap_hana_python_script.py | 4 +-- .../tests/parsers/test_sap_hdb_version.py | 6 ++--- .../tests/parsers/test_sap_host_profile.py | 4 +-- insights/tests/parsers/test_sapcontrol.py | 6 ++--- insights/tests/parsers/test_saphostctrl.py | 4 +-- insights/tests/parsers/test_saphostexec.py | 6 ++--- .../parsers/test_sat5_insights_properties.py | 4 +-- .../test_satellite_content_hosts_count.py | 6 ++--- .../test_satellite_enabled_features.py | 4 +-- .../tests/parsers/test_satellite_mongodb.py | 10 +++---- .../test_satellite_postgresql_query.py | 10 +++---- insights/tests/parsers/test_sctp.py | 8 +++--- .../tests/parsers/test_setup_named_chroot.py | 6 ++--- insights/tests/parsers/test_slabinfo.py | 10 +++---- insights/tests/parsers/test_smbstatus.py | 6 ++--- insights/tests/parsers/test_smt.py | 4 +-- insights/tests/parsers/test_sockstat.py | 4 +-- .../tests/parsers/test_ssh_client_config.py | 4 +-- .../tests/parsers/test_ssl_certificate.py | 6 ++--- .../parsers/test_subscription_manager.py | 4 +-- .../test_subscription_manager_release.py | 10 +++---- insights/tests/parsers/test_sudoers.py | 4 +-- insights/tests/parsers/test_sys_module.py | 8 +++--- insights/tests/parsers/test_sys_vmbus.py | 6 ++--- insights/tests/parsers/test_systemctl_show.py | 4 +-- .../tests/parsers/test_systemd_analyze.py | 4 +-- insights/tests/parsers/test_systemd_config.py | 4 +-- insights/tests/parsers/test_tags.py | 4 +-- .../parsers/test_teamdctl_config_dump.py | 4 +-- .../tests/parsers/test_teamdctl_state_dump.py | 4 +-- .../test_tomcat_virtual_dir_context.py | 6 ++--- insights/tests/parsers/test_tuned.py | 4 +-- insights/tests/parsers/test_unitfiles.py | 6 ++--- insights/tests/parsers/test_upstart.py | 4 +-- insights/tests/parsers/test_user_group.py | 4 +-- insights/tests/parsers/test_version_info.py | 4 +-- .../tests/parsers/test_virt_uuid_facts.py | 4 +-- insights/tests/parsers/test_virt_who_conf.py | 4 +-- .../parsers/test_vma_ra_enabled_s390x.py | 4 +-- insights/tests/parsers/test_x86_debug.py | 10 +++---- insights/tests/parsers/test_yum_repolist.py | 8 +++--- insights/tests/parsers/test_zdump_v.py | 4 +-- insights/tests/test_config_parser.py | 6 ++--- insights/tests/test_yaml_parser.py | 4 +-- 310 files changed, 961 insertions(+), 925 deletions(-) diff --git a/docs/exception_model.rst b/docs/exception_model.rst index 68fca2b0cc..95a9358d41 100644 --- a/docs/exception_model.rst +++ b/docs/exception_model.rst @@ -82,7 +82,7 @@ any exceptions in the data (“dirty parser”). This allows rules that don’t exceptions to rely on only the first parser, and those rules will not run if valid data is not present. If the dirty parser identifies errors in the data then it will save information regarding the errors for use by rules. If no errors are found in the data -then the dirty parser will raise :py:class:`insights.core.exceptions.SkipException` +then the dirty parser will raise :py:class:`insights.core.exceptions.SkipComponent` to indicate to the engine that it should be removed from the dependency hierarchy. Other Exceptions from Parsers @@ -99,15 +99,13 @@ types aren’t important and such checks may limit expressiveness and flexibilit Parsers should not use the assert statement in place of error handling code. Asserts are for debugging purposes only. -SkipComponent and SkipException -=============================== +SkipComponent +============= Any component may raise `SkipComponent` to signal to the engine that nothing is wrong but that the component should be taken out of dependency resolution. This is useful if a component's dependencies are met but it's still unable to produce a meaningful result. -:py:class:`insights.core.exceptions.SkipException` is a specialization of this for the -dirty parser use case above, but it's treated the same as `SkipComponent`. Exception Recognition by the Insights Engine ============================================ diff --git a/insights/combiners/modinfo.py b/insights/combiners/modinfo.py index 3f928b700c..4a3859148f 100644 --- a/insights/combiners/modinfo.py +++ b/insights/combiners/modinfo.py @@ -12,7 +12,7 @@ The ModulesInfo combines the collected modules info from the result of ``KernelModulesInfo``. """ -from insights.core.exceptions import SkipComponent, SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import combiner from insights.parsers.modinfo import (KernelModulesInfo, ModInfoEach, ModInfoAll) from insights.util import deprecated @@ -102,7 +102,7 @@ class ModulesInfo(dict): False Raises: - SkipException: When content is empty. + SkipComponent: When content is empty. Attributes: retpoline_y (set): A set of names of the modules with the attribute "retpoline: Y". @@ -116,4 +116,4 @@ def __init__(self, filtered_modules_info): self.retpoline_n = filtered_modules_info.retpoline_n self.retpoline_y = filtered_modules_info.retpoline_y if not self: - raise SkipException + raise SkipComponent diff --git a/insights/combiners/nmcli_dev_show.py b/insights/combiners/nmcli_dev_show.py index a5c5ce4e8b..7925413d34 100644 --- a/insights/combiners/nmcli_dev_show.py +++ b/insights/combiners/nmcli_dev_show.py @@ -4,7 +4,7 @@ As there are three different file paths in different sos packages, create this combiner to fix this issue. """ -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import combiner from insights.parsers.nmcli import NmcliDevShow, NmcliDevShowSos @@ -34,7 +34,7 @@ def __init__(self, nmclidevshow, nmclidevshowsos): self._con_dev.extend(item.connected_devices) if not data: - raise SkipException() + raise SkipComponent() super(AllNmcliDevShow, self).__init__() self.update(data) diff --git a/insights/core/__init__.py b/insights/core/__init__.py index 0a96d9a554..0cb9499102 100644 --- a/insights/core/__init__.py +++ b/insights/core/__init__.py @@ -14,7 +14,7 @@ from insights.contrib.ConfigParser import NoOptionError, NoSectionError from insights.core import ls_parser -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent, SkipException # noqa: F401 from insights.core.serde import deserializer, serializer from insights.parsr import iniparser from insights.parsr.query import Directive, Entry, Result, Section, compile_queries @@ -354,11 +354,11 @@ class ConfigParser(Parser, ConfigComponent): Base Insights component class for Parsers of configuration files. Raises: - SkipException: When input content is empty. + SkipComponent: When input content is empty. """ def parse_content(self, content): if not content: - raise SkipException('Empty content.') + raise SkipComponent('Empty content.') self.content = content self.doc = self.parse_doc(content) @@ -403,7 +403,7 @@ def find_main(self, name): if c.file_name == name: return c - raise SkipException("The main conf {main_conf} doesn't exist.".format(main_conf=name)) + raise SkipComponent("The main conf {main_conf} doesn't exist.".format(main_conf=name)) class ContainerConfigCombiner(ConfigCombiner): @@ -762,12 +762,12 @@ def parse_content(self, content): else: self.data = yaml.load(content, Loader=SafeLoader) if self.data is None: - raise SkipException("There is no data") + raise SkipComponent("There is no data") if not isinstance(self.data, (dict, list)): raise ParseException("YAML didn't produce a dictionary or list.") - except SkipException as se: + except SkipComponent as se: tb = sys.exc_info()[2] - six.reraise(SkipException, SkipException(str(se)), tb) + six.reraise(SkipComponent, SkipComponent(str(se)), tb) except: tb = sys.exc_info()[2] cls = self.__class__ @@ -787,11 +787,11 @@ def parse_content(self, content): else: self.data = json.loads(content) if self.data is None: - raise SkipException("There is no data") + raise SkipComponent("There is no data") except: # If content is empty then raise a skip exception instead of a parse exception. if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") else: tb = sys.exc_info()[2] cls = self.__class__ diff --git a/insights/core/exceptions.py b/insights/core/exceptions.py index ae71bffd3b..aea9a8dfa4 100644 --- a/insights/core/exceptions.py +++ b/insights/core/exceptions.py @@ -1,3 +1,6 @@ +from insights.util import deprecated + + class CalledProcessError(Exception): """ Raised if call fails. @@ -81,10 +84,20 @@ def __init__(self, content_type): class SkipException(SkipComponent): """ + .. warning:: + This class is deprecated, please use + :py:class:`insights.core.exceptions.SkipComponent` instead. + Exception that should be thrown from parsers that are explicitly written to look for errors in input data. If the expected error is not found then the parser should throw this exception to signal to the infrastructure that the parser's output should not be retained. """ - pass + def __init__(self, msg): + deprecated( + SkipException, + "Please use the :class:`insights.core.exceptions.SkipComponent` instead.", + "3.2.25" + ) + super(SkipException, self).__init__(msg) diff --git a/insights/parsers/abrt_ccpp.py b/insights/parsers/abrt_ccpp.py index eb9abfcc2b..8119a65a12 100644 --- a/insights/parsers/abrt_ccpp.py +++ b/insights/parsers/abrt_ccpp.py @@ -73,12 +73,11 @@ 'yes' """ - - -from insights.specs import Specs -from insights import Parser, parser +from insights.core import Parser +from insights.core.exceptions import SkipComponent +from insights.core.plugins import parser from insights.parsers import split_kv_pairs -from insights.core.exceptions import SkipException +from insights.specs import Specs @parser(Specs.abrt_ccpp_conf) @@ -89,4 +88,4 @@ class AbrtCCppConf(Parser, dict): def parse_content(self, content): self.update(split_kv_pairs(content, use_partition=False)) if not self: - raise SkipException("empty content") + raise SkipComponent("empty content") diff --git a/insights/parsers/auditctl.py b/insights/parsers/auditctl.py index 17da42bbfa..8deea67c7d 100644 --- a/insights/parsers/auditctl.py +++ b/insights/parsers/auditctl.py @@ -10,9 +10,9 @@ ------------------------------------- """ - -from insights import parser, CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core import CommandParser +from insights.core.exceptions import ParseException, SkipComponent +from insights.core.plugins import parser from insights.specs import Specs @@ -43,17 +43,17 @@ class AuditRules(CommandParser, list): True Raises: - SkipException: When there are not rules. + SkipComponent: When there are not rules. """ def parse_content(self, content): if len(content) == 1 and content[0].lower().strip() == 'no rules': - raise SkipException + raise SkipComponent for line in content: if line.strip(): self.append(line.strip()) if not self: - raise SkipException('No rules found') + raise SkipComponent('No rules found') @parser(Specs.auditctl_status) @@ -86,7 +86,7 @@ class AuditStatus(CommandParser, dict): """ def parse_content(self, content): if not content: - raise SkipException("Input content is empty.") + raise SkipComponent("Input content is empty.") if len(content) > 1: for line in content: k, v = line.split(None, 1) @@ -108,4 +108,4 @@ def parse_content(self, content): except ValueError: raise ParseException('Unexpected type in line %s ' % line) if not self: - raise SkipException('There is no content in the status output.') + raise SkipComponent('There is no content in the status output.') diff --git a/insights/parsers/authselect.py b/insights/parsers/authselect.py index 2a2f8eb712..b91fa1f47b 100644 --- a/insights/parsers/authselect.py +++ b/insights/parsers/authselect.py @@ -2,9 +2,9 @@ AuthSelectCurrent - command ``authselect current`` ================================================== """ -from insights import parser from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent +from insights.core.plugins import parser from insights.specs import Specs @@ -39,7 +39,7 @@ def parse_content(self, content): self.enabled_features = [] for line in content: if 'No existing configuration detected.' in line: - raise SkipException + raise SkipComponent line_sp = line.split() if line.startswith('Profile ID:'): self.profile_id = line_sp[-1] @@ -55,4 +55,4 @@ def parse_content(self, content): elif line.startswith('-') and feature_flag: self.enabled_features.append(line_sp[-1]) if self.profile_id is None: - raise SkipException + raise SkipComponent diff --git a/insights/parsers/aws_instance_id.py b/insights/parsers/aws_instance_id.py index 8c346c01bc..b94225e38b 100644 --- a/insights/parsers/aws_instance_id.py +++ b/insights/parsers/aws_instance_id.py @@ -12,7 +12,7 @@ import json from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -45,7 +45,7 @@ class AWSInstanceIdDoc(CommandParser, dict): } Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. ParseException: When type cannot be recognized. Attributes: @@ -64,7 +64,7 @@ class AWSInstanceIdDoc(CommandParser, dict): def parse_content(self, content): """Parse output of command.""" if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() # Just in case curl stats are present in data startline = 0 @@ -107,7 +107,7 @@ class AWSInstanceIdPkcs7(CommandParser): NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Attributes: signature (str): PKCS7 signature string including header and footer. @@ -121,7 +121,7 @@ class AWSInstanceIdPkcs7(CommandParser): def parse_content(self, content): """Parse output of command.""" if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() # Just in case curl stats are present in data startline = 0 diff --git a/insights/parsers/awx_manage.py b/insights/parsers/awx_manage.py index bb8ea38fa4..97875e0662 100644 --- a/insights/parsers/awx_manage.py +++ b/insights/parsers/awx_manage.py @@ -12,7 +12,7 @@ """ from insights.core import CommandParser, JSONParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -37,7 +37,7 @@ class AnsibleTowerLicenseType(CommandParser, JSONParser): """ def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent if len(content) != 1: raise ParseException("Invalid output: {0}".format(content)) self.type = content[0].strip() diff --git a/insights/parsers/azure_instance.py b/insights/parsers/azure_instance.py index 78ae1c747e..18643a999a 100644 --- a/insights/parsers/azure_instance.py +++ b/insights/parsers/azure_instance.py @@ -16,14 +16,14 @@ import json from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs def validate_content(content): if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() @parser(Specs.azure_instance_id) @@ -38,7 +38,7 @@ class AzureInstanceID(CommandParser): f904ece8-c6c1-4b5c-881f-309b50f25e50 Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. Attributes: id (str): The instance ID of the VM instance in Azure. @@ -69,7 +69,7 @@ class AzureInstanceType(CommandParser): Standard_L64s_v2 Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. ParseException: When type cannot be recognized. Attributes: @@ -126,7 +126,7 @@ class AzureInstancePlan(CommandParser): }, Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. Attributes: name (str): The name of the plan for the VM Instance in Azure, e.g: rhel7 diff --git a/insights/parsers/azure_instance_plan.py b/insights/parsers/azure_instance_plan.py index 0330c50637..49a1882749 100644 --- a/insights/parsers/azure_instance_plan.py +++ b/insights/parsers/azure_instance_plan.py @@ -12,7 +12,7 @@ import json from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs from insights.util import deprecated @@ -38,7 +38,7 @@ class AzureInstancePlan(CommandParser): }, Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. Attributes: name (str): The name of the plan for the VM Instance in Azure, e.g: rhel7 @@ -60,7 +60,7 @@ def __init__(self, *args, **kwargs): def parse_content(self, content): if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() try: plan = json.loads(content[0]) except: diff --git a/insights/parsers/azure_instance_type.py b/insights/parsers/azure_instance_type.py index 30c6001348..6a07566029 100644 --- a/insights/parsers/azure_instance_type.py +++ b/insights/parsers/azure_instance_type.py @@ -10,7 +10,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs from insights.util import deprecated @@ -32,7 +32,7 @@ class AzureInstanceType(CommandParser): Standard_L64s_v2 Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. ParseException: When type cannot be recognized. Attributes: @@ -57,7 +57,7 @@ def __init__(self, *args, **kwargs): def parse_content(self, content): if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() self.raw = self.type = self.size = self.version = None # Ignore any curl stats that may be present in data diff --git a/insights/parsers/bond_dynamic_lb.py b/insights/parsers/bond_dynamic_lb.py index 6231a92ca3..9afd2feaec 100644 --- a/insights/parsers/bond_dynamic_lb.py +++ b/insights/parsers/bond_dynamic_lb.py @@ -27,7 +27,7 @@ """ from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -42,13 +42,13 @@ class BondDynamicLB(Parser): 1 - Load based load balancing. Raises: - SkipException: When contents are empty + SkipComponent: When contents are empty ParseException: When contents are invalid """ def parse_content(self, content): if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") line = content[0].strip() self._dynamic_lb_status = None self._bond_name = self.file_path.rsplit("/")[-3] diff --git a/insights/parsers/ceph_cmd_json_parsing.py b/insights/parsers/ceph_cmd_json_parsing.py index cd56194573..5c5e6909cc 100644 --- a/insights/parsers/ceph_cmd_json_parsing.py +++ b/insights/parsers/ceph_cmd_json_parsing.py @@ -38,7 +38,7 @@ import json from insights.core import CommandParser, JSONParser, LegacyItemAccess -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -181,7 +181,7 @@ class CephReport(CommandParser, LegacyItemAccess): """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") if not content[0].startswith('report ') or len(content) < 10: raise ParseException("Invalid Content: ", content[0]) diff --git a/insights/parsers/ceph_osd_tree_text.py b/insights/parsers/ceph_osd_tree_text.py index ed7ec9bb04..f8b57220a2 100644 --- a/insights/parsers/ceph_osd_tree_text.py +++ b/insights/parsers/ceph_osd_tree_text.py @@ -3,7 +3,7 @@ =========================================== """ from insights.core import CommandParser, LegacyItemAccess -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -62,7 +62,7 @@ def calc_column_indices(line, headers): return idx if not content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") if len(content) == 1 or "TYPE NAME" not in content[0]: raise ParseException("Wrong content in table: '{0}'.".format(content)) diff --git a/insights/parsers/ceph_version.py b/insights/parsers/ceph_version.py index adebe0a892..9b300d7f96 100644 --- a/insights/parsers/ceph_version.py +++ b/insights/parsers/ceph_version.py @@ -11,7 +11,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs from insights.util import rsplit @@ -129,7 +129,7 @@ class CephVersion(CommandParser): def parse_content(self, content): # Parse Ceph Version Content and get Release, Major, Minor number if not content or len(content) != 1: - raise SkipException("Empty Ceph Version Line", content) + raise SkipComponent("Empty Ceph Version Line", content) community_version = get_community_version(content[0]) release_data = get_ceph_version(community_version) @@ -146,7 +146,7 @@ def get_community_version(version_full): Returns the community version part from the output of ``ceph -v`` """ if any(item not in version_full for item in ['ceph version', '.', '-']): - raise SkipException("Wrong Format Ceph Version", version_full) + raise SkipComponent("Wrong Format Ceph Version", version_full) return version_full.split()[2] @@ -159,7 +159,7 @@ def get_ceph_version(community_full): community_version, _ = rsplit(community_full, '.') release_data = community_to_release_map.get(community_version, None) if not release_data: - raise SkipException("No Mapping Release Version", community_version) + raise SkipComponent("No Mapping Release Version", community_version) release_data['upstream_version'] = dict( zip( ['release', 'major', 'minor'], diff --git a/insights/parsers/certificates_enddate.py b/insights/parsers/certificates_enddate.py index 51b6465e13..8127a0212a 100644 --- a/insights/parsers/certificates_enddate.py +++ b/insights/parsers/certificates_enddate.py @@ -38,8 +38,9 @@ """ from collections import namedtuple from datetime import datetime -from insights import CommandParser -from insights.core.exceptions import SkipException + +from insights.core import CommandParser +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -63,7 +64,7 @@ def parse_content(self, content): else: datestamp = None if not self: - raise SkipException("No certification files found.") + raise SkipComponent("No certification files found.") @property def data(self): diff --git a/insights/parsers/chkconfig.py b/insights/parsers/chkconfig.py index 8b64f928f4..d819c322e0 100644 --- a/insights/parsers/chkconfig.py +++ b/insights/parsers/chkconfig.py @@ -5,8 +5,9 @@ import re from collections import namedtuple + from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -19,7 +20,7 @@ class ChkConfig(CommandParser): Sample input data is shown as `content` in the examples below. Raises: - SkipException: When nothing is parsed. + SkipComponent: When nothing is parsed. Examples: >>> content = ''' @@ -126,7 +127,7 @@ def parse_content(self, content): self.level_states[service] = states if not self.services: - raise SkipException + raise SkipComponent def is_on(self, service_name): """ diff --git a/insights/parsers/cmdline.py b/insights/parsers/cmdline.py index 3f7e8fcf03..9c87bc20f0 100644 --- a/insights/parsers/cmdline.py +++ b/insights/parsers/cmdline.py @@ -7,7 +7,7 @@ """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -65,7 +65,7 @@ class CmdLine(LegacyItemAccess, Parser): def parse_content(self, content): if not content: - raise SkipException('Empty output') + raise SkipComponent('Empty output') if len(content) != 1: raise ParseException('Invalid output: {0}', content) diff --git a/insights/parsers/corosync_cmapctl.py b/insights/parsers/corosync_cmapctl.py index 5d837925e6..50ee22a579 100644 --- a/insights/parsers/corosync_cmapctl.py +++ b/insights/parsers/corosync_cmapctl.py @@ -5,7 +5,7 @@ This module parses the output of the ``corosync-cmapctl [params]`` command. """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -37,7 +37,7 @@ class CorosyncCmapctl(CommandParser, dict): 'corosync_cmap' Raises: - SkipException: When there is no content + SkipComponent: When there is no content ParseException: When there is no "=" in the content """ @@ -46,7 +46,7 @@ def __init__(self, context): def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent for line in content: if '=' not in line: raise ParseException("Can not parse line %s" % line) diff --git a/insights/parsers/cpu_vulns.py b/insights/parsers/cpu_vulns.py index 7624763705..671ee24d4b 100644 --- a/insights/parsers/cpu_vulns.py +++ b/insights/parsers/cpu_vulns.py @@ -5,7 +5,7 @@ Parser to parse the output of files ``/sys/devices/system/cpu/vulnerabilities/*`` """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -47,11 +47,11 @@ class CpuVulns(Parser): value (str): The result parsed Raises: - SkipException: When file content is empty + SkipComponent: When file content is empty """ def parse_content(self, content): if not content: - raise SkipException("Input content is empty") + raise SkipComponent("Input content is empty") self.value = content[0] diff --git a/insights/parsers/cpupower_frequency_info.py b/insights/parsers/cpupower_frequency_info.py index 73cf4fae05..87026a4b68 100644 --- a/insights/parsers/cpupower_frequency_info.py +++ b/insights/parsers/cpupower_frequency_info.py @@ -3,7 +3,7 @@ =================================================================== """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -51,7 +51,7 @@ class CpupowerFrequencyInfo(CommandParser, dict): Active: yes Raises: - SkipException: When input is empty. + SkipComponent: When input is empty. ParseException: When input cannot be parsed. Examples: @@ -72,7 +72,7 @@ class CpupowerFrequencyInfo(CommandParser, dict): def parse_content(self, content): if not content: - raise SkipException("Empty content") + raise SkipComponent("Empty content") if len(content) < 10 or not ('analyzing CPU' in content[0]): raise ParseException("Incorrect content: '{0}'".format(content)) diff --git a/insights/parsers/crypto_policies.py b/insights/parsers/crypto_policies.py index 66742b8418..72594a69ad 100644 --- a/insights/parsers/crypto_policies.py +++ b/insights/parsers/crypto_policies.py @@ -19,7 +19,7 @@ ------------------------------------------------------------------------ """ from insights.core import Parser, SysconfigOptions -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -42,7 +42,7 @@ class CryptoPoliciesConfig(Parser): """ def parse_content(self, content): if not content: - raise SkipException("/etc/crypto-policies/config is empty") + raise SkipComponent("/etc/crypto-policies/config is empty") self.value = get_active_lines(content)[0] @@ -63,7 +63,7 @@ class CryptoPoliciesStateCurrent(Parser): """ def parse_content(self, content): if not content: - raise SkipException("/etc/crypto-policies/state/current is empty") + raise SkipComponent("/etc/crypto-policies/state/current is empty") self.value = get_active_lines(content)[0] @@ -116,7 +116,7 @@ class CryptoPoliciesBind(Parser): """ def parse_content(self, content): if not content: - raise SkipException("/etc/crypto-policies/back-ends/bind.config is empty") + raise SkipComponent("/etc/crypto-policies/back-ends/bind.config is empty") self.value = content in_da = False in_ddd = False diff --git a/insights/parsers/cups_ppd.py b/insights/parsers/cups_ppd.py index 3f58a3dfa1..dbabc83f47 100644 --- a/insights/parsers/cups_ppd.py +++ b/insights/parsers/cups_ppd.py @@ -5,7 +5,7 @@ Parser to parse the content of files ``/etc/cups/ppd/*`` """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -43,7 +43,7 @@ class CupsPpd(Parser, dict): """ def parse_content(self, content): if not content: - raise SkipException("No Valid Configuration") + raise SkipComponent("No Valid Configuration") data = {} for line in content: if line.startswith("*") and ":" in line and not line.startswith("*%"): @@ -57,5 +57,5 @@ def parse_content(self, content): else: data[key] = value if not data: - raise SkipException("No Valid Configuration") + raise SkipComponent("No Valid Configuration") self.update(data) diff --git a/insights/parsers/date.py b/insights/parsers/date.py index 6e69956f47..49774470ac 100644 --- a/insights/parsers/date.py +++ b/insights/parsers/date.py @@ -17,7 +17,7 @@ from datetime import datetime from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -175,7 +175,7 @@ def parse_content(self, content): non_blank_line = line break if non_blank_line is None: - raise SkipException('No data in the output.') + raise SkipComponent('No data in the output.') try: colon_index = non_blank_line.index(':') except ValueError: diff --git a/insights/parsers/db2.py b/insights/parsers/db2.py index 0b27b51cb1..774546d4fa 100644 --- a/insights/parsers/db2.py +++ b/insights/parsers/db2.py @@ -8,7 +8,7 @@ ------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -41,7 +41,7 @@ class Db2ls(CommandParser, list): def parse_content(self, content): if not content: - raise SkipException("Empty.") + raise SkipComponent("Empty.") keys = [] for line in content: if not keys and line.startswith('#PATH'): @@ -51,4 +51,4 @@ def parse_content(self, content): line_splits.extend([i.strip(': ') for i in line_splits.pop(-1).rsplit(':', 1)]) self.append(dict(zip(keys, line_splits))) if len(self) == 0: - raise SkipException('Nothing to parse.') + raise SkipComponent('Nothing to parse.') diff --git a/insights/parsers/dig.py b/insights/parsers/dig.py index cd337406fa..cfbec36c0d 100644 --- a/insights/parsers/dig.py +++ b/insights/parsers/dig.py @@ -14,7 +14,7 @@ import re from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -33,7 +33,7 @@ class Dig(CommandParser): command (string): Specific ``dig`` command used. Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. """ def __init__(self, context, command): self.status = None @@ -43,7 +43,7 @@ def __init__(self, context, command): def parse_content(self, content): if not content: - raise SkipException('No content.') + raise SkipComponent('No content.') for line in content: match = HEADER_TEMPLATE.search(line) diff --git a/insights/parsers/dnf_module.py b/insights/parsers/dnf_module.py index 47585611ca..712976283e 100644 --- a/insights/parsers/dnf_module.py +++ b/insights/parsers/dnf_module.py @@ -11,7 +11,7 @@ --------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import parse_fixed_table from insights.specs import Specs @@ -92,7 +92,7 @@ def parse_content(self, content): heading_ignore=['Name '], trailing_ignore=['Hint:', 'Error:']) if not data: - raise SkipException('Nothing need to parse.') + raise SkipComponent('Nothing need to parse.') for m in data: self.update({m['Name']: DnfModuleBrief(m)}) @@ -258,7 +258,7 @@ def _update_value(k, v): _update_value(mod_info.name, mod_info) if self.__len__() == 0: - raise SkipException('Nothing need to parse.') + raise SkipComponent('Nothing need to parse.') @property def modules(self): diff --git a/insights/parsers/docker_inspect.py b/insights/parsers/docker_inspect.py index e2e9694a9f..29d5d6dbda 100644 --- a/insights/parsers/docker_inspect.py +++ b/insights/parsers/docker_inspect.py @@ -8,7 +8,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.marshalling import unmarshal from insights.core.plugins import parser from insights.specs import Specs @@ -26,7 +26,7 @@ class DockerInspect(CommandParser, dict): as JSON, so "json.loads" is an option to parse the output in the future. Raises: - SkipException: If content is not provided + SkipComponent: If content is not provided """ def __init__(self, *args, **kwargs): deprecated( @@ -38,14 +38,14 @@ def __init__(self, *args, **kwargs): def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent content = "\n".join(list(content)) try: inspect_data = unmarshal(content) self.update(inspect_data[0]) except: - raise SkipException + raise SkipComponent @property def data(self): diff --git a/insights/parsers/docker_list.py b/insights/parsers/docker_list.py index 595213339b..f56f1516c8 100644 --- a/insights/parsers/docker_list.py +++ b/insights/parsers/docker_list.py @@ -22,7 +22,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import parse_fixed_table from insights.specs import Specs @@ -45,7 +45,7 @@ class DockerList(CommandParser): Raises: NotImplementedError: If `key_field` or `attr_name` is not defined - SkipException: If no data to parse + SkipComponent: If no data to parse """ key_field = None heading_ignore = [] @@ -67,14 +67,14 @@ def parse_content(self, content): # will output help when the spec is run due to incorrect arguments. So check # the content for any lines starting with Usage: so it can be skipped. if any(l for l in content if l.startswith("Usage: ")): - raise SkipException('No data only help output.') + raise SkipComponent('No data only help output.') self.rows = parse_fixed_table(content, heading_ignore=self.heading_ignore, header_substitute=self.substitutions) if not self.rows: - raise SkipException('No data.') + raise SkipComponent('No data.') data = {} for row in self.rows: diff --git a/insights/parsers/dotnet.py b/insights/parsers/dotnet.py index c2b8cee211..d4ce17471a 100644 --- a/insights/parsers/dotnet.py +++ b/insights/parsers/dotnet.py @@ -11,7 +11,7 @@ -------------------------------------------------------------------- """ from insights.core import CommandParser, ContainerParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -36,7 +36,7 @@ class DotNetVersion(CommandParser): def parse_content(self, content): if not content or len(content) > 1: - raise SkipException + raise SkipComponent self.major = self.minor = None self.raw = content[0].strip() diff --git a/insights/parsers/du.py b/insights/parsers/du.py index a46e7a89bc..7a39faa425 100644 --- a/insights/parsers/du.py +++ b/insights/parsers/du.py @@ -11,7 +11,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -53,7 +53,7 @@ class DiskUsage(CommandParser, dict): 182 Raises: - SkipException: When no data could be parsed. + SkipComponent: When no data could be parsed. ParseException: Raised when any problem parsing the command output. """ @@ -84,7 +84,7 @@ def parse_content(self, content): raise ParseException("Could not parse line: '{0}'". format(line)) if len(self) == 0: - raise SkipException('No data parsed') + raise SkipComponent('No data parsed') @parser(Specs.du_dirs) diff --git a/insights/parsers/fcoeadm_i.py b/insights/parsers/fcoeadm_i.py index 2379dc4691..e7f4444217 100644 --- a/insights/parsers/fcoeadm_i.py +++ b/insights/parsers/fcoeadm_i.py @@ -12,7 +12,7 @@ sub-dictionaries are kept in a list keyed in 'Interfaces'. """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -87,7 +87,7 @@ class FcoeadmI(CommandParser, dict): stat_list (list): FCoE interface(s) status Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty ParseException: When input content is not available to parse """ @@ -96,7 +96,7 @@ def parse_content(self, content): BADWD = "No useful data parsed in content: '{0}'".format(content) if not content: - raise SkipException(EMPTY) + raise SkipComponent(EMPTY) if len(content) < 6 and len(content) > 0: raise ParseException(BADWD) diff --git a/insights/parsers/findmnt.py b/insights/parsers/findmnt.py index d0f72f5554..a976b6f211 100644 --- a/insights/parsers/findmnt.py +++ b/insights/parsers/findmnt.py @@ -6,7 +6,7 @@ of command ``findmnt -lo+PROPAGATION``. """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search, parse_fixed_table from insights.specs import Specs @@ -48,7 +48,7 @@ def parse_content(self, content): self.cols = [] self.keywords = [] if not content: - raise SkipException("No data.") + raise SkipComponent("No data.") self.cols = parse_fixed_table(content, header_substitute=[ diff --git a/insights/parsers/firewall_config.py b/insights/parsers/firewall_config.py index d86879990e..80b0f6e848 100644 --- a/insights/parsers/firewall_config.py +++ b/insights/parsers/firewall_config.py @@ -15,7 +15,7 @@ 'public' """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -30,4 +30,4 @@ class FirewallDConf(Parser, dict): def parse_content(self, content): self.update(split_kv_pairs(content, use_partition=False)) if not self: - raise SkipException("empty content") + raise SkipComponent("empty content") diff --git a/insights/parsers/gcp_instance_type.py b/insights/parsers/gcp_instance_type.py index 85a21e523f..17f95b5a23 100644 --- a/insights/parsers/gcp_instance_type.py +++ b/insights/parsers/gcp_instance_type.py @@ -12,7 +12,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -30,7 +30,7 @@ class GCPInstanceType(CommandParser): Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. ParseException: When type cannot be recognized. Attributes: @@ -50,7 +50,7 @@ class GCPInstanceType(CommandParser): def parse_content(self, content): if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() self.raw_line = self.raw = self.type = self.size = None # Ignore any curl stats that may be present in data diff --git a/insights/parsers/gcp_license_codes.py b/insights/parsers/gcp_license_codes.py index a4adc77422..d65eb8c34f 100644 --- a/insights/parsers/gcp_license_codes.py +++ b/insights/parsers/gcp_license_codes.py @@ -12,7 +12,7 @@ import json from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -29,7 +29,7 @@ class GCPLicenseCodes(CommandParser): [{"id": "601259152637613565"}] Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. ParseException: When the json is unable to be parsed Attributes: @@ -45,7 +45,7 @@ class GCPLicenseCodes(CommandParser): def parse_content(self, content): if not content or 'curl: ' in content[0]: - raise SkipException() + raise SkipComponent() try: license_list = json.loads(content[0]) except: diff --git a/insights/parsers/getsebool.py b/insights/parsers/getsebool.py index 70a8b11fc3..0ec4d6dad9 100644 --- a/insights/parsers/getsebool.py +++ b/insights/parsers/getsebool.py @@ -23,7 +23,7 @@ 'off' """ from insights.core import CommandParser, LegacyItemAccess -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -39,12 +39,12 @@ class Getsebool(LegacyItemAccess, CommandParser): So we can return the value like {"tmpreaper_use_nfs":"off", "tmpreaper_use_samba":"off"} Raises: - SkipException: When SELinux is not enabled. + SkipComponent: When SELinux is not enabled. """ def parse_content(self, content): if content and 'selinux is disabled' in content[0].lower(): - raise SkipException('SELinux is disabled') + raise SkipComponent('SELinux is disabled') self.data = {} for line in content: diff --git a/insights/parsers/gfs2_file_system_block_size.py b/insights/parsers/gfs2_file_system_block_size.py index bae587dd82..57bad3ed9e 100644 --- a/insights/parsers/gfs2_file_system_block_size.py +++ b/insights/parsers/gfs2_file_system_block_size.py @@ -5,7 +5,7 @@ The parser parse the output of ``stat -fc %s `` """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -28,7 +28,7 @@ class GFS2FileSystemBlockSize(CommandParser): Raise:: - SkipException: When the content isn't in the expected format. + SkipComponent: When the content isn't in the expected format. Attributes:: @@ -39,4 +39,4 @@ def parse_content(self, content): if len(content) == 1 and content[0].isdigit(): self.block_size = int(content[0]) else: - raise SkipException('The output is invalid.') + raise SkipComponent('The output is invalid.') diff --git a/insights/parsers/gluster_peer_status.py b/insights/parsers/gluster_peer_status.py index 0cd5f18266..6fb9fd05d0 100644 --- a/insights/parsers/gluster_peer_status.py +++ b/insights/parsers/gluster_peer_status.py @@ -3,7 +3,7 @@ =================================================== """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -52,7 +52,7 @@ def _grouper(self, iterable, n, fillvalue=None): def parse_content(self, content): if not content: - raise SkipException("No data.") + raise SkipComponent("No data.") self.status = {'peers': 0, 'hosts': []} self.status['peers'] = int(content[0].split(':')[-1].strip()) diff --git a/insights/parsers/grub_conf.py b/insights/parsers/grub_conf.py index 4f5e17892c..1505f4c1e3 100644 --- a/insights/parsers/grub_conf.py +++ b/insights/parsers/grub_conf.py @@ -52,7 +52,7 @@ """ from insights.components.rhel_version import IsRhel6, IsRhel7, IsRhel8, IsRhel9 from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -367,14 +367,14 @@ class BootLoaderEntries(Parser, dict): cmdline(str): the cmdline of the saved boot entry Raises: - SkipException: when input content is empty or no useful data. + SkipComponent: when input content is empty or no useful data. """ def parse_content(self, content): """ Parses the ``/boot/loader/entries/*.conf`` files. """ if not content: - raise SkipException() + raise SkipComponent() self.entry = {} self.title = '' @@ -386,7 +386,7 @@ def parse_content(self, content): self.cmdline = value if not self.entry: - raise SkipException() + raise SkipComponent() self.update(self.entry) self.title = self.entry.get('title') diff --git a/insights/parsers/grubby.py b/insights/parsers/grubby.py index 121a10b484..586249855a 100644 --- a/insights/parsers/grubby.py +++ b/insights/parsers/grubby.py @@ -12,7 +12,7 @@ --------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -31,7 +31,7 @@ class GrubbyDefaultIndex(CommandParser): 0 Raises: - SkipException: When output is empty + SkipComponent: When output is empty ParseException: When output is invalid Attributes: @@ -39,7 +39,7 @@ class GrubbyDefaultIndex(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException('Empty output') + raise SkipComponent('Empty output') if len(content) != 1 or not content[0].isdigit(): raise ParseException('Invalid output: {0}', content) self.default_index = int(content[0]) @@ -60,7 +60,7 @@ class GrubbyDefaultKernel(CommandParser): '/boot/vmlinuz-2.6.32-573.el6.x86_64' Raises: - SkipException: When output is empty + SkipComponent: When output is empty ParseException: When output is invalid Attributes: @@ -68,7 +68,7 @@ class GrubbyDefaultKernel(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException('Empty output') + raise SkipComponent('Empty output') if len(content) != 1 or len(content[0].split()) > 1: raise ParseException('Invalid output: {0}', content) self.default_kernel = content[0].strip() diff --git a/insights/parsers/grubenv.py b/insights/parsers/grubenv.py index ba3fd305c6..f9a9c72999 100644 --- a/insights/parsers/grubenv.py +++ b/insights/parsers/grubenv.py @@ -9,7 +9,7 @@ ---------------------------------------- """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -66,7 +66,7 @@ def __init__(self, context): def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") self._errors = [] data = dict() @@ -82,7 +82,7 @@ def parse_content(self, content): data[key] = value if (not data) and (not self._errors): - raise SkipException("No parsed data.") + raise SkipComponent("No parsed data.") self.update(data) diff --git a/insights/parsers/hammer_ping.py b/insights/parsers/hammer_ping.py index 8ff53e32d0..b84f570c14 100644 --- a/insights/parsers/hammer_ping.py +++ b/insights/parsers/hammer_ping.py @@ -34,7 +34,7 @@ ['elasticsearch', 'foreman_tasks'] """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -81,7 +81,7 @@ def parse_content(self, content): service_name = None content = list(filter(None, (line.split(comment_char, 1)[0].rstrip() for line in content))) if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") for line in content: items = [item for item in line.split(':', 1)] diff --git a/insights/parsers/hammer_task_list.py b/insights/parsers/hammer_task_list.py index 07faf71c43..9a3c11bbde 100644 --- a/insights/parsers/hammer_task_list.py +++ b/insights/parsers/hammer_task_list.py @@ -53,7 +53,7 @@ import csv from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -65,7 +65,7 @@ class HammerTaskList(CommandParser, list): Parse the CSV output from the ``hammer --output csv task list`` command. Raises: - SkipException: When nothing is parsed. + SkipComponent: When nothing is parsed. Attributes: can_authenticate (bool): Whether we have valid data; if False it's @@ -81,7 +81,7 @@ def parse_content(self, content): strip_line = [item.strip() for item in line] self.append(dict(zip(headings, strip_line))) if len(self) <= 0: - raise SkipException() + raise SkipComponent() self._running_tasks = [t for t in self if t.get('State', t.get('state')) == 'running'] @property diff --git a/insights/parsers/hosts.py b/insights/parsers/hosts.py index 679535f26e..affdcb5f5e 100644 --- a/insights/parsers/hosts.py +++ b/insights/parsers/hosts.py @@ -33,7 +33,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -66,7 +66,7 @@ def parse_content(self, content): self._data[ip].extend(names) if not self._data: - raise SkipException("No useful data") + raise SkipComponent("No useful data") @property def data(self): diff --git a/insights/parsers/httpd_V.py b/insights/parsers/httpd_V.py index 389bd4e394..f3a674cbab 100644 --- a/insights/parsers/httpd_V.py +++ b/insights/parsers/httpd_V.py @@ -11,7 +11,7 @@ compilation option is present. """ from insights.core import CommandParser, LegacyItemAccess -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -61,12 +61,12 @@ class HttpdV(LegacyItemAccess, CommandParser): compilation option is present. Raises: - SkipException: When input content is empty or there is no parsed data. + SkipComponent: When input content is empty or there is no parsed data. """ def parse_content(self, content): if not content: - raise SkipException("Input content is empty.") + raise SkipComponent("Input content is empty.") self.data = {} compiled_with = {} @@ -92,7 +92,7 @@ def parse_content(self, content): if compiled_with: self.data['Server compiled with'] = compiled_with else: - raise SkipException("Input content is not empty but there is no useful parsed data.") + raise SkipComponent("Input content is not empty but there is no useful parsed data.") @property def httpd_command(self): diff --git a/insights/parsers/ibm_proc.py b/insights/parsers/ibm_proc.py index 620d72a351..5731810577 100644 --- a/insights/parsers/ibm_proc.py +++ b/insights/parsers/ibm_proc.py @@ -11,7 +11,7 @@ ---------------------------------------------------------------------------- """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -31,12 +31,12 @@ class IBMPpcLparCfg(Parser, dict): '8247-22L' Raises: - SkipException: If nothing need to parse + SkipComponent: If nothing need to parse """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") for line in content: key, value = [l.strip() for l in line.split('=', 1)] @@ -44,7 +44,7 @@ def parse_content(self, content): self[key] = value.strip() if len(self) == 0: - raise SkipException("Nothing to parse.") + raise SkipComponent("Nothing to parse.") @parser(Specs.ibm_fw_vernum_encoded) @@ -66,16 +66,16 @@ class IBMFirmwareLevel(Parser): 'VL950_092' Raises: - SkipException: If nothing need to parse + SkipComponent: If nothing need to parse """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") self.raw = content[0] if "(" not in self.raw or ")" not in self.raw: - raise SkipException("Nothing to parse.") + raise SkipComponent("Nothing to parse.") self.firmware_level = self.raw[self.raw.index('(') + 1:self.raw.index(')')] diff --git a/insights/parsers/imagemagick_policy.py b/insights/parsers/imagemagick_policy.py index 3a9ea0b90e..f33997088b 100644 --- a/insights/parsers/imagemagick_policy.py +++ b/insights/parsers/imagemagick_policy.py @@ -3,7 +3,7 @@ =============================================================================================================== """ from insights.core import XMLParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -18,7 +18,7 @@ class ImageMagickPolicy(XMLParser): policies (list): list of Element objects with a 'policy' tag Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Sample output of this file is:: @@ -62,7 +62,7 @@ class ImageMagickPolicy(XMLParser): def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") try: super(ImageMagickPolicy, self).parse_content(content) diff --git a/insights/parsers/ip_netns_exec_namespace_lsof.py b/insights/parsers/ip_netns_exec_namespace_lsof.py index d8f0ab3115..e6bf11bf5a 100644 --- a/insights/parsers/ip_netns_exec_namespace_lsof.py +++ b/insights/parsers/ip_netns_exec_namespace_lsof.py @@ -10,7 +10,7 @@ from collections import namedtuple from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.parsers import keyword_search, parse_fixed_table @@ -43,7 +43,7 @@ class IpNetnsExecNamespaceLsofI(CommandParser): data (list): List of key value pair derived from the command. Raises: - SkipException: When the file is empty or data is useless. + SkipComponent: When the file is empty or data is useless. """ keyvalue = namedtuple("KeyValue", ["command", "pid", "user", "fd", "type", "device", "size_off", "node", "name"]) @@ -52,7 +52,7 @@ def parse_content(self, content): self.fields = [] self.data = [] if not content: - raise SkipException("Empty file") + raise SkipComponent("Empty file") self.data = parse_fixed_table(content, heading_ignore=["COMMAND", "PID", "USER", "FD", "TYPE", "DEVICE", "SIZE/OFF", "NODE", "NAME"], @@ -60,7 +60,7 @@ def parse_content(self, content): ("TYPE", "type"), ("DEVICE", "device"), ("SIZE/OFF", "size_off"), ("NODE", "node"), ("NAME", "name")]) if not self.data: - raise SkipException("Useless data") + raise SkipComponent("Useless data") for item in self.data: self.fields.append(self.keyvalue(item["command"], item["pid"], item["user"], item["fd"], item["type"], item["device"], diff --git a/insights/parsers/ipcs.py b/insights/parsers/ipcs.py index 54a342e535..a621de0751 100644 --- a/insights/parsers/ipcs.py +++ b/insights/parsers/ipcs.py @@ -18,7 +18,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, parse_delimited_table from insights.specs import Specs @@ -36,7 +36,7 @@ def parse_content(self, content): ids = ['semid', 'shmid', 'msqid'] table = parse_delimited_table(content, heading_ignore=['key'] + ids) if not table: - raise SkipException('Nothing to parse.') + raise SkipComponent('Nothing to parse.') id_s = [i for i in table[0] if i in ids] if not id_s or len(id_s) != 1: raise ParseException('Unexpected heading line.') diff --git a/insights/parsers/ipsec_conf.py b/insights/parsers/ipsec_conf.py index d1e2cde986..be2788a530 100644 --- a/insights/parsers/ipsec_conf.py +++ b/insights/parsers/ipsec_conf.py @@ -9,7 +9,7 @@ from collections import defaultdict from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -22,7 +22,7 @@ class IpsecConf(CommandParser, dict): and control information for the Libreswan IPsec subsystem Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Sample output of this command is:: @@ -56,7 +56,7 @@ class IpsecConf(CommandParser, dict): def parse_content(self, content): if not content: - raise SkipException('No content.') + raise SkipComponent('No content.') ipsec_type, ipsec_name = "", "" ipsec_sections = {} @@ -84,4 +84,4 @@ def parse_content(self, content): self[ipsec_type] = ipsec_sections except ValueError: - raise SkipException('Syntax error') + raise SkipComponent('Syntax error') diff --git a/insights/parsers/kernel_config.py b/insights/parsers/kernel_config.py index 9ebb4ef46b..fb385fb2e8 100644 --- a/insights/parsers/kernel_config.py +++ b/insights/parsers/kernel_config.py @@ -34,7 +34,7 @@ 'config-3.10.0-327.28.3.rt56.235.el7.x86_64' """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -51,7 +51,7 @@ class KernelConf(Parser, dict): def parse_content(self, content): if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") self._config_name = self.file_path.rsplit("/")[-1] lines = [l for l in content if not l.strip().startswith('#')] diff --git a/insights/parsers/kpatch_list.py b/insights/parsers/kpatch_list.py index 652739e4dc..af40423260 100644 --- a/insights/parsers/kpatch_list.py +++ b/insights/parsers/kpatch_list.py @@ -23,7 +23,7 @@ '3.10.0-1062.1.1.el7.x86_64' """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -33,7 +33,7 @@ class KpatchList(CommandParser): """Class for command: /usr/sbin/kpatch list""" def parse_content(self, content): if not content: - raise SkipException("No Data from command: /usr/sbin/kpatch list") + raise SkipComponent("No Data from command: /usr/sbin/kpatch list") self._loaded = {} self._installed = {} diff --git a/insights/parsers/ksmstate.py b/insights/parsers/ksmstate.py index 9cbadc5ec3..9599755fa6 100644 --- a/insights/parsers/ksmstate.py +++ b/insights/parsers/ksmstate.py @@ -6,7 +6,7 @@ ``/sys/kernel/mm/ksm/run``. """ from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -35,12 +35,12 @@ class KSMState(Parser): False Raises: - SkipException: when input is empty. + SkipComponent: when input is empty. ParseException: when the content is not expected. """ def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent if len(content) != 1 or content[0] not in ('0', '1', '2'): raise ParseException("Incorrect content: '{0}'".format(content)) diff --git a/insights/parsers/ktimer_lockless.py b/insights/parsers/ktimer_lockless.py index 4ddbf0bd1d..24d33d3792 100644 --- a/insights/parsers/ktimer_lockless.py +++ b/insights/parsers/ktimer_lockless.py @@ -3,7 +3,7 @@ =========================================================== """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -22,10 +22,10 @@ class KTimerLockless(Parser): 0 Raises: - SkipException: when input is empty. + SkipComponent: when input is empty. """ def parse_content(self, content): if len(content) == 1 and content[0].isdigit(): self.ktimer_lockless_val = int(content[0]) else: - raise SkipException('The file is empty') + raise SkipComponent('The file is empty') diff --git a/insights/parsers/ld_library_path.py b/insights/parsers/ld_library_path.py index 90225350ca..8787678dd3 100644 --- a/insights/parsers/ld_library_path.py +++ b/insights/parsers/ld_library_path.py @@ -8,7 +8,7 @@ from collections import namedtuple from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -48,7 +48,7 @@ class UserLdLibraryPath(Parser, list): True Raises: - SkipException: When the output is empty or nothing needs to parse. + SkipComponent: When the output is empty or nothing needs to parse. """ def parse_content(self, content): @@ -61,6 +61,6 @@ def parse_content(self, content): llds.append(LdLibraryPath(user, paths.split(':'), raw)) if not llds: - raise SkipException("LD_LIBRARY_PATH not set.") + raise SkipComponent("LD_LIBRARY_PATH not set.") self.extend(llds) diff --git a/insights/parsers/ldif_config.py b/insights/parsers/ldif_config.py index 0089f53522..28c5292eec 100644 --- a/insights/parsers/ldif_config.py +++ b/insights/parsers/ldif_config.py @@ -3,7 +3,7 @@ ========================================================== """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -78,7 +78,7 @@ class LDIFParser(Parser, list): """ def parse_content(self, content): if not content: - raise SkipException('The file is empty') + raise SkipComponent('The file is empty') attr_kval = {} for line in content: diff --git a/insights/parsers/libssh_config.py b/insights/parsers/libssh_config.py index b0d988dd92..8f6633feee 100644 --- a/insights/parsers/libssh_config.py +++ b/insights/parsers/libssh_config.py @@ -13,7 +13,7 @@ -------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -68,12 +68,12 @@ class LibsshConfig(CommandParser, dict): ['/etc/crypto-policies/back-ends/libssh.config', '/etc/ssh/sshd_config'] Raises: - SkipException: When input content is empty or there is a syntax error. + SkipComponent: When input content is empty or there is a syntax error. """ def parse_content(self, content): if not content: - raise SkipException('No content.') + raise SkipComponent('No content.') for line in get_active_lines(content): delimiter = None @@ -94,7 +94,7 @@ def parse_content(self, content): _v.append(v) self[k] = _v except ValueError: - raise SkipException('Syntax error') + raise SkipComponent('Syntax error') @parser(Specs.libssh_client_config) diff --git a/insights/parsers/losetup.py b/insights/parsers/losetup.py index 27b8f7cf09..22b1d69ce9 100644 --- a/insights/parsers/losetup.py +++ b/insights/parsers/losetup.py @@ -49,7 +49,7 @@ 512 """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import parse_delimited_table from insights.specs import Specs @@ -63,7 +63,7 @@ class LoSetup(CommandParser, list): def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") self.extend(parse_delimited_table(content)) for entry in self: diff --git a/insights/parsers/lpstat.py b/insights/parsers/lpstat.py index 616abda2dc..ba1572d242 100644 --- a/insights/parsers/lpstat.py +++ b/insights/parsers/lpstat.py @@ -9,7 +9,7 @@ LpstatProtocol - command ``/usr/bin/lpstat -v`` """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -114,7 +114,7 @@ class LpstatProtocol(CommandParser, dict): """ def parse_content(self, content): if not content: - raise SkipException("No Valid Output") + raise SkipComponent("No Valid Output") data = {} for line in content: if line.startswith("device for "): @@ -123,5 +123,5 @@ def parse_content(self, content): printer = line_split[0].split()[-1].strip() data[printer] = protocol if not data: - raise SkipException("No Valid Output") + raise SkipComponent("No Valid Output") self.update(data) diff --git a/insights/parsers/lscpu.py b/insights/parsers/lscpu.py index 7629222253..6c01465f5c 100644 --- a/insights/parsers/lscpu.py +++ b/insights/parsers/lscpu.py @@ -5,7 +5,7 @@ This module provides the information about the CPU architecture using the output of the command ``lscpu``. """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -61,7 +61,7 @@ class LsCPU(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException("No data.") + raise SkipComponent("No data.") self.info = {} split_on = ":" for line in content: diff --git a/insights/parsers/lspci.py b/insights/parsers/lspci.py index e5c157a5dc..2f425d985d 100644 --- a/insights/parsers/lspci.py +++ b/insights/parsers/lspci.py @@ -15,7 +15,7 @@ import re from insights.core import CommandParser, LogFileOutput -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -206,7 +206,7 @@ def parse_content(self, content): dev[key] = val if len(self) <= 1 and not dev: - raise SkipException() + raise SkipComponent() @property def pci_dev_list(self): diff --git a/insights/parsers/lssap.py b/insights/parsers/lssap.py index aeae79e1b5..d598671b89 100644 --- a/insights/parsers/lssap.py +++ b/insights/parsers/lssap.py @@ -29,7 +29,7 @@ 'D51' """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import parse_delimited_table from insights.specs import Specs @@ -40,7 +40,7 @@ class Lssap(CommandParser): """Class to parse ``lssap`` command output. Raises: - SkipException: Nothing needs to be parsed. + SkipComponent: Nothing needs to be parsed. ParseException: Raised if any error occurs parsing the content. Attributes: @@ -52,7 +52,7 @@ class Lssap(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException() + raise SkipComponent() self.data = [] # remove lssap version and bar text from content diff --git a/insights/parsers/lvm.py b/insights/parsers/lvm.py index c8911df14d..d259d324dd 100644 --- a/insights/parsers/lvm.py +++ b/insights/parsers/lvm.py @@ -38,7 +38,7 @@ import json from insights.core import CommandParser, LegacyItemAccess, Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.parsers import get_active_lines, optlist_to_dict, parse_fixed_table @@ -748,7 +748,7 @@ class LvmSystemDevices(Parser, dict): 'phl0clFbAokp9UXqbIgI5YYQxuTIJVkD' Raises: - SkipException: when there is no device info. + SkipComponent: when there is no device info. """ def parse_content(self, content): @@ -757,7 +757,7 @@ def parse_content(self, content): dict_info = optlist_to_dict(line, opt_sep=None) self[dict_info.pop('IDNAME')] = dict_info if not self: - raise SkipException("No valid content.") + raise SkipComponent("No valid content.") if __name__ == "__main__": diff --git a/insights/parsers/max_uid.py b/insights/parsers/max_uid.py index 84faf193b5..614dc42bb5 100644 --- a/insights/parsers/max_uid.py +++ b/insights/parsers/max_uid.py @@ -5,7 +5,7 @@ This module provides the MaxUID value gathered from the ``/etc/passwd`` file. """ from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -35,7 +35,7 @@ class MaxUID(Parser): 65534 Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. ParseException: When type cannot be recognized. Examples: @@ -45,7 +45,7 @@ class MaxUID(Parser): def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") for line in content: try: diff --git a/insights/parsers/mdadm.py b/insights/parsers/mdadm.py index 19257980c4..a47143e489 100644 --- a/insights/parsers/mdadm.py +++ b/insights/parsers/mdadm.py @@ -3,7 +3,7 @@ =============================================== """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -58,7 +58,7 @@ def parse_content(self, content): if mdadm_dev in self.file_path: self.device = '/dev/' + self.file_path.split(mdadm_dev)[1].strip() else: - raise SkipException('Cannot parse device name from path {p}'.format(p=self.file_path)) + raise SkipComponent('Cannot parse device name from path {p}'.format(p=self.file_path)) for key, val in split_kv_pairs(content, split_on=':').items(): if val.isdigit(): diff --git a/insights/parsers/mdstat.py b/insights/parsers/mdstat.py index 176dc0665f..a13703dcd6 100644 --- a/insights/parsers/mdstat.py +++ b/insights/parsers/mdstat.py @@ -5,7 +5,7 @@ import re from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -97,7 +97,7 @@ class Mdstat(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") self.mds = {} self.components = [] @@ -111,7 +111,7 @@ def parse_content(self, content): if line.startswith('Personalities'): # If the line doesn't have any raid types then md raid isn't active. if line == "Personalities :": - raise SkipException("No parseable md devices present.") + raise SkipComponent("No parseable md devices present.") in_component = False self.personalities = parse_personalities(line) diff --git a/insights/parsers/modinfo.py b/insights/parsers/modinfo.py index f1ba34bbaa..03e1953db3 100644 --- a/insights/parsers/modinfo.py +++ b/insights/parsers/modinfo.py @@ -14,7 +14,7 @@ -------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs from insights.util import deprecated @@ -35,10 +35,10 @@ def from_content(cls, content): well per the `content`. Raises: - SkipException: When nothing need to check to a dict. + SkipComponent: When nothing need to check to a dict. """ if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") data = {} for line in content: @@ -53,7 +53,7 @@ def from_content(cls, content): data[key].append(value) if not data: - raise SkipException("No Parsed Contents") + raise SkipComponent("No Parsed Contents") data['module_deps'] = list(data.get('depends', '').split(',')) data['module_name'] = data.get('filename', '').rsplit('/')[-1].split('.')[0] @@ -175,7 +175,7 @@ class KernelModulesInfo(CommandParser, dict): parm: int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int) Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Examples: >>> from insights.core.filters import add_filter @@ -205,7 +205,7 @@ class KernelModulesInfo(CommandParser, dict): """ def parse_content(self, content): if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") self.retpoline_y = set() self.retpoline_n = set() @@ -227,7 +227,7 @@ def parse_content(self, content): self.retpoline_n.add(name) if m.get('retpoline') == 'N' else None if len(self) == 0: - raise SkipException("No Parsed Contents") + raise SkipComponent("No Parsed Contents") @parser(Specs.modinfo_all) @@ -278,7 +278,7 @@ class ModInfoAll(KernelModulesInfo): parm: int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int) Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Examples: >>> type(modinfo_all) @@ -344,7 +344,7 @@ class ModInfoEach(CommandParser, ModInfo): parm: int_mode: Force interrupt mode other than MSI-X (1 INT#x; 2 MSI) (int) Raises: - SkipException: When nothing is need to parse + SkipComponent: When nothing is need to parse Examples: >>> type(modinfo_obj) diff --git a/insights/parsers/mount.py b/insights/parsers/mount.py index 4fa7ce9466..74bb1afbec 100644 --- a/insights/parsers/mount.py +++ b/insights/parsers/mount.py @@ -41,7 +41,7 @@ import os from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, keyword_search, optlist_to_dict from insights.specs import Specs @@ -144,7 +144,7 @@ class MountedFileSystems(CommandParser): :class:`MountEntry` objects as the value. Raises: - SkipException: When the file is empty. + SkipComponent: When the file is empty. ParseException: Raised when any problem parsing the command output. """ def __len__(self): @@ -165,7 +165,7 @@ def __getitem__(self, idx): def parse_content(self, content): # No content found or file is empty if not content: - raise SkipException('Empty content') + raise SkipComponent('Empty content') self._parse_mounts(content) diff --git a/insights/parsers/mpirun.py b/insights/parsers/mpirun.py index 16bb7228be..189e26fdfb 100644 --- a/insights/parsers/mpirun.py +++ b/insights/parsers/mpirun.py @@ -6,7 +6,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -29,9 +29,9 @@ class MPIrunVersion(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") if len(content) != 2: - raise SkipException("Content not parsable.") + raise SkipComponent("Content not parsable.") self.year = content[0].split('Version ')[1].split(" ")[0] self.version = content[0].split(', ')[-1] diff --git a/insights/parsers/multipath_conf.py b/insights/parsers/multipath_conf.py index 08480cea37..d919d5d866 100644 --- a/insights/parsers/multipath_conf.py +++ b/insights/parsers/multipath_conf.py @@ -17,7 +17,7 @@ from insights.contrib import pyparsing as p from insights.core import ConfigParser, LegacyItemAccess, Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsr import (EOF, Forward, LeftCurly, Lift, LineEnd, Literal, Many, Number, OneLineComment, PosMarker, QuotedString, @@ -135,7 +135,7 @@ def _create_parser(cls): def parse_content(self, content): if not content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") self.data = MultipathConfParser._create_parser().parseString("\n".join(content))[0].asDict() diff --git a/insights/parsers/mysqladmin.py b/insights/parsers/mysqladmin.py index d95061af66..08a3047dbc 100644 --- a/insights/parsers/mysqladmin.py +++ b/insights/parsers/mysqladmin.py @@ -16,7 +16,7 @@ import re from insights.core import CommandParser, LegacyItemAccess -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -52,7 +52,7 @@ def grouper(self, iterable, n, fillvalue=None): def parse_content(self, content): if not content: - raise SkipException("Content is empty.") + raise SkipComponent("Content is empty.") self.status = {} if self.pattern.search(content[0]): @@ -89,7 +89,7 @@ def parse_content(self, content): """ bad_lines = [] if not content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") if len(content) < 5: raise ParseException("Wrong content in table: '{0}'.".format(content)) diff --git a/insights/parsers/named_checkconf.py b/insights/parsers/named_checkconf.py index cd6c2a8510..676edf1571 100644 --- a/insights/parsers/named_checkconf.py +++ b/insights/parsers/named_checkconf.py @@ -9,7 +9,7 @@ import re from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -37,7 +37,7 @@ class NamedCheckconf(CommandParser): the value is a list of all digests associated with it. Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Sample output of this command is:: @@ -155,7 +155,7 @@ def __init__(self, context): def parse_content(self, content): if not content: - raise SkipException('No content.') + raise SkipComponent('No content.') full_result = '\n'.join(content) diff --git a/insights/parsers/named_conf.py b/insights/parsers/named_conf.py index 82aff5f2ab..57a07e003b 100644 --- a/insights/parsers/named_conf.py +++ b/insights/parsers/named_conf.py @@ -5,7 +5,7 @@ NamedConf parser the file named configuration file. Named is a name server used by BIND. """ -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers.named_checkconf import NamedCheckconf from insights.specs import Specs @@ -27,7 +27,7 @@ class NamedConf(NamedCheckconf): allow_recursion_address (list): List of address in 'allow-recursion' section. Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Examples: >>> named_conf.includes @@ -50,7 +50,7 @@ def parse_content(self, content): allow_recursion_address.extend(i.strip(';') for i in line.split(None, 1)[1].strip('{}; ').split()) except IndexError: - raise SkipException("Syntax error of include directive") + raise SkipComponent("Syntax error of include directive") self.includes = includes self.allow_recursion_address = allow_recursion_address diff --git a/insights/parsers/net_namespace.py b/insights/parsers/net_namespace.py index 6e3b7a4a46..fe027f8f9f 100644 --- a/insights/parsers/net_namespace.py +++ b/insights/parsers/net_namespace.py @@ -21,7 +21,7 @@ 3 """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -31,7 +31,7 @@ class NetworkNamespace(Parser): def parse_content(self, content): if not content: - raise SkipException('Nothing to parse.') + raise SkipComponent('Nothing to parse.') self._netns_list = [] for line in get_active_lines(content): diff --git a/insights/parsers/netstat.py b/insights/parsers/netstat.py index 38ce809c7e..1e8b958fcc 100644 --- a/insights/parsers/netstat.py +++ b/insights/parsers/netstat.py @@ -29,7 +29,7 @@ from collections import defaultdict from insights.core import CommandParser, LegacyItemAccess, Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search, parse_delimited_table from insights.specs import Specs @@ -777,7 +777,7 @@ class ProcNsat(Parser): def parse_content(self, content): self.data = {} if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") tcp_hdr = content[0].split()[1:] tcp_hdr_len = len(tcp_hdr) tcp_stat = content[1].split()[1:] diff --git a/insights/parsers/networkmanager_dhclient.py b/insights/parsers/networkmanager_dhclient.py index 1f0524762f..ce79e8e16e 100644 --- a/insights/parsers/networkmanager_dhclient.py +++ b/insights/parsers/networkmanager_dhclient.py @@ -5,7 +5,7 @@ import re from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -44,7 +44,7 @@ class NetworkManagerDhclient(Parser): has_vulnerable_block (bool): True, if the vulnerable block is present, False otherwise. Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Sample output of this command is:: @@ -98,7 +98,7 @@ class NetworkManagerDhclient(Parser): """ def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") result = "\n".join(content) match_rhel_6 = VULNERABLE_BLOCK_RHEL_6.search(result) diff --git a/insights/parsers/nfnetlink_queue.py b/insights/parsers/nfnetlink_queue.py index 947483e3c8..2c939c6cf4 100644 --- a/insights/parsers/nfnetlink_queue.py +++ b/insights/parsers/nfnetlink_queue.py @@ -3,7 +3,7 @@ ============================================================= """ from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -49,7 +49,7 @@ class NfnetLinkQueue(Parser, list): def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") data = [] fields = ['queue_number', 'peer_portid', 'queue_total', 'copy_mode', @@ -64,7 +64,7 @@ def parse_content(self, content): data.append(dict(zip(fields, parts))) if not data: - raise SkipException("No parsed data.") + raise SkipComponent("No parsed data.") self.extend(data) diff --git a/insights/parsers/nmcli.py b/insights/parsers/nmcli.py index b52248cb03..4dcfd47c87 100644 --- a/insights/parsers/nmcli.py +++ b/insights/parsers/nmcli.py @@ -15,7 +15,7 @@ import re from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, parse_fixed_table from insights.specs import Specs @@ -90,7 +90,7 @@ class NmcliDevShow(CommandParser, dict): """ def parse_content(self, content): if not content: - raise SkipException() + raise SkipComponent() data = {} per_device = {} @@ -121,7 +121,7 @@ def parse_content(self, content): data[current_dev] = per_device if not data: - raise SkipException() + raise SkipComponent() self.update(data) self._con_dev = [k for k, v in data.items() if 'STATE' in v and v['STATE'] == 'connected'] @@ -181,7 +181,7 @@ def parse_content(self, content): try: self.data = parse_fixed_table(content, heading_ignore=["NAME", "UUID", "TYPE", "DEVICE"]) except: - raise SkipException("Invalid Contents!") + raise SkipComponent("Invalid Contents!") self._disconnected_connection = [] for all_connection in self.data: if all_connection['DEVICE'] == "--": diff --git a/insights/parsers/nova_user_ids.py b/insights/parsers/nova_user_ids.py index 01c69a8dee..39e481c699 100644 --- a/insights/parsers/nova_user_ids.py +++ b/insights/parsers/nova_user_ids.py @@ -15,7 +15,7 @@ --------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -39,15 +39,15 @@ class NovaUID(CommandParser): data: ``int`` if 'nova' user exist. Raises: - SkipException: If 'nova' user not found or output is empty. + SkipComponent: If 'nova' user not found or output is empty. ParseException: For any other output which is not a number or multi-line. Outputs of such kind are not yet expected from the command `id`. ''' def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") if "no such user" in content[0].lower(): - raise SkipException("No such user.") + raise SkipComponent("No such user.") if len(content) > 1 or not content[0].isdigit(): raise ParseException("Unable to parse user ID: {0}".format(content)) self.data = int(content[0]) @@ -72,7 +72,7 @@ class NovaMigrationUID(NovaUID): data: ``int`` if 'nova_migration' user exist. Raises: - SkipException: If 'nova_migration' user not found or output is empty. + SkipComponent: If 'nova_migration' user not found or output is empty. ParseException: For any other output which is not a number or multi-line. Output of such kind are not yet expected from the command `id`. ''' diff --git a/insights/parsers/numa_cpus.py b/insights/parsers/numa_cpus.py index df4a072095..8ab352a591 100644 --- a/insights/parsers/numa_cpus.py +++ b/insights/parsers/numa_cpus.py @@ -22,7 +22,7 @@ 14 """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -36,7 +36,7 @@ class NUMACpus(LegacyItemAccess, Parser): def parse_content(self, content): if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") self.data = {} self._cpu_ranges = [] diff --git a/insights/parsers/nvme_core_io_timeout.py b/insights/parsers/nvme_core_io_timeout.py index abb3608a63..439eba85ba 100644 --- a/insights/parsers/nvme_core_io_timeout.py +++ b/insights/parsers/nvme_core_io_timeout.py @@ -5,7 +5,7 @@ This parser reads the content of ``/sys/module/nvme_core/parameters/io_timeout``. """ from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -20,7 +20,7 @@ class NVMeCoreIOTimeout(Parser): 4294967295 Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. ParseException: When type cannot be recognized. Attributes: @@ -33,7 +33,7 @@ class NVMeCoreIOTimeout(Parser): def parse_content(self, content): if not content or len(content) != 1: - raise SkipException() + raise SkipComponent() if not content[0].strip('').isdigit(): raise ParseException("Unexpected content: ", content) self.val = int(content[0].strip()) diff --git a/insights/parsers/od_cpu_dma_latency.py b/insights/parsers/od_cpu_dma_latency.py index f0e1cd41ba..75161828cc 100644 --- a/insights/parsers/od_cpu_dma_latency.py +++ b/insights/parsers/od_cpu_dma_latency.py @@ -6,7 +6,7 @@ ``/usr/bin/od -An -t d /dev/cpu_dma_latency`` command output. """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -34,4 +34,4 @@ def parse_content(self, content): if content and content[0].isdigit(): self.force_latency = int(content[0]) else: - raise SkipException('Nothing to parse.') + raise SkipComponent('Nothing to parse.') diff --git a/insights/parsers/open_vm_tools.py b/insights/parsers/open_vm_tools.py index e65a63aa91..e68d8f7afd 100644 --- a/insights/parsers/open_vm_tools.py +++ b/insights/parsers/open_vm_tools.py @@ -10,7 +10,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -37,7 +37,7 @@ class OpenVmToolsStatRawTextSession(CommandParser, dict): def parse_content(self, content): if not content or 'must be run inside a virtual machine' in content[0]: - raise SkipException + raise SkipComponent data = dict() for line in content: @@ -46,6 +46,6 @@ def parse_content(self, content): data[key] = value if not data: - raise SkipException + raise SkipComponent self.update(data) diff --git a/insights/parsers/ovs_appctl_fdb_show_bridge.py b/insights/parsers/ovs_appctl_fdb_show_bridge.py index 94ccfa6830..a9e4d90580 100644 --- a/insights/parsers/ovs_appctl_fdb_show_bridge.py +++ b/insights/parsers/ovs_appctl_fdb_show_bridge.py @@ -12,7 +12,7 @@ 3 0 MAC2 24 """ from insights.core import CommandParser, LegacyItemAccess -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -46,7 +46,7 @@ class OVSappctlFdbShowBridge(CommandParser, LegacyItemAccess): value. Raises: - SkipException: When the file is empty or data is not present for a bridge. + SkipComponent: When the file is empty or data is not present for a bridge. Examples: @@ -60,7 +60,7 @@ class OVSappctlFdbShowBridge(CommandParser, LegacyItemAccess): def parse_content(self, content): if len(content) == 0: - raise SkipException("Empty file") + raise SkipComponent("Empty file") self.data = {} # Extract the bridge name @@ -69,4 +69,4 @@ def parse_content(self, content): header = content[0].split() self.data[bridge_name] = [dict(zip(header, entry.split(None, len(header)))) for entry in content[1:]] if not self.data[bridge_name]: - raise SkipException("No data present for {0}".format(bridge_name)) + raise SkipComponent("No data present for {0}".format(bridge_name)) diff --git a/insights/parsers/ovs_ofctl_dump_flows.py b/insights/parsers/ovs_ofctl_dump_flows.py index 16433ba0cc..59659367b0 100644 --- a/insights/parsers/ovs_ofctl_dump_flows.py +++ b/insights/parsers/ovs_ofctl_dump_flows.py @@ -6,7 +6,7 @@ output of command ``/usr/bin/ovs-ofctl dump-flows ``. """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -41,7 +41,7 @@ class OVSofctlDumpFlows(CommandParser): def parse_content(self, content): if not content: - raise SkipException("Empty Content!") + raise SkipComponent("Empty Content!") self._bridges = [] @@ -49,7 +49,7 @@ def parse_content(self, content): try: self._bridge_name = self.file_path.split("ovs-ofctl_dump-flows_")[1] except: - raise SkipException("Invalid Path!") + raise SkipComponent("Invalid Path!") for line in content: line = line.split(',') @@ -57,7 +57,7 @@ def parse_content(self, content): if flow_list: self._bridges.append(flow_list) if not self._bridges: - raise SkipException("Invalid Content!") + raise SkipComponent("Invalid Content!") @property def bridge_name(self): diff --git a/insights/parsers/ovs_vsctl.py b/insights/parsers/ovs_vsctl.py index 54d65b42ed..a098e1244d 100644 --- a/insights/parsers/ovs_vsctl.py +++ b/insights/parsers/ovs_vsctl.py @@ -13,7 +13,7 @@ --------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, optlist_to_dict from insights.specs import Specs @@ -26,7 +26,7 @@ class OVSvsctlList(CommandParser, list): data types as string, numbers, list or dictionary. Raises: - SkipException: When file is empty. + SkipComponent: When file is empty. """ def parse_content(self, content): """ @@ -35,7 +35,7 @@ def parse_content(self, content): """ # No content found or file is empty if not content: - raise SkipException("Empty file") + raise SkipComponent("Empty file") record = {} for line in get_active_lines(content): diff --git a/insights/parsers/ovs_vsctl_list_bridge.py b/insights/parsers/ovs_vsctl_list_bridge.py index ae31a786d6..db5fb87b47 100644 --- a/insights/parsers/ovs_vsctl_list_bridge.py +++ b/insights/parsers/ovs_vsctl_list_bridge.py @@ -57,7 +57,7 @@ class OVSvsctlListBridge(OVSvsctlList): element contains the details of a bridge. Raises: - SkipException: When file is empty. + SkipComponent: When file is empty. """ def __init__(self, *args, **kwargs): deprecated( diff --git a/insights/parsers/package_provides.py b/insights/parsers/package_provides.py index 2a1c224ce5..50c30f8d50 100644 --- a/insights/parsers/package_provides.py +++ b/insights/parsers/package_provides.py @@ -3,7 +3,7 @@ ================================================================ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -30,7 +30,7 @@ class PackageProvidesCommand(CommandParser, dict): /opt/rh/httpd24/root/usr/sbin/httpd httpd24-httpd-2.4.34-7.el7.x86_64 Raises: - SkipException: When no such command detected running on this host. + SkipComponent: When no such command detected running on this host. ParseException: When there is un-parseble line. Example: @@ -57,7 +57,7 @@ def parse_content(self, content): data[l_sp[0]] = l_sp[1] if len(data) == 0: - raise SkipException() + raise SkipComponent() self.update(data) diff --git a/insights/parsers/partitions.py b/insights/parsers/partitions.py index 06f522af93..05d3231f28 100644 --- a/insights/parsers/partitions.py +++ b/insights/parsers/partitions.py @@ -7,7 +7,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import parse_delimited_table from insights.specs import Specs @@ -38,12 +38,12 @@ class Partitions(Parser, dict): [('blocks', '19531250'), ('major', '3'), ('minor', '0'), ('name', 'hda')] Raises: - SkipException: When input is empty. + SkipComponent: When input is empty. """ def parse_content(self, content): if not content: - raise SkipException('Empty content') + raise SkipComponent('Empty content') self.update(dict( (row['name'], row) diff --git a/insights/parsers/passenger_status.py b/insights/parsers/passenger_status.py index 6f58cab78b..b465cac023 100644 --- a/insights/parsers/passenger_status.py +++ b/insights/parsers/passenger_status.py @@ -5,7 +5,7 @@ following parsers: """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -58,12 +58,12 @@ class PassengerStatus(CommandParser, dict): 3 Raises: - SkipException: When input content is empty or there is no useful data. + SkipComponent: When input content is empty or there is no useful data. """ def parse_content(self, content): if len(content) <= 1: - raise SkipException("Empty content") + raise SkipComponent("Empty content") group = '' data = {} @@ -98,7 +98,7 @@ def parse_content(self, content): group_list[key] = val if not data: - raise SkipException("No useful data") + raise SkipComponent("No useful data") self.update(data) @property diff --git a/insights/parsers/pci_rport_target_disk_paths.py b/insights/parsers/pci_rport_target_disk_paths.py index 327782314a..055ae5e4d9 100644 --- a/insights/parsers/pci_rport_target_disk_paths.py +++ b/insights/parsers/pci_rport_target_disk_paths.py @@ -5,7 +5,7 @@ Module for parsing the output of command ``find /sys/devices/ -maxdepth 10 -mindepth 9 -name stat -type f``. """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -66,7 +66,7 @@ class PciRportTargetDiskPaths(CommandParser): Raises: ParseException: Input content is not available to parse - SkipException: Input content is empty + SkipComponent: Input content is empty Attributes: path_list (list): the result parsed @@ -147,7 +147,7 @@ def parse_content(self, content): ] if not content: - raise SkipException(EMPTY) + raise SkipComponent(EMPTY) pci = [] self.__host_attributes = set() diff --git a/insights/parsers/pcs_quorum_status.py b/insights/parsers/pcs_quorum_status.py index aac558269f..c70732b296 100644 --- a/insights/parsers/pcs_quorum_status.py +++ b/insights/parsers/pcs_quorum_status.py @@ -3,7 +3,7 @@ ================================================ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import parse_fixed_table from insights.specs import Specs @@ -48,7 +48,7 @@ class PcsQuorumStatus(CommandParser): membership_info (list): List of dicts where keys are the feature name of each node and values are the corresponding feature value. Raises: - SkipException: When input is empty. + SkipComponent: When input is empty. ParseException: When input cannot be parsed. Examples: @@ -64,7 +64,7 @@ class PcsQuorumStatus(CommandParser): def parse_content(self, content): if not content: - raise SkipException("Empty content") + raise SkipComponent("Empty content") if len(content) < 21 or not ('Quorum information' in content[0] and 'Votequorum information' in content[9] and 'Membership information' in content[17]): diff --git a/insights/parsers/php_ini.py b/insights/parsers/php_ini.py index 6dec6528c9..83f2becac4 100644 --- a/insights/parsers/php_ini.py +++ b/insights/parsers/php_ini.py @@ -54,7 +54,7 @@ from insights.core import ConfigParser from insights.core.filters import add_filter -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsr import (Char, EOF, HangingString, InSet, LeftBracket, Lift, LineEnd, Literal, Many, Number, @@ -141,7 +141,7 @@ def make_bytes(number, char_multiple): res = Entry(children=Top(content), src=self) return apply_defaults(res) - except SkipException: + except SkipComponent: raise except: raise ParseException(ParseException("Could not parse content: '{0}'". diff --git a/insights/parsers/pmrep.py b/insights/parsers/pmrep.py index 8a30428753..37db1a0e10 100644 --- a/insights/parsers/pmrep.py +++ b/insights/parsers/pmrep.py @@ -24,7 +24,7 @@ from csv import DictReader from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -35,7 +35,7 @@ class PMREPMetrics(CommandParser, list): """Parses output of ``pmrep -t 1s -T 1s -o csv`` command.""" def parse_content(self, content): if not content or len(content) == 1: - raise SkipException("There is no data in the table") + raise SkipComponent("There is no data in the table") try: reader = DictReader(content) except Exception: diff --git a/insights/parsers/podman_inspect.py b/insights/parsers/podman_inspect.py index 72561dfb60..d19be2a01d 100644 --- a/insights/parsers/podman_inspect.py +++ b/insights/parsers/podman_inspect.py @@ -8,7 +8,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.marshalling import unmarshal from insights.core.plugins import parser from insights.specs import Specs @@ -26,7 +26,7 @@ class PodmanInspect(CommandParser, dict): as JSON, so "json.loads" is an option to parse the output in the future. Raises: - SkipException: If content is not provided + SkipComponent: If content is not provided """ def __init__(self, *args, **kwargs): deprecated( @@ -38,7 +38,7 @@ def __init__(self, *args, **kwargs): def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent content = "\n".join(list(content)) @@ -46,7 +46,7 @@ def parse_content(self, content): inspect_data = unmarshal(content) self.update(inspect_data[0]) except: - raise SkipException + raise SkipComponent @parser(Specs.podman_image_inspect) diff --git a/insights/parsers/postconf.py b/insights/parsers/postconf.py index c1e247a355..b6e59295d7 100644 --- a/insights/parsers/postconf.py +++ b/insights/parsers/postconf.py @@ -6,7 +6,7 @@ ================================================= """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -36,7 +36,7 @@ class _Postconf(CommandParser, dict): def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent data = dict() for line in content: @@ -45,7 +45,7 @@ def parse_content(self, content): data[key] = value if not data: - raise SkipException + raise SkipComponent self.update(data) diff --git a/insights/parsers/proc_environ.py b/insights/parsers/proc_environ.py index 64ec00e8a6..24b9772822 100644 --- a/insights/parsers/proc_environ.py +++ b/insights/parsers/proc_environ.py @@ -7,7 +7,7 @@ """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -29,14 +29,14 @@ class ProcEnviron(Parser, LegacyItemAccess): True Raises: - insights.core.exceptions.SkipException: if the ``environ`` file is empty or doesn't exist. + insights.core.exceptions.SkipComponent: if the ``environ`` file is empty or doesn't exist. insights.core.exceptions.ParseException: if the ``environ`` file content is incorrect. """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") if len(content) != 1: raise ParseException("Incorrect content: '{0}'".format(content[-1])) diff --git a/insights/parsers/proc_keys.py b/insights/parsers/proc_keys.py index 098e3d1557..0f0299e272 100644 --- a/insights/parsers/proc_keys.py +++ b/insights/parsers/proc_keys.py @@ -6,7 +6,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -81,7 +81,7 @@ class ProcKeys(Parser, list): def parse_content(self, content): if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") column = ['id', 'flags', 'usage', 'timeout', 'permissions', 'uid', 'gid', 'type', 'description'] @@ -90,7 +90,7 @@ def parse_content(self, content): if row and len(column) == len(row): self.append(dict(zip(column, row))) else: - raise SkipException("Invalid Contents: {0}".format(line)) + raise SkipComponent("Invalid Contents: {0}".format(line)) def search(self, **kwargs): """ diff --git a/insights/parsers/puppet_ca_cert_expire_date.py b/insights/parsers/puppet_ca_cert_expire_date.py index ccbfe9e9c4..ae50759b93 100644 --- a/insights/parsers/puppet_ca_cert_expire_date.py +++ b/insights/parsers/puppet_ca_cert_expire_date.py @@ -17,7 +17,7 @@ datetime.datetime(2035, 12, 4, 7, 4, 5) """ -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers.ssl_certificate import CertificateInfo from insights.specs import Specs @@ -40,11 +40,11 @@ class PuppetCertExpireDate(CertificateInfo): expire_date (datetime): The date when the puppet ca cert will be expired Raises: - SkipException: when notAfter isn't in the output + SkipComponent: when notAfter isn't in the output """ def parse_content(self, content): super(PuppetCertExpireDate, self).parse_content(content) if 'notAfter' not in self: - raise SkipException("Cannot get the puppet ca cert expire info") + raise SkipComponent("Cannot get the puppet ca cert expire info") self.expire_date = self['notAfter'].datetime diff --git a/insights/parsers/rdma_config.py b/insights/parsers/rdma_config.py index 1da6d8da7a..f6fa87c44a 100644 --- a/insights/parsers/rdma_config.py +++ b/insights/parsers/rdma_config.py @@ -3,7 +3,7 @@ ========================================= """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, split_kv_pairs from insights.specs import Specs @@ -60,6 +60,6 @@ class RdmaConfig(Parser, LegacyItemAccess): def parse_content(self, content): _content = get_active_lines(content) if not _content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") self.data = split_kv_pairs(_content) diff --git a/insights/parsers/readlink_e_mtab.py b/insights/parsers/readlink_e_mtab.py index fd4c534a76..21801ed93f 100644 --- a/insights/parsers/readlink_e_mtab.py +++ b/insights/parsers/readlink_e_mtab.py @@ -13,7 +13,7 @@ '/proc/4578/mounts' """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -23,7 +23,7 @@ class ReadLinkEMtab(CommandParser): """Class for command: readlink -e /etc/mtab""" def parse_content(self, content): if content is None or len(content) == 0: - raise SkipException("No Data from command: readlink -e /etc/mtab") + raise SkipComponent("No Data from command: readlink -e /etc/mtab") for line in content: self._path = line # use the last line diff --git a/insights/parsers/readlink_openshift_certs.py b/insights/parsers/readlink_openshift_certs.py index d60e6375eb..35b083b77a 100644 --- a/insights/parsers/readlink_openshift_certs.py +++ b/insights/parsers/readlink_openshift_certs.py @@ -10,7 +10,7 @@ ------------------------------------------------------------------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -29,11 +29,11 @@ class ReadLinkEKubeletClientCurrent(CommandParser): '/etc/origin/node/certificates/kubelet-client-2019-10-18-23-17-35.pem' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ def parse_content(self, content): if content is None or len(content) == 0: - raise SkipException("No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-client-current.pem") + raise SkipComponent("No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-client-current.pem") self._path = content[-1] @@ -57,11 +57,11 @@ class ReadLinkEKubeletServerCurrent(CommandParser): '/etc/origin/node/certificates/kubelet-server-2018-10-18-23-29-14.pem' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ def parse_content(self, content): if content is None or len(content) == 0: - raise SkipException("No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-server-current.pem") + raise SkipComponent("No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-server-current.pem") self._path = content[-1] diff --git a/insights/parsers/rhev_data_center.py b/insights/parsers/rhev_data_center.py index 0aea82c189..7b2ece96d1 100644 --- a/insights/parsers/rhev_data_center.py +++ b/insights/parsers/rhev_data_center.py @@ -7,7 +7,7 @@ from re import compile as re_compile from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -25,7 +25,7 @@ class RhevDataCenter(CommandParser): the Data Center having incorrect file ownership. Raises: - SkipException: If no files are found with incorrect ownership. + SkipComponent: If no files are found with incorrect ownership. The following are available in ``data`` and ``incorrect_volume_ownership``: @@ -43,7 +43,7 @@ class RhevDataCenter(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException('No files found with incorrect ownership.') + raise SkipComponent('No files found with incorrect ownership.') self.data = json.loads(''.join(content)) # Full path of volumes attached to the RHEV VMs in the Data Center not having correct file ownership. diff --git a/insights/parsers/rhsm_releasever.py b/insights/parsers/rhsm_releasever.py index f2edaffd37..99be37eee8 100644 --- a/insights/parsers/rhsm_releasever.py +++ b/insights/parsers/rhsm_releasever.py @@ -5,7 +5,7 @@ """ from insights.core import JSONParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -27,7 +27,7 @@ class RhsmReleaseVer(JSONParser): {"releaseVer": "6.10"} Raises: - SkipException: When the json content of the file is empty.(i.e release version is empty. eg. {}) + SkipComponent: When the json content of the file is empty.(i.e release version is empty. eg. {}) Examples: >>> type(rhsm_releasever) @@ -49,7 +49,7 @@ def parse_content(self, content): super(RhsmReleaseVer, self).parse_content(content) self.set = self.major = self.minor = None if 'releaseVer' not in self.data: - raise SkipException('releaseVer is not in data') + raise SkipComponent('releaseVer is not in data') rel = self.data.get('releaseVer') or '' rel_splits = rel.split('.') # Release: 6.7 diff --git a/insights/parsers/rndc_status.py b/insights/parsers/rndc_status.py index f513d78025..a3af5ec5e8 100644 --- a/insights/parsers/rndc_status.py +++ b/insights/parsers/rndc_status.py @@ -3,7 +3,7 @@ ===================================== """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -34,7 +34,7 @@ class RndcStatus(CommandParser, dict): server is up and running Raises: - SkipException: When input is empty. + SkipComponent: When input is empty. ParseException: When input cannot be parsed. Examples: @@ -48,7 +48,7 @@ class RndcStatus(CommandParser, dict): def parse_content(self, content): if not content: - raise SkipException("Empty content") + raise SkipComponent("Empty content") for line in content: if ':' in line: k, v = line.split(':', 1) diff --git a/insights/parsers/sap_hana_python_script.py b/insights/parsers/sap_hana_python_script.py index 6b0ca617a9..1da8a40ad9 100644 --- a/insights/parsers/sap_hana_python_script.py +++ b/insights/parsers/sap_hana_python_script.py @@ -10,7 +10,7 @@ --------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -23,7 +23,7 @@ class SapHanaPython(CommandParser, list): overall_status(bool): The overall host status. Raises: - SkipException: When nothing is parsered. + SkipComponent: When nothing is parsered. """ def parse_content(self, content): @@ -47,7 +47,7 @@ def parse_content(self, content): self.append(dict(zip(keys, lsp))) if len(self) == 0: - raise SkipException + raise SkipComponent @parser(Specs.sap_hana_landscape) diff --git a/insights/parsers/sap_hdb_version.py b/insights/parsers/sap_hdb_version.py index d7e6065ddc..56b84f129e 100644 --- a/insights/parsers/sap_hdb_version.py +++ b/insights/parsers/sap_hdb_version.py @@ -7,7 +7,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -66,7 +66,7 @@ def parse_content(self, content): 'does not exist', ] if len(content) <= 1: - raise SkipException("Incorrect content.") + raise SkipComponent("Incorrect content.") data = {} self.sid = self.version = self.revision = None self.major = self.minor = self.patchlevel = None @@ -83,13 +83,13 @@ def parse_content(self, content): self.version = val val_splits = val.split('.') if len(val_splits) != 5: - raise SkipException("Incorrect HDB version: {0}.".format(val)) + raise SkipComponent("Incorrect HDB version: {0}.".format(val)) self.major = val_splits[0] self.minor = val_splits[1] self.revision = val_splits[2] self.patchlevel = val_splits[3] if not self.version: - raise SkipException("Incorrect content.") + raise SkipComponent("Incorrect content.") self.update(data) diff --git a/insights/parsers/sap_host_profile.py b/insights/parsers/sap_host_profile.py index 799513f624..8b6fa572a9 100644 --- a/insights/parsers/sap_host_profile.py +++ b/insights/parsers/sap_host_profile.py @@ -6,7 +6,7 @@ """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.parsers import get_active_lines @@ -48,6 +48,6 @@ def parse_content(self, content): self.data = {} for line in get_active_lines(content): if '=' not in line: - raise SkipException("Incorrect line: '{0}'".format(line)) + raise SkipComponent("Incorrect line: '{0}'".format(line)) key, val = line.split('=', 1) self.data[key.strip()] = val.strip() diff --git a/insights/parsers/sapcontrol.py b/insights/parsers/sapcontrol.py index 30bc6c8181..131b943049 100644 --- a/insights/parsers/sapcontrol.py +++ b/insights/parsers/sapcontrol.py @@ -7,7 +7,7 @@ ----------------------------------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import parse_delimited_table from insights.specs import Specs @@ -49,7 +49,7 @@ class SAPControlSystemUpdateList(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException("Empty output.") + raise SkipComponent("Empty output.") header = "hostname, instanceNr, status, starttime, endtime, dispstatus" if len(content) <= 3 or header not in content: @@ -64,7 +64,7 @@ def parse_content(self, content): heading_ignore=header_sp) if not self.data: - raise SkipException("Empty or useless output.") + raise SkipComponent("Empty or useless output.") self.is_running = all(l['status'] == 'Running' for l in self.data) self.is_green = all(l['dispstatus'] == 'GREEN' for l in self.data) diff --git a/insights/parsers/saphostctrl.py b/insights/parsers/saphostctrl.py index fabe0d99bb..85fad70b10 100644 --- a/insights/parsers/saphostctrl.py +++ b/insights/parsers/saphostctrl.py @@ -8,7 +8,7 @@ ------------------------------------------------------------------------------------------------ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.specs import Specs @@ -77,7 +77,7 @@ class SAPHostCtrlInstances(CommandParser, list): `SystemNumber`. Raises: - SkipException: When input is empty. + SkipComponent: When input is empty. ParseException: When input cannot be parsed. """ REQUIRED_DIRECTIVES = ( @@ -118,7 +118,7 @@ def parse_content(self, content): _sids.add(fields[2]) if fields[0] == 'SID' else None if len(self) < 1: - raise SkipException("Nothing need to parse") + raise SkipComponent("Nothing need to parse") self.sids = list(_sids) self.types = list(_types) diff --git a/insights/parsers/saphostexec.py b/insights/parsers/saphostexec.py index c2340d640c..3ebd500d90 100644 --- a/insights/parsers/saphostexec.py +++ b/insights/parsers/saphostexec.py @@ -11,8 +11,9 @@ ----------------------------------------------------- """ from collections import namedtuple + from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -59,7 +60,7 @@ def parse_content(self, content): if data: self.update(data) else: - raise SkipException + raise SkipComponent @property def is_running(self): @@ -148,7 +149,7 @@ def parse_content(self, content): if data: self.update(data) else: - raise SkipException + raise SkipComponent @property def data(self): diff --git a/insights/parsers/sat5_insights_properties.py b/insights/parsers/sat5_insights_properties.py index 1ad6b9948b..9ad8b0de2e 100644 --- a/insights/parsers/sat5_insights_properties.py +++ b/insights/parsers/sat5_insights_properties.py @@ -3,7 +3,7 @@ =================================================================== """ from insights.core import LegacyItemAccess, Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -36,11 +36,11 @@ class Sat5InsightsProperties(LegacyItemAccess, Parser): Otherwise, False Raises: - SkipException: When file content is empty. + SkipComponent: When file content is empty. """ def parse_content(self, content): if not content: - raise SkipException('Empty content.') + raise SkipComponent('Empty content.') self.data = {} for line in get_active_lines(content): diff --git a/insights/parsers/satellite_content_hosts_count.py b/insights/parsers/satellite_content_hosts_count.py index 3b8eec4141..00d3afe3f0 100644 --- a/insights/parsers/satellite_content_hosts_count.py +++ b/insights/parsers/satellite_content_hosts_count.py @@ -20,7 +20,7 @@ 13 """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -43,4 +43,4 @@ def parse_content(self, content): except ValueError: raise ParseException("Unknow satelite content hosts count") if self.count is None: - raise SkipException("Cannot get the count of satellite content hosts") + raise SkipComponent("Cannot get the count of satellite content hosts") diff --git a/insights/parsers/satellite_enabled_features.py b/insights/parsers/satellite_enabled_features.py index 1f37784b72..646496cd32 100644 --- a/insights/parsers/satellite_enabled_features.py +++ b/insights/parsers/satellite_enabled_features.py @@ -19,7 +19,7 @@ False """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -36,4 +36,4 @@ def parse_content(self, content): features = line.strip('[]') self.extend([feature.strip('"') for feature in features.split(',') if feature]) if len(self) == 0: - raise SkipException + raise SkipComponent diff --git a/insights/parsers/satellite_installer_configurations.py b/insights/parsers/satellite_installer_configurations.py index 308246499d..6ec04b2f1f 100644 --- a/insights/parsers/satellite_installer_configurations.py +++ b/insights/parsers/satellite_installer_configurations.py @@ -10,7 +10,7 @@ """ from insights.core import YAMLParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -29,5 +29,5 @@ class CustomHiera(YAMLParser): def parse_content(self, content): try: super(CustomHiera, self).parse_content(content) - except SkipException: + except SkipComponent: pass diff --git a/insights/parsers/satellite_mongodb.py b/insights/parsers/satellite_mongodb.py index 825820d1ce..b543f1deef 100644 --- a/insights/parsers/satellite_mongodb.py +++ b/insights/parsers/satellite_mongodb.py @@ -11,7 +11,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -43,7 +43,7 @@ class MongoDBStorageEngine(CommandParser, dict): Raises:: - SkipException: When there is no attribute in the output + SkipComponent: When there is no attribute in the output ParseException: When the storage engine attributes aren't in expected format """ @@ -63,7 +63,7 @@ def parse_content(self, content): except Exception: raise ParseException("Unable to parse the line: {0}".format(line)) if not self: - raise SkipException("Cannot get storage engine from Satellite MongoDB") + raise SkipComponent("Cannot get storage engine from Satellite MongoDB") @parser(Specs.satellite_non_yum_type_repos) @@ -92,10 +92,10 @@ class MongoDBNonYumTypeRepos(CommandParser): Raises:: - SkipException: When the output isn't in exptected format + SkipComponent: When the output isn't in exptected format """ def parse_content(self, content): if len(content) != 4 or not content[3].isdigit(): - raise SkipException("Unexpected output for MongoDBNonYumTypeRepos") + raise SkipComponent("Unexpected output for MongoDBNonYumTypeRepos") self.count = int(content[3]) diff --git a/insights/parsers/satellite_postgresql_query.py b/insights/parsers/satellite_postgresql_query.py index 3fd67dd9a1..c4656e428c 100644 --- a/insights/parsers/satellite_postgresql_query.py +++ b/insights/parsers/satellite_postgresql_query.py @@ -29,7 +29,7 @@ from csv import DictReader from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import calc_offset, keyword_search from insights.specs import Specs @@ -65,7 +65,7 @@ class SatellitePostgreSQLQuery(CommandParser, list): def,http://xx.com, Raises: - SkipException: when there isn't data in the table + SkipComponent: when there isn't data in the table ParseException: when the output isn't in good csv format or the yaml values aren't in good yaml format NotImplementedError: when the subclass doesn't override the columns attribute. """ @@ -98,7 +98,7 @@ def parse_content(self, content): row[name] = self._parse_yaml(row[name]) self.append(row) if not self: - raise SkipException("There is no data in the table.") + raise SkipComponent("There is no data in the table.") def search(self, **kwargs): """ diff --git a/insights/parsers/sctp.py b/insights/parsers/sctp.py index 960b9d8548..f0d89d0646 100644 --- a/insights/parsers/sctp.py +++ b/insights/parsers/sctp.py @@ -18,7 +18,7 @@ """ from insights.components.rhel_version import IsRhel6, IsRhel7 from insights.core import Parser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -72,7 +72,7 @@ class SCTPEps(Parser): def parse_content(self, content): if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") line = content[0].strip().split() keys_cnt = len(self.COLUMN_IDX) @@ -148,7 +148,7 @@ def parse_content(self, content): self._sctp_local_ips = set() self._sctp_remote_ips = set() if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") line = content[0].strip().split() keys_cnt = len(self.COLUMN_IDX) @@ -379,13 +379,13 @@ class SCTPSnmp(Parser, dict): } Raises: - SkipException: When contents are empty. + SkipComponent: When contents are empty. ParseException: When file contents are not in expected format. """ def parse_content(self, content): if (not content) or (not self.file_path): - raise SkipException("No Contents") + raise SkipComponent("No Contents") for line in content: line_strip = line.split() diff --git a/insights/parsers/sealert.py b/insights/parsers/sealert.py index 7ca958ccec..0543dc2e65 100644 --- a/insights/parsers/sealert.py +++ b/insights/parsers/sealert.py @@ -2,9 +2,8 @@ Sealert - command ``/usr/bin/sealert -l "*"`` ============================================= """ - -from insights import CommandParser -from insights import parser +from insights.core import CommandParser +from insights.core.plugins import parser from insights.specs import Specs @@ -98,7 +97,7 @@ class Sealert(CommandParser): reports (list[Report]): Sealert reports Raises: - SkipException: When output is empty + SkipComponent: When output is empty """ SELINUX_DISABLED_MESSAGE = "unable to establish connection to setroubleshoot daemon!" diff --git a/insights/parsers/setup_named_chroot.py b/insights/parsers/setup_named_chroot.py index e3faef94ef..e42a5dcd0e 100644 --- a/insights/parsers/setup_named_chroot.py +++ b/insights/parsers/setup_named_chroot.py @@ -6,7 +6,7 @@ ``/usr/libexec/setup-named-chroot.sh``. """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.parsers import get_active_lines @@ -35,7 +35,7 @@ class SetupNamedChroot(Parser, dict): raw (list): A list of all the active lines present Raises: - SkipException: When the file is empty or when the input content is not + SkipComponent: When the file is empty or when the input content is not empty but there is no useful parsed data Examples: @@ -48,7 +48,7 @@ class SetupNamedChroot(Parser, dict): def parse_content(self, content): # No content found or file is empty if not content: - raise SkipException("Empty file") + raise SkipComponent("Empty file") data = {} self.raw = [] @@ -65,6 +65,6 @@ def parse_content(self, content): # No useful parsed data if not data: - raise SkipException("Input content is not empty but there is no useful parsed data.") + raise SkipComponent("Input content is not empty but there is no useful parsed data.") self.update(data) diff --git a/insights/parsers/slabinfo.py b/insights/parsers/slabinfo.py index d31202751c..405a48d0a5 100644 --- a/insights/parsers/slabinfo.py +++ b/insights/parsers/slabinfo.py @@ -6,7 +6,7 @@ ---------------------------------- """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -60,18 +60,18 @@ def parse_content(self, content): column = [] row = [] if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") if 'slabinfo - version' in content[0]: self.__slab_version = content[0].split()[-1] else: - raise SkipException("Invalid Contents") + raise SkipComponent("Invalid Contents") if "active_objs" in content[1]: line = content[1].split() column = [obj.replace('<', '').replace('>', '') for obj in line if obj not in ['#', ':', 'tunables', 'slabdata']] else: - raise SkipException("Invalid Contents") + raise SkipComponent("Invalid Contents") for line in content[2:]: line = line.split() @@ -80,7 +80,7 @@ def parse_content(self, content): self.data[row[0]] = dict(zip(column, row)) row = [] else: - raise SkipException("Invalid Contents") + raise SkipComponent("Invalid Contents") @property def slab_version(self): diff --git a/insights/parsers/smbstatus.py b/insights/parsers/smbstatus.py index de4674538a..defcb347fb 100644 --- a/insights/parsers/smbstatus.py +++ b/insights/parsers/smbstatus.py @@ -12,7 +12,7 @@ ---------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines, parse_fixed_table from insights.specs import Specs @@ -31,7 +31,7 @@ def __iter__(self): def parse_content(self, content): new_content = get_active_lines(content, '-----------') if not content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") if len(content) == 1: raise ParseException("There is no useful parsed data in the content: '{0}'".format(content)) return new_content diff --git a/insights/parsers/smt.py b/insights/parsers/smt.py index 6ee27382f3..8b589a7429 100644 --- a/insights/parsers/smt.py +++ b/insights/parsers/smt.py @@ -16,7 +16,7 @@ import re from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -32,7 +32,7 @@ class CpuSMTActive(Parser): 1 Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Examples: >>> cpu_smt_active.on @@ -40,7 +40,7 @@ class CpuSMTActive(Parser): """ def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") self.on = bool(int(content[0])) @@ -62,7 +62,7 @@ class CpuSMTControl(Parser): off Raises: - SkipException: When content is empty or cannot be parsed. + SkipComponent: When content is empty or cannot be parsed. Examples: >>> cpu_smt_control.on @@ -81,7 +81,7 @@ class CpuSMTControl(Parser): def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") values = self.SMT_CONTROL[content[0]] @@ -103,7 +103,7 @@ class CpuCoreOnline(Parser): 1 Raises: - SkipException: When content is empty or cannot be parsed + SkipComponent: When content is empty or cannot be parsed Examples: >>> cpu_core_online.core_id @@ -115,7 +115,7 @@ class CpuCoreOnline(Parser): def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") self.on = bool(int(content[0])) self.core_id = int(re.match(CpuCoreOnline.cpu_core_path, self.file_path).group(1)) @@ -137,7 +137,7 @@ class CpuSiblings(Parser): 1,3 Raises: - SkipException: When content is empty or cannot be parsed + SkipComponent: When content is empty or cannot be parsed Examples: >>> cpu_siblings.core_id @@ -149,7 +149,7 @@ class CpuSiblings(Parser): def parse_content(self, content): if not content: - raise SkipException("No content.") + raise SkipComponent("No content.") # The separator in the sibling list may be either in the format 0-1 or 0,2 depending on # the CPU model diff --git a/insights/parsers/sockstat.py b/insights/parsers/sockstat.py index ae3827a5ff..beeda3dce6 100644 --- a/insights/parsers/sockstat.py +++ b/insights/parsers/sockstat.py @@ -5,7 +5,7 @@ file, which contains TCP/IP stats of individual layer. """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -80,13 +80,13 @@ class SockStats(Parser, dict): } Raises: - SkipException: When contents are empty + SkipComponent: When contents are empty """ def parse_content(self, content): if not content: - raise SkipException("No Contents") + raise SkipComponent("No Contents") for line in content: line_split = line.split(':') diff --git a/insights/parsers/ssh_client_config.py b/insights/parsers/ssh_client_config.py index ae79b7ef73..8ef6e783bc 100644 --- a/insights/parsers/ssh_client_config.py +++ b/insights/parsers/ssh_client_config.py @@ -20,8 +20,9 @@ """ from collections import namedtuple + from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -77,7 +78,7 @@ class SshClientConfig(Parser): '192.168.122.2' Raises: - SkipException: When input content is empty. Not found any parse results. + SkipComponent: When input content is empty. Not found any parse results. """ KeyValue = namedtuple('KeyValue', ['keyword', 'value', 'line']) @@ -88,7 +89,7 @@ def parse_content(self, content): _content = get_active_lines(content) if not _content: - raise SkipException("Empty content.") + raise SkipComponent("Empty content.") index_list = [i for i, l in enumerate(_content) if l.startswith('Host ')] index = index_list[0] if index_list else len(_content) @@ -109,7 +110,7 @@ def parse_content(self, content): self.host_lines[hostbit].append(self.KeyValue(kw, val, line)) if not (self.host_lines or self.global_lines): - raise SkipException("Nothing parsed.") + raise SkipComponent("Nothing parsed.") @parser(Specs.ssh_config) diff --git a/insights/parsers/ssl_certificate.py b/insights/parsers/ssl_certificate.py index 7886b7fcb2..d26dfa4d25 100644 --- a/insights/parsers/ssl_certificate.py +++ b/insights/parsers/ssl_certificate.py @@ -20,7 +20,7 @@ from datetime import datetime from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipComponent, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers.certificates_enddate import CertificatesEnddate from insights.specs import Specs @@ -79,7 +79,7 @@ class CertificateInfo(CommandParser, dict): 'Dec 7 07:02:33 2020' Raises: - SkipException: when the command output is empty. + SkipComponent: when the command output is empty. """ def __init__(self, context): @@ -95,7 +95,7 @@ def parse_content(self, content): self.update(parse_openssl_output(content)) if not self: - raise SkipException("There is not any info in the cert.") + raise SkipComponent("There is not any info in the cert.") @property def cert_path(self): @@ -145,7 +145,7 @@ def parse_content(self, content): in the chain. Raises: - SkipException: when the command output is empty. + SkipComponent: when the command output is empty. """ self.earliest_expiry_date = None @@ -159,7 +159,7 @@ def parse_content(self, content): if index == len(content) - 1: self.append(parse_openssl_output(content=content[start_index:index + 1])) if not self: - raise SkipException("There is not any info in the ca cert chain.") + raise SkipComponent("There is not any info in the ca cert chain.") for one_cert in self: expire_date = one_cert.get('notAfter') if expire_date and (self.earliest_expiry_date is None or expire_date.datetime < self.earliest_expiry_date.datetime): diff --git a/insights/parsers/subscription_manager.py b/insights/parsers/subscription_manager.py index 419987695c..982dfabb52 100644 --- a/insights/parsers/subscription_manager.py +++ b/insights/parsers/subscription_manager.py @@ -8,7 +8,7 @@ ----------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.specs import Specs @@ -44,4 +44,4 @@ def parse_content(self, content): self[key] = val if len(self) == 0: - raise SkipException + raise SkipComponent diff --git a/insights/parsers/subscription_manager_release.py b/insights/parsers/subscription_manager_release.py index e46e72c6c6..8246bfa657 100644 --- a/insights/parsers/subscription_manager_release.py +++ b/insights/parsers/subscription_manager_release.py @@ -10,7 +10,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -44,7 +44,7 @@ def parse_content(self, content): self.set = self.major = self.minor = None l = len(content) if l != 1: - raise SkipException("Content takes at most 1 line ({0} given).".format(l)) + raise SkipComponent("Content takes at most 1 line ({0} given).".format(l)) line = content[0].strip() if line != 'Release not set': line_splits = line.split() @@ -72,5 +72,5 @@ def parse_content(self, content): # leave self.minor as None return - raise SkipException("Incorrect content: {0}".format(line)) + raise SkipComponent("Incorrect content: {0}".format(line)) # Release not set diff --git a/insights/parsers/sudoers.py b/insights/parsers/sudoers.py index 1e12d5d4ef..f94251e6d9 100644 --- a/insights/parsers/sudoers.py +++ b/insights/parsers/sudoers.py @@ -13,7 +13,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.filters import add_filter from insights.core.plugins import parser from insights.parsers import get_active_lines @@ -116,4 +116,4 @@ def parse_content(self, content): self.lines = get_active_lines(content, comment_char="##") if not self.lines: - raise SkipException + raise SkipComponent diff --git a/insights/parsers/sys_bus.py b/insights/parsers/sys_bus.py index e7909268f5..0e7ac50ad5 100644 --- a/insights/parsers/sys_bus.py +++ b/insights/parsers/sys_bus.py @@ -40,7 +40,7 @@ class CdcWDM(Parser): True Raises: - SkipException: When contents are empty + SkipComponent: When contents are empty ParseException: When contents are invalid """ diff --git a/insights/parsers/sys_module.py b/insights/parsers/sys_module.py index cc4ac44fae..d81afb10a1 100755 --- a/insights/parsers/sys_module.py +++ b/insights/parsers/sys_module.py @@ -24,7 +24,7 @@ ------------------------------------------------------------------------------------------------- """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -39,7 +39,7 @@ class SysModuleParameters(Parser): Y Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Attributes: val(str): Raw data of the content. @@ -47,7 +47,7 @@ class SysModuleParameters(Parser): def parse_content(self, content): if not content or len(content) != 1: - raise SkipException() + raise SkipComponent() self.val = content[0].strip() @property @@ -76,7 +76,7 @@ class MaxLUNs(Parser): 512 Raises: - SkipException: When content is empty or no parse-able content. + SkipComponent: When content is empty or no parse-able content. Attributes: val(int): Convert the raw data of the content to int. @@ -84,7 +84,7 @@ class MaxLUNs(Parser): def parse_content(self, content): if not content or len(content) != 1: - raise SkipException() + raise SkipComponent() if not content[0].strip('').isdigit(): raise ValueError("Unexpected content: {0}".format(content[0])) self.val = int(content[0].strip()) diff --git a/insights/parsers/sys_vmbus.py b/insights/parsers/sys_vmbus.py index 5bd1826a95..9c098df776 100644 --- a/insights/parsers/sys_vmbus.py +++ b/insights/parsers/sys_vmbus.py @@ -9,7 +9,7 @@ ------------------------------------------------------------ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -31,7 +31,7 @@ class SysVmbusDeviceID(Parser): {47505500-0001-0000-3130-444531444234} Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Attributes: id(str): Device ID @@ -43,7 +43,7 @@ class SysVmbusDeviceID(Parser): """ def parse_content(self, content): if not content or len(content) != 1: - raise SkipException() + raise SkipComponent() self.id = content[0].strip('{}\n') @@ -56,7 +56,7 @@ class SysVmbusClassID(Parser): {44c4f61d-4444-4400-9d52-802e27ede19f} Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Attributes: id(str): Class ID @@ -71,6 +71,6 @@ class SysVmbusClassID(Parser): """ def parse_content(self, content): if not content or len(content) != 1: - raise SkipException() + raise SkipComponent() self.id = content[0].strip('{}\n') self.desc = VMBUS_DEV_DICT.get(self.id, 'Unknown') diff --git a/insights/parsers/systemctl_show.py b/insights/parsers/systemctl_show.py index b7102fa843..6fb4ef9a29 100644 --- a/insights/parsers/systemctl_show.py +++ b/insights/parsers/systemctl_show.py @@ -12,7 +12,7 @@ ---------------------------------------------------------------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import split_kv_pairs from insights.specs import Specs @@ -75,13 +75,13 @@ class SystemctlShowServiceAll(CommandParser, dict): '0' Raises: - SkipException: When nothing needs to parse + SkipComponent: When nothing needs to parse ParseException: When something cannot be parsed """ def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent sidx = 0 idx_list = [] @@ -98,7 +98,7 @@ def parse_content(self, content): self[name] = dict((k, v) for k, v in data.items() if v) if len(self) == 0: - raise SkipException + raise SkipComponent @parser(Specs.systemctl_show_target) @@ -171,7 +171,7 @@ class SystemctlShowTarget(SystemctlShowServiceAll): >>> systemctl_show_target.get('network.target').get('RequiredBy', None) Raises: - SkipException: When nothing needs to parse + SkipComponent: When nothing needs to parse ParseException: When something cannot be parsed """ pass diff --git a/insights/parsers/systemd/unitfiles.py b/insights/parsers/systemd/unitfiles.py index d2eddf95d3..cc17cc2250 100644 --- a/insights/parsers/systemd/unitfiles.py +++ b/insights/parsers/systemd/unitfiles.py @@ -12,7 +12,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import get_active_lines from insights.specs import Specs @@ -35,7 +35,7 @@ class UnitFiles(Parser): runlevel2.target enabled Raises: - SkipException: When nothing is parsed. + SkipComponent: When nothing is parsed. Example: @@ -105,7 +105,7 @@ def parse_content(self, content): self.service_list.append(service) if not self.services: - raise SkipException + raise SkipComponent def is_on(self, service_name): """ @@ -159,7 +159,7 @@ class ListUnits(Parser): To show all installed unit files use 'systemctl list-unit-files'. Raises: - SkipException: When nothing is parsed. + SkipComponent: When nothing is parsed. Example: @@ -226,7 +226,7 @@ def parse_content(self, content): self.unit_list[parts[first_part]] = service_details if not self.unit_list: - raise SkipException + raise SkipComponent def get_service_details(self, service_name): """ diff --git a/insights/parsers/systemd_analyze.py b/insights/parsers/systemd_analyze.py index 79f2f73ffc..61e2981fca 100644 --- a/insights/parsers/systemd_analyze.py +++ b/insights/parsers/systemd_analyze.py @@ -5,7 +5,7 @@ This module parses the output of command ``systemd-analyze blame``. """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -49,11 +49,11 @@ class SystemdAnalyzeBlame(CommandParser, dict): 'unbound-anchor.service': 32.423} Raises: - SkipException: If content is not provided. + SkipComponent: If content is not provided. """ def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent for c in content: cols = c.split() diff --git a/insights/parsers/tomcat_virtual_dir_context.py b/insights/parsers/tomcat_virtual_dir_context.py index 6ae78148cf..d084f0378a 100644 --- a/insights/parsers/tomcat_virtual_dir_context.py +++ b/insights/parsers/tomcat_virtual_dir_context.py @@ -41,7 +41,7 @@ } """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -68,7 +68,7 @@ def parse_content(self, content): self.data[file_name] = [file_line] if self.data == {}: - raise SkipException('VirtualDirContext not used.') + raise SkipComponent('VirtualDirContext not used.') @parser(Specs.tomcat_vdc_fallback) diff --git a/insights/parsers/tuned.py b/insights/parsers/tuned.py index bba68efc22..3441f9e163 100644 --- a/insights/parsers/tuned.py +++ b/insights/parsers/tuned.py @@ -43,7 +43,7 @@ True """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -54,7 +54,7 @@ class Tuned(CommandParser, dict): Parse output from the ``/usr/sbin/tuned-adm list`` command. Raises: - SkipException: When noting needs to parse + SkipComponent: When noting needs to parse """ def parse_content(self, content): @@ -69,7 +69,7 @@ def parse_content(self, content): data['preset'] = line.split(': ')[1].strip() # Ignore everything else for now if not data: - raise SkipException + raise SkipComponent self.update(data) @property diff --git a/insights/parsers/upstart.py b/insights/parsers/upstart.py index 33152d5524..af8536d54a 100644 --- a/insights/parsers/upstart.py +++ b/insights/parsers/upstart.py @@ -6,7 +6,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -50,7 +50,7 @@ class UpstartInitctlList(CommandParser): serial stop/waiting Raises: - SkipException: When nothing need to parse. + SkipComponent: When nothing need to parse. Attributes: data(list): Daemon details are stored as list of str. @@ -83,7 +83,7 @@ def parse_content(self, content): self.tty = {} self.daemon_proc = {} if (not content): - raise SkipException("No Contents") + raise SkipComponent("No Contents") for line in content: self.data.append(line) if 'dev/tty' in line: diff --git a/insights/parsers/user_group.py b/insights/parsers/user_group.py index f21d710ef7..dd2cd16587 100644 --- a/insights/parsers/user_group.py +++ b/insights/parsers/user_group.py @@ -11,7 +11,7 @@ """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import keyword_search from insights.specs import Specs @@ -41,7 +41,7 @@ class GroupInfo(CommandParser, list): """ def parse_content(self, content): if not content: - raise SkipException + raise SkipComponent for line in content: try: diff --git a/insights/parsers/vma_ra_enabled_s390x.py b/insights/parsers/vma_ra_enabled_s390x.py index ad3ccd397d..af2028a865 100644 --- a/insights/parsers/vma_ra_enabled_s390x.py +++ b/insights/parsers/vma_ra_enabled_s390x.py @@ -5,7 +5,7 @@ Parser to parse the output of file ``/sys/kernel/mm/swap/vma_ra_enabled`` """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -30,13 +30,13 @@ class VmaRaEnabledS390x(Parser): ra_enabled (bool): The result parsed Raises: - SkipException: When file content is empty + SkipComponent: When file content is empty """ def parse_content(self, content): if not content: - raise SkipException("Input content is empty") + raise SkipComponent("Input content is empty") if content[0] == 'True': self.ra_enabled = True diff --git a/insights/parsers/x86_debug.py b/insights/parsers/x86_debug.py index 9a32b3488f..e8a42c65c4 100644 --- a/insights/parsers/x86_debug.py +++ b/insights/parsers/x86_debug.py @@ -18,7 +18,7 @@ """ from insights.core import Parser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -31,11 +31,11 @@ class X86DebugEnabled(Parser): value (int): the result parsed of `/sys/kernel/debug/x86/*_enabled` Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ def parse_content(self, content): if not content: - raise SkipException("Input content is empty") + raise SkipComponent("Input content is empty") # it is a digit self.value = int(content[0]) @@ -58,7 +58,7 @@ class X86IBPBEnabled(X86DebugEnabled): value (int): the result parsed of '/sys/kernel/debug/x86/ibpb_enabled' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ pass @@ -81,7 +81,7 @@ class X86IBRSEnabled(X86DebugEnabled): value (int): the result parsed of '/sys/kernel/debug/x86/ibrs_enabled' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ pass @@ -104,7 +104,7 @@ class X86PTIEnabled(X86DebugEnabled): value (int): the result parsed of '/sys/kernel/debug/x86/pti_enabled' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ pass @@ -127,6 +127,6 @@ class X86RETPEnabled(X86DebugEnabled): value (int): the result parsed of '/sys/kernel/debug/x86/retp_enabled' Raises: - SkipException: When input content is empty + SkipComponent: When input content is empty """ pass diff --git a/insights/parsers/yum.py b/insights/parsers/yum.py index b24b870318..53e9029496 100644 --- a/insights/parsers/yum.py +++ b/insights/parsers/yum.py @@ -10,7 +10,7 @@ ----------------------------------------------------- """ from insights.core import CommandParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.core.plugins import parser from insights.parsers import parse_fixed_table from insights.specs import Specs @@ -126,10 +126,10 @@ class YumRepoList(CommandParser): """ def parse_content(self, content): if not content: - raise SkipException('No repolist.') + raise SkipComponent('No repolist.') if content[0].startswith('repolist:'): - raise SkipException('No repolist.') + raise SkipComponent('No repolist.') trailing_line_prefix = [ 'repolist:', @@ -153,7 +153,7 @@ def parse_content(self, content): raise ParseException('Failed to parser yum repolist: {0}'.format(str(e))) if not self.data: - raise SkipException('No repolist.') + raise SkipComponent('No repolist.') self.repos = dict((d['id'].lstrip('!').lstrip('*'), d) for d in self.data) diff --git a/insights/parsers/yum_updateinfo.py b/insights/parsers/yum_updateinfo.py index ce153b5915..662fb63eab 100644 --- a/insights/parsers/yum_updateinfo.py +++ b/insights/parsers/yum_updateinfo.py @@ -4,7 +4,7 @@ Provides a list of available advisories """ from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.parsers import parse_delimited_table from insights.specs import Specs @@ -34,7 +34,7 @@ def parse_content(self, content): with_header = ['advisory type package'] + content table = parse_delimited_table(with_header) if not table: - raise SkipException('No data.') + raise SkipComponent('No data.') self._items = table @property diff --git a/insights/parsers/zdump_v.py b/insights/parsers/zdump_v.py index 64cf49d3f4..89e130d55c 100644 --- a/insights/parsers/zdump_v.py +++ b/insights/parsers/zdump_v.py @@ -30,7 +30,7 @@ from datetime import datetime from insights.core import CommandParser -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.core.plugins import parser from insights.specs import Specs @@ -76,13 +76,13 @@ class ZdumpV(CommandParser, list): and store the 'Daylight Saving Time' information into a list. Raises: - SkipException: When nothing is parsed. + SkipComponent: When nothing is parsed. .. warning:: The value in key `local_time` doesn't include the TimeZone information """ def parse_content(self, content): if not content: - raise SkipException("No Data from command: /usr/sbin/zdump -v /etc/localtime -c 2019,2039") + raise SkipComponent("No Data from command: /usr/sbin/zdump -v /etc/localtime -c 2019,2039") for line in content: dst = {} diff --git a/insights/tests/combiners/test_httpd_conf_tree.py b/insights/tests/combiners/test_httpd_conf_tree.py index b33673aeb1..d7fe8c9916 100644 --- a/insights/tests/combiners/test_httpd_conf_tree.py +++ b/insights/tests/combiners/test_httpd_conf_tree.py @@ -2,7 +2,7 @@ import pytest from insights.combiners.httpd_conf import HttpdConfTree, HttpdConfSclHttpd24Tree, HttpdConfSclJbcsHttpd24Tree -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import httpd_conf from insights.tests import context_wrap @@ -723,7 +723,7 @@ def test_httpd_one_file_overwrites(): def test_httpd_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert httpd_conf.HttpdConf(context_wrap('', path='/etc/httpd/httpd.conf')) is None diff --git a/insights/tests/combiners/test_nginx_conf.py b/insights/tests/combiners/test_nginx_conf.py index 9ee48b3fbb..8934b6d859 100644 --- a/insights/tests/combiners/test_nginx_conf.py +++ b/insights/tests/combiners/test_nginx_conf.py @@ -1,7 +1,7 @@ import pytest from insights.combiners.nginx_conf import NginxConfTree, ContainerNginxConfTree -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.nginx_conf import NginxConfPEG, ContainerNginxConfPEG from insights.parsr.query import startswith from insights.tests import context_wrap @@ -219,7 +219,7 @@ def test_nginx_recursive_includes(): def test_nginx_empty(): nginx_conf = context_wrap('', path="/etc/nginx/nginx.conf") - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert NginxConfPEG(nginx_conf) is None diff --git a/insights/tests/parsers/__init__.py b/insights/tests/parsers/__init__.py index efb719cd03..3010462b7e 100644 --- a/insights/tests/parsers/__init__.py +++ b/insights/tests/parsers/__init__.py @@ -1,10 +1,13 @@ import doctest -from doctest import (DebugRunner, DocTestFinder, DocTestRunner, - OutputChecker) import pytest import re import sys +from doctest import (DebugRunner, DocTestFinder, DocTestRunner, + OutputChecker) + +from insights.util import deprecated + class Py23DocChecker(OutputChecker): def check_output(self, want, got, optionflags): @@ -39,9 +42,29 @@ def ic_testmod(m, name=None, globs=None, verbose=None, def skip_exception_check(parser_obj, output_str=""): + """ + .. warning:: + This class is deprecated, please use + :py:class:`skip_component_check` instead. + """ + deprecated( + skip_component_check, + "Please use the :method:`skip_component_check` instead.", + "3.2.25" + ) + from insights.core.exceptions import SkipException from insights.tests import context_wrap with pytest.raises(SkipException) as ex: parser_obj(context_wrap(output_str)) return str(ex) + + +def skip_component_check(parser_obj, output_str=""): + from insights.core.exceptions import SkipComponent + from insights.tests import context_wrap + + with pytest.raises(SkipComponent) as ex: + parser_obj(context_wrap(output_str)) + return str(ex) diff --git a/insights/tests/parsers/test_abrt_ccpp.py b/insights/tests/parsers/test_abrt_ccpp.py index 15c869ea08..cbce343af1 100644 --- a/insights/tests/parsers/test_abrt_ccpp.py +++ b/insights/tests/parsers/test_abrt_ccpp.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import abrt_ccpp from insights.parsers.abrt_ccpp import AbrtCCppConf from insights.tests import context_wrap @@ -70,7 +70,7 @@ def test_empty_content(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AbrtCCppConf(context_wrap(ABRT_CONF_CONTENT_NO)) diff --git a/insights/tests/parsers/test_auditctl.py b/insights/tests/parsers/test_auditctl.py index e6a79434d4..132f634a5e 100644 --- a/insights/tests/parsers/test_auditctl.py +++ b/insights/tests/parsers/test_auditctl.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import auditctl from insights.parsers.auditctl import AuditStatus, AuditRules from insights.tests import context_wrap @@ -88,10 +88,10 @@ def test_normal_auds_rhel7(): def test_auds_blank_input(): ctx = context_wrap(BLANK_INPUT_SAMPLE) - with pytest.raises(SkipException) as sc: + with pytest.raises(SkipComponent) as sc: AuditStatus(ctx) assert "Input content is empty." in str(sc) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AuditStatus(context_wrap(BAD_INPUT_SAMPLE)) @@ -109,9 +109,9 @@ def test_audit_rules(): def test_audit_rules_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AuditRules(context_wrap(AUDIT_RULES_OUTPUT1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AuditRules(context_wrap(AUDIT_RULES_OUTPUT3)) diff --git a/insights/tests/parsers/test_authselect.py b/insights/tests/parsers/test_authselect.py index c88b8d9d95..373be6690a 100644 --- a/insights/tests/parsers/test_authselect.py +++ b/insights/tests/parsers/test_authselect.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import authselect from insights.parsers.authselect import AuthSelectCurrent from insights.tests import context_wrap @@ -37,10 +37,10 @@ def test_authselect_current(): def test_authselect_current_exp(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AuthSelectCurrent(context_wrap(AUTHSELECT_CURRENT_EMPTY)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AuthSelectCurrent(context_wrap(AUTHSELECT_CURRENT_NG)) diff --git a/insights/tests/parsers/test_aws_instance_id.py b/insights/tests/parsers/test_aws_instance_id.py index 5f88be89b6..c6028d3648 100644 --- a/insights/tests/parsers/test_aws_instance_id.py +++ b/insights/tests/parsers/test_aws_instance_id.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import aws_instance_id from insights.parsers.aws_instance_id import AWSInstanceIdDoc, AWSInstanceIdPkcs7 from insights.tests import context_wrap @@ -98,10 +98,10 @@ def test_aws_instance_id_doc(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AWSInstanceIdDoc(context_wrap(AWS_CURL_ERROR)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AWSInstanceIdDoc(context_wrap(AWS_NO_DOC)) with pytest.raises(ParseException) as pe: @@ -152,10 +152,10 @@ def test_aws_instance_id_doc(): def test_aws_instance_id_pkcs7(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AWSInstanceIdDoc(context_wrap(AWS_CURL_ERROR)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AWSInstanceIdDoc(context_wrap(AWS_NO_DOC)) pkcs7 = AWSInstanceIdPkcs7(context_wrap(AWS_ID_PKCS7)) diff --git a/insights/tests/parsers/test_awx_manage.py b/insights/tests/parsers/test_awx_manage.py index 9145d82d5b..044032d9a2 100644 --- a/insights/tests/parsers/test_awx_manage.py +++ b/insights/tests/parsers/test_awx_manage.py @@ -1,11 +1,11 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import awx_manage from insights.parsers.awx_manage import AnsibleTowerLicenseType, AnsibleTowerLicense, AwxManagePrintSettings from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check GOOD_LICENSE = """ enterprise @@ -53,7 +53,7 @@ def test_ansible_tower_license_type(): def test_ansible_tower_license_ab_type(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AnsibleTowerLicenseType(context_wrap(NG_COMMAND_0)) with pytest.raises(ContentException): @@ -72,7 +72,7 @@ def test_ansible_tower_license_data(): def test_ansible_tower_license__data_ab_type(): - assert 'Empty output.' in skip_exception_check(AnsibleTowerLicense) + assert 'Empty output.' in skip_component_check(AnsibleTowerLicense) with pytest.raises(ContentException): AnsibleTowerLicense(context_wrap(NG_COMMAND_1)) diff --git a/insights/tests/parsers/test_azure_instance.py b/insights/tests/parsers/test_azure_instance.py index a88299a7e5..345e0e0bcb 100644 --- a/insights/tests/parsers/test_azure_instance.py +++ b/insights/tests/parsers/test_azure_instance.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import azure_instance from insights.parsers.azure_instance import AzureInstanceID, AzureInstancePlan, AzureInstanceType from insights.tests import context_wrap @@ -64,7 +64,7 @@ # Test AzureInstanceID def test_azure_instance_id_ab_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceID(context_wrap('')) @@ -76,13 +76,13 @@ def test_azure_instance_id(): # Test AzureInstanceType def test_azure_instance_type_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_3)) with pytest.raises(ParseException) as pe: @@ -94,7 +94,7 @@ def test_azure_instance_type_ab_other(): def test_azure_instance_type_ab_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap('')) @@ -125,16 +125,16 @@ def test_azure_instance_type_stats(): # Test AzureInstancePlan def test_azure_instance_plan_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_3)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap('')) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_azure_instance_plan.py b/insights/tests/parsers/test_azure_instance_plan.py index 77047e7d86..173481feca 100644 --- a/insights/tests/parsers/test_azure_instance_plan.py +++ b/insights/tests/parsers/test_azure_instance_plan.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import azure_instance_plan from insights.parsers.azure_instance_plan import AzureInstancePlan from insights.tests import context_wrap @@ -32,16 +32,16 @@ def test_azure_instance_place_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap(AZURE_PLAN_AB_3)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstancePlan(context_wrap('')) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_azure_instance_type.py b/insights/tests/parsers/test_azure_instance_type.py index 3e2c5b685b..2e0156a1d9 100644 --- a/insights/tests/parsers/test_azure_instance_type.py +++ b/insights/tests/parsers/test_azure_instance_type.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import azure_instance_type from insights.parsers.azure_instance_type import AzureInstanceType from insights.tests import context_wrap @@ -34,13 +34,13 @@ def test_azure_instance_type_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap(AZURE_TYPE_AB_3)) with pytest.raises(ParseException) as pe: @@ -52,7 +52,7 @@ def test_azure_instance_type_ab_other(): def test_azure_instance_type_ab_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): AzureInstanceType(context_wrap('')) diff --git a/insights/tests/parsers/test_bond_dynamic_lb.py b/insights/tests/parsers/test_bond_dynamic_lb.py index 1330d446a1..b406d96a5e 100644 --- a/insights/tests/parsers/test_bond_dynamic_lb.py +++ b/insights/tests/parsers/test_bond_dynamic_lb.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import bond_dynamic_lb from insights.parsers.bond_dynamic_lb import BondDynamicLB from insights.tests import context_wrap @@ -56,7 +56,7 @@ def test_bond_dynamic_lb_class(): assert not bond_obj.bond_name assert 'Unrecognised Values' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: bond_obj = BondDynamicLB(context_wrap(BOND_LD_BALANCE_NO, CONTEXT_PATH)) assert not bond_obj.bond_name assert 'No Contents' in str(exc) diff --git a/insights/tests/parsers/test_ceph_cmd_json_parsing.py b/insights/tests/parsers/test_ceph_cmd_json_parsing.py index 188f6a971d..85b69bbecb 100644 --- a/insights/tests/parsers/test_ceph_cmd_json_parsing.py +++ b/insights/tests/parsers/test_ceph_cmd_json_parsing.py @@ -6,7 +6,7 @@ from insights.parsers.ceph_cmd_json_parsing import (CephCfgInfo, CephDfDetail, CephECProfileGet, CephHealthDetail, CephOsdDf, CephOsdDump, CephOsdTree, CephReport, CephS) from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check CEPH_OSD_DUMP_INFO = """ { @@ -536,7 +536,7 @@ def test_ceph_osd_dump(self): assert result['pools'][0]['min_size'] == 2 def test_ceph_osd_dump_empty(self): - assert 'Empty output.' in skip_exception_check(CephOsdDump) + assert 'Empty output.' in skip_component_check(CephOsdDump) class TestCephOsdDf(): @@ -575,7 +575,7 @@ def test_ceph_osd_df(self): assert result['nodes'][0]['pgs'] == 945 def test_ceph_os_df_empty(self): - assert 'Empty output.' in skip_exception_check(CephOsdDf) + assert 'Empty output.' in skip_component_check(CephOsdDf) class TestCephS(): @@ -608,7 +608,7 @@ def test_ceph_s(self): assert result['pgmap']['pgs_by_state'][0]['state_name'] == 'active+clean' def test_ceph_s_empty(self): - assert 'Empty output.' in skip_exception_check(CephS) + assert 'Empty output.' in skip_component_check(CephS) class TestCephECProfileGet(): @@ -625,7 +625,7 @@ def test_ceph_ec_profile_get(self): assert result['m'] == "1" def test_ceph_ec_profile_get_empty(self): - assert 'Empty output.' in skip_exception_check(CephECProfileGet) + assert 'Empty output.' in skip_component_check(CephECProfileGet) class TestCephCfgInfo(): @@ -651,7 +651,7 @@ def test_ceph_cfg_info(self): assert result.max_open_files == '131072' def test_ceph_cfg_info_empty(self): - assert 'Empty output.' in skip_exception_check(CephCfgInfo) + assert 'Empty output.' in skip_component_check(CephCfgInfo) class TestCephHealthDetail(): @@ -673,7 +673,7 @@ def test_ceph_health_detail(self): assert result['overall_status'] == 'HEALTH_OK' def test_ceph_health_detail_empty(self): - assert 'Empty output.' in skip_exception_check(CephHealthDetail) + assert 'Empty output.' in skip_component_check(CephHealthDetail) class TestCephDfDetail(): @@ -725,7 +725,7 @@ def test_ceph_df_detail(self): assert result['stats']['total_avail_bytes'] == 16910123008 def test_ceph_df_detail_empty(self): - assert 'Empty output.' in skip_exception_check(CephDfDetail) + assert 'Empty output.' in skip_component_check(CephDfDetail) class TestCephOsdTree(): @@ -859,7 +859,7 @@ def test_ceph_osd_tree(self): assert len(result['nodes'][0]['children']) == 4 def test_ceph_osd_tree_empty(self): - assert 'Empty output.' in skip_exception_check(CephOsdTree) + assert 'Empty output.' in skip_component_check(CephOsdTree) class TestCephReport(): @@ -878,4 +878,4 @@ def test_invalid_json(self): assert "Could not parse json." in str(e) def test_ceph_report_empty(self): - assert 'Empty output.' in skip_exception_check(CephReport) + assert 'Empty output.' in skip_component_check(CephReport) diff --git a/insights/tests/parsers/test_ceph_conf.py b/insights/tests/parsers/test_ceph_conf.py index 2c90fd9dbb..1d48a434d4 100644 --- a/insights/tests/parsers/test_ceph_conf.py +++ b/insights/tests/parsers/test_ceph_conf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ceph_conf from insights.tests import context_wrap @@ -45,7 +45,7 @@ def test_ceph_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert ceph_conf.CephConf(context_wrap('')) is None diff --git a/insights/tests/parsers/test_ceph_osd_tree_text.py b/insights/tests/parsers/test_ceph_osd_tree_text.py index c7fd1512f3..2ffdbc9f00 100644 --- a/insights/tests/parsers/test_ceph_osd_tree_text.py +++ b/insights/tests/parsers/test_ceph_osd_tree_text.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import ceph_osd_tree_text from insights.parsers.ceph_osd_tree_text import CephOsdTreeText from insights.tests import context_wrap @@ -60,7 +60,7 @@ def test_ceph_osd_tree_text_v2(): def test_skip_content(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: CephOsdTreeText(context_wrap(OSD_TREE_EMPTY)) assert "Empty content." in str(e) diff --git a/insights/tests/parsers/test_ceph_version.py b/insights/tests/parsers/test_ceph_version.py index 01eb24b566..db2cf5c072 100644 --- a/insights/tests/parsers/test_ceph_version.py +++ b/insights/tests/parsers/test_ceph_version.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.ceph_version import CephVersion from insights.tests import context_wrap @@ -20,16 +20,16 @@ def test_ceph_version(): - with pytest.raises(SkipException) as error_context2: + with pytest.raises(SkipComponent) as error_context2: CephVersion(context_wrap(CV2)) assert 'Empty Ceph Version Line' in str(error_context2) - with pytest.raises(SkipException) as error_context3: + with pytest.raises(SkipComponent) as error_context3: CephVersion(context_wrap(CV3)) assert 'Wrong Format Ceph Version' in str(error_context3) - with pytest.raises(SkipException) as error_context5: + with pytest.raises(SkipComponent) as error_context5: CephVersion(context_wrap(CV5)) assert 'Wrong Format Ceph Version' in str(error_context5) - with pytest.raises(SkipException) as error_context6: + with pytest.raises(SkipComponent) as error_context6: CephVersion(context_wrap(CV6)) assert 'No Mapping Release Version' in str(error_context6) diff --git a/insights/tests/parsers/test_certificates_enddate.py b/insights/tests/parsers/test_certificates_enddate.py index ad1470e25d..8570d95c24 100644 --- a/insights/tests/parsers/test_certificates_enddate.py +++ b/insights/tests/parsers/test_certificates_enddate.py @@ -3,7 +3,7 @@ from datetime import datetime -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import certificates_enddate from insights.tests import context_wrap @@ -121,5 +121,5 @@ def test_doc(): def test_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): certificates_enddate.CertificatesEnddate(context_wrap(CRT7)) diff --git a/insights/tests/parsers/test_chkconfig.py b/insights/tests/parsers/test_chkconfig.py index da6d46a5e8..1be1adc9cd 100644 --- a/insights/tests/parsers/test_chkconfig.py +++ b/insights/tests/parsers/test_chkconfig.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.chkconfig import ChkConfig from insights.tests import context_wrap @@ -103,5 +103,5 @@ def test_rhel_73(): def test_chkconfig_ng(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ChkConfig(context_wrap(SERVICES_NG)) diff --git a/insights/tests/parsers/test_cloud_cfg.py b/insights/tests/parsers/test_cloud_cfg.py index 745684be4b..f7bd684329 100644 --- a/insights/tests/parsers/test_cloud_cfg.py +++ b/insights/tests/parsers/test_cloud_cfg.py @@ -1,8 +1,8 @@ import doctest from insights.parsers import cloud_cfg -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check CONFIG_1 = """ @@ -23,7 +23,7 @@ def test_cloud_cfg(): def test_cloud_cfg_empty(): - assert 'There is no data' in skip_exception_check(cloud_cfg.CloudCfg) + assert 'There is no data' in skip_component_check(cloud_cfg.CloudCfg) def test_doc_examples(): diff --git a/insights/tests/parsers/test_cmdline.py b/insights/tests/parsers/test_cmdline.py index 36789e7e28..a670810090 100644 --- a/insights/tests/parsers/test_cmdline.py +++ b/insights/tests/parsers/test_cmdline.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import cmdline from insights.parsers.cmdline import CmdLine from insights.tests import context_wrap @@ -44,7 +44,7 @@ def test_cmdline_v2(): def test_cmdline_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): CmdLine(context_wrap(CMDLINE_GRUB2_EMPTY)) with pytest.raises(ParseException) as ex: diff --git a/insights/tests/parsers/test_cni_podman_bridge_conf.py b/insights/tests/parsers/test_cni_podman_bridge_conf.py index 8af23e4086..e842a933eb 100644 --- a/insights/tests/parsers/test_cni_podman_bridge_conf.py +++ b/insights/tests/parsers/test_cni_podman_bridge_conf.py @@ -2,8 +2,8 @@ from insights.parsers import cni_podman_bridge_conf from insights.parsers.cni_podman_bridge_conf import CNIPodmanBridgeConf -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check PODMAN_CNI_FILE = ''' { @@ -65,4 +65,4 @@ def test_cni_podman_bridge_conf(): def test_cni_podman_bridge_conf_empty(): - assert 'Empty output.' in skip_exception_check(CNIPodmanBridgeConf) + assert 'Empty output.' in skip_component_check(CNIPodmanBridgeConf) diff --git a/insights/tests/parsers/test_containers_policy.py b/insights/tests/parsers/test_containers_policy.py index f017afaa23..6f3b2e06c1 100644 --- a/insights/tests/parsers/test_containers_policy.py +++ b/insights/tests/parsers/test_containers_policy.py @@ -2,8 +2,8 @@ from insights.parsers import containers_policy from insights.parsers.containers_policy import ContainersPolicy -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check CONTAINERS_POLICY_FILE = ''' { @@ -61,4 +61,4 @@ def test_containers_policy(): def test_containers_policy_empty(): - assert 'Empty output.' in skip_exception_check(ContainersPolicy) + assert 'Empty output.' in skip_component_check(ContainersPolicy) diff --git a/insights/tests/parsers/test_corosync.py b/insights/tests/parsers/test_corosync.py index 75f40ad778..61b6c336b8 100644 --- a/insights/tests/parsers/test_corosync.py +++ b/insights/tests/parsers/test_corosync.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import corosync from insights.parsr.query import first, last from insights.tests import context_wrap @@ -78,7 +78,7 @@ def test_corosync_conf(): def test_corosync_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert corosync.CorosyncConf(context_wrap('')) is None diff --git a/insights/tests/parsers/test_corosync_cmapctl.py b/insights/tests/parsers/test_corosync_cmapctl.py index 2c5b9cb2dc..07af9366c2 100644 --- a/insights/tests/parsers/test_corosync_cmapctl.py +++ b/insights/tests/parsers/test_corosync_cmapctl.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import corosync_cmapctl from insights.tests import context_wrap @@ -97,7 +97,7 @@ def test_state_schemiss(): def test_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): corosync_cmapctl.CorosyncCmapctl(context_wrap(COROSYNC_CONTENT_3, path="corosync_cmpctl")) with pytest.raises(ContentException): corosync_cmapctl.CorosyncCmapctl(context_wrap(COROSYNC_CONTENT_4, path="corosync_cmpctl_-C")) diff --git a/insights/tests/parsers/test_cpu_vulns.py b/insights/tests/parsers/test_cpu_vulns.py index 9e3c3fb911..03da0c6e91 100644 --- a/insights/tests/parsers/test_cpu_vulns.py +++ b/insights/tests/parsers/test_cpu_vulns.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import cpu_vulns from insights.parsers.cpu_vulns import CpuVulns from insights.tests import context_wrap @@ -79,7 +79,7 @@ def test_cpu_vulns_meltdown_exp1(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: CpuVulns(context_wrap('', path='/sys/devices/system/cpu/vulnerabilities/meltdown')) assert "Input content is empty" in str(sc1) @@ -107,7 +107,7 @@ def test_cpu_vulns_spec_store_bypass_exp1(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: CpuVulns(context_wrap('', path='meltdown')) assert "Input content is empty" in str(sc1) @@ -123,7 +123,7 @@ def test_cpu_vulns_spectre_v1_exp1(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: CpuVulns(context_wrap('')) assert "Input content is empty" in str(sc1) @@ -151,7 +151,7 @@ def test_cpu_vulns_spectre_v2_exp1(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: CpuVulns(context_wrap('')) assert "Input content is empty" in str(sc1) diff --git a/insights/tests/parsers/test_cpupower_frequency_info.py b/insights/tests/parsers/test_cpupower_frequency_info.py index 308983cc0d..7a23d4e64d 100644 --- a/insights/tests/parsers/test_cpupower_frequency_info.py +++ b/insights/tests/parsers/test_cpupower_frequency_info.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import cpupower_frequency_info from insights.parsers.cpupower_frequency_info import CpupowerFrequencyInfo from insights.tests import context_wrap @@ -147,7 +147,7 @@ def test_invalid(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: CpupowerFrequencyInfo(context_wrap(CPUPOWER_INFO_EMPTY)) assert "Empty content" in str(e) diff --git a/insights/tests/parsers/test_crypto_policies_bind.py b/insights/tests/parsers/test_crypto_policies_bind.py index 206bf5b447..4dad9275d0 100644 --- a/insights/tests/parsers/test_crypto_policies_bind.py +++ b/insights/tests/parsers/test_crypto_policies_bind.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.crypto_policies import CryptoPoliciesBind from insights.tests import context_wrap @@ -31,7 +31,7 @@ def test_crypto_policies_bind(): def test_crypto_policies_bind_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): CryptoPoliciesBind(context_wrap("")) result = CryptoPoliciesBind(context_wrap(CONFIG_EMPTY_SECTIONS)) assert [] == result.disable_algorithms diff --git a/insights/tests/parsers/test_crypto_policies_config.py b/insights/tests/parsers/test_crypto_policies_config.py index 70fcb95e28..5291fb4f65 100644 --- a/insights/tests/parsers/test_crypto_policies_config.py +++ b/insights/tests/parsers/test_crypto_policies_config.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.crypto_policies import CryptoPoliciesConfig from insights.tests import context_wrap @@ -41,5 +41,5 @@ def test_crypto_policies_commented(): def test_crypto_policies_config_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): CryptoPoliciesConfig(context_wrap("")) diff --git a/insights/tests/parsers/test_crypto_policies_state_current.py b/insights/tests/parsers/test_crypto_policies_state_current.py index 83b22adf4b..d88dd79f4f 100644 --- a/insights/tests/parsers/test_crypto_policies_state_current.py +++ b/insights/tests/parsers/test_crypto_policies_state_current.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.crypto_policies import CryptoPoliciesStateCurrent from insights.tests import context_wrap @@ -15,5 +15,5 @@ def test_crypto_policies_state_current(): def test_crypto_policies_state_current_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): CryptoPoliciesStateCurrent(context_wrap("")) diff --git a/insights/tests/parsers/test_cups_ppd.py b/insights/tests/parsers/test_cups_ppd.py index 74acec8d6b..ff28cab401 100644 --- a/insights/tests/parsers/test_cups_ppd.py +++ b/insights/tests/parsers/test_cups_ppd.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import cups_ppd from insights.parsers.cups_ppd import CupsPpd from insights.tests import context_wrap @@ -39,11 +39,11 @@ def test_cups_ppd(): assert cups_ppd_result["cupsFilter2"] == ['"application/vnd.cups-pdf application/pdf 10 -"', '"application/vnd.cups-postscript application/postscript 10 -"'] assert "test" not in cups_ppd_result - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: CupsPpd(context_wrap(CUPS_PPD_INVALID1, path='/etc/cups/ppd/test_printer1.ppd')) assert 'No Valid Configuration' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: CupsPpd(context_wrap(CUPS_PPD_INVALID2, path='/etc/cups/ppd/test_printer1.ppd')) assert 'No Valid Configuration' in str(exc) diff --git a/insights/tests/parsers/test_date.py b/insights/tests/parsers/test_date.py index c38495cfa5..f1784b5123 100644 --- a/insights/tests/parsers/test_date.py +++ b/insights/tests/parsers/test_date.py @@ -3,7 +3,7 @@ from datetime import datetime -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import date from insights.parsers.date import Date, DateUTC, DateParseException, TimeDateCtlStatus from insights.tests import context_wrap @@ -163,7 +163,7 @@ def test_timedatectl(): def test_timedatectl_except(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): TimeDateCtlStatus(context_wrap(TIMEDATECTL_CONTENT4_WITHOUT_INFO, strip=False)) with pytest.raises(ParseException): TimeDateCtlStatus(context_wrap(TIMEDATECTL_CONTENT4_WITHOUT_COLON_OUTPUT, strip=False)) diff --git a/insights/tests/parsers/test_db2.py b/insights/tests/parsers/test_db2.py index 87ddfdc156..fcd4d5a113 100644 --- a/insights/tests/parsers/test_db2.py +++ b/insights/tests/parsers/test_db2.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import db2 from insights.parsers.db2 import Db2ls from insights.tests import context_wrap @@ -32,9 +32,9 @@ def test_db2ls(): assert db2ls[1]['INSTALLTIME'] == 'Fri Feb 11 10:34:51 2022 CST' assert db2ls[1]['INSTALLERUID'] == '0' - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Db2ls(context_wrap(DB2LS_A_C_EMPTY1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Db2ls(context_wrap(DB2LS_A_C_EMPTY2)) diff --git a/insights/tests/parsers/test_dig.py b/insights/tests/parsers/test_dig.py index 6594e40809..25cbe5db93 100644 --- a/insights/tests/parsers/test_dig.py +++ b/insights/tests/parsers/test_dig.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import dig from insights.parsers.dig import Dig, DigDnssec, DigEdns, DigNoedns from insights.tests import context_wrap @@ -146,7 +146,7 @@ def test_dig_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Dig(context_wrap(""), "") diff --git a/insights/tests/parsers/test_dnf_module.py b/insights/tests/parsers/test_dnf_module.py index 9a0771e673..a4e451d5c7 100644 --- a/insights/tests/parsers/test_dnf_module.py +++ b/insights/tests/parsers/test_dnf_module.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import dnf_module from insights.parsers.dnf_module import DnfModuleList, DnfModuleInfo from insights.tests import context_wrap @@ -191,7 +191,7 @@ def test_dnf_module_list_exp(): with pytest.raises(ValueError): DnfModuleList(context_wrap(DNF_MODULE_LIST_EXP1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): DnfModuleList(context_wrap(DNF_MODULE_LIST_EXP2)) @@ -210,7 +210,7 @@ def test_dnf_module_info(): def test_dnf_module_info_exp(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): DnfModuleInfo(context_wrap(DNF_MODULE_INFO_EXP)) diff --git a/insights/tests/parsers/test_docker_inspect.py b/insights/tests/parsers/test_docker_inspect.py index 27289df1d9..ed0043f180 100644 --- a/insights/tests/parsers/test_docker_inspect.py +++ b/insights/tests/parsers/test_docker_inspect.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import docker_inspect from insights.tests import context_wrap @@ -301,7 +301,7 @@ def test_docker_object_image_inspect(): def test_docker_container_inspect_truncated_input(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): docker_inspect.DockerInspectContainer(context_wrap(DOCKER_CONTAINER_INSPECT_TRUNCATED)) diff --git a/insights/tests/parsers/test_docker_list.py b/insights/tests/parsers/test_docker_list.py index bf5fde6df7..b525504421 100644 --- a/insights/tests/parsers/test_docker_list.py +++ b/insights/tests/parsers/test_docker_list.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import docker_list from insights.tests import context_wrap @@ -79,17 +79,17 @@ def test_docker_list_containers(): def test_docker_list_images_no_data(): - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: docker_list.DockerListImages(context_wrap(DOCKER_LIST_IMAGES_NO_DATA)) assert 'No data.' in str(ex) def test_docker_list_images_help_output(): - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: docker_list.DockerListImages(context_wrap(DOCKER_HELP_OUTPUT)) assert 'No data only help output.' in str(ex) - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: docker_list.DockerListContainers(context_wrap(DOCKER_HELP_OUTPUT)) assert 'No data only help output.' in str(ex) diff --git a/insights/tests/parsers/test_dotnet.py b/insights/tests/parsers/test_dotnet.py index 3ddb8600ed..5ccd79513a 100644 --- a/insights/tests/parsers/test_dotnet.py +++ b/insights/tests/parsers/test_dotnet.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import dotnet from insights.parsers.dotnet import DotNetVersion, ContainerDotNetVersion from insights.tests import context_wrap @@ -40,7 +40,7 @@ def test_dotnet_version_ab(): assert ret is None assert "Unrecognized version" in str(pe) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ret = DotNetVersion(context_wrap(dotnet_version_5)) assert ret is None diff --git a/insights/tests/parsers/test_doveconf.py b/insights/tests/parsers/test_doveconf.py index 06bb1932eb..bb8f1ad8c2 100644 --- a/insights/tests/parsers/test_doveconf.py +++ b/insights/tests/parsers/test_doveconf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import doveconf from insights.parsers.doveconf import Doveconf from insights.tests import context_wrap @@ -189,7 +189,7 @@ def test_doveconf(): def test_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Doveconf(context_wrap(EMPTY)) diff --git a/insights/tests/parsers/test_du.py b/insights/tests/parsers/test_du.py index 75782e7de1..6eb1bfa4fd 100644 --- a/insights/tests/parsers/test_du.py +++ b/insights/tests/parsers/test_du.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import du from insights.parsers.du import DiskUsage from insights.tests import context_wrap @@ -121,7 +121,7 @@ def test_du(): def test_du_bad(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: DiskUsage(context_wrap(DU_ACCESS_ERROR)) assert 'No data parsed' in str(exc) diff --git a/insights/tests/parsers/test_engine_db_query.py b/insights/tests/parsers/test_engine_db_query.py index 280415d010..d19f44fd5b 100644 --- a/insights/tests/parsers/test_engine_db_query.py +++ b/insights/tests/parsers/test_engine_db_query.py @@ -4,7 +4,7 @@ from insights.core.exceptions import ParseException from insights.parsers import engine_db_query from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check OUTPUT = """ @@ -94,7 +94,7 @@ def test_edbq(): assert output.result == [{'vds_name': 'hosto', 'rpm_version': 'vdsm-4.40.20-33.git1b7dedcf3.fc30'}, {'vds_name': 'hosto2', 'rpm_version': 'vdsm-4.40.13-38.gite9bae3c68.fc30'}] # No content - assert 'Empty output.' in skip_exception_check(engine_db_query.EngineDBQueryVDSMversion) + assert 'Empty output.' in skip_component_check(engine_db_query.EngineDBQueryVDSMversion) # Error with pytest.raises(ParseException) as e: diff --git a/insights/tests/parsers/test_etcd_conf.py b/insights/tests/parsers/test_etcd_conf.py index 4f15d4b9e2..4870537cb5 100644 --- a/insights/tests/parsers/test_etcd_conf.py +++ b/insights/tests/parsers/test_etcd_conf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import etcd_conf from insights.parsers.etcd_conf import EtcdConf from insights.tests import context_wrap @@ -23,7 +23,7 @@ def test_etcd_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert etcd_conf.EtcdConf(context_wrap('')) is None diff --git a/insights/tests/parsers/test_fcoeadm_i.py b/insights/tests/parsers/test_fcoeadm_i.py index 746465dca1..178744b171 100644 --- a/insights/tests/parsers/test_fcoeadm_i.py +++ b/insights/tests/parsers/test_fcoeadm_i.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import fcoeadm_i from insights.parsers.fcoeadm_i import FcoeadmI from insights.tests import context_wrap @@ -84,7 +84,7 @@ def test_fcoeadm_i_exp(): Here test the examples cause expections """ - with pytest.raises(SkipException) as sc: + with pytest.raises(SkipComponent) as sc: FcoeadmI(context_wrap("")) assert "Input content is empty" in str(sc) diff --git a/insights/tests/parsers/test_findmnt.py b/insights/tests/parsers/test_findmnt.py index 16301a7520..436fdb12b7 100644 --- a/insights/tests/parsers/test_findmnt.py +++ b/insights/tests/parsers/test_findmnt.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import findmnt from insights.tests import context_wrap @@ -92,7 +92,7 @@ def test_findmnt_output(): def test_blank_output(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: findmnt.FindmntPropagation(context_wrap("")) assert "No data." in str(e) diff --git a/insights/tests/parsers/test_firewall_config.py b/insights/tests/parsers/test_firewall_config.py index 49338801e1..27a4e3d094 100644 --- a/insights/tests/parsers/test_firewall_config.py +++ b/insights/tests/parsers/test_firewall_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import firewall_config from insights.parsers.firewall_config import FirewallDConf from insights.tests import context_wrap @@ -42,5 +42,5 @@ def test_docs(): def test_empty_content(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): FirewallDConf(context_wrap(FIREWALLD_CONFIG_2)) diff --git a/insights/tests/parsers/test_freeipa_healthcheck_log.py b/insights/tests/parsers/test_freeipa_healthcheck_log.py index d412330198..e00cf13225 100644 --- a/insights/tests/parsers/test_freeipa_healthcheck_log.py +++ b/insights/tests/parsers/test_freeipa_healthcheck_log.py @@ -2,7 +2,7 @@ from insights.parsers import freeipa_healthcheck_log from insights.parsers.freeipa_healthcheck_log import FreeIPAHealthCheckLog -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check from insights.tests import context_wrap LONG_FREEIPA_HEALTHCHECK_LOG_OK = """ @@ -99,7 +99,7 @@ def test_freeipa_healthcheck_get_results_not_ok(): def test_freeipa_healthcheck_log_empty(): - assert 'Empty output.' in skip_exception_check(FreeIPAHealthCheckLog) + assert 'Empty output.' in skip_component_check(FreeIPAHealthCheckLog) def test_freeipa_healthcheck_log__documentation(): diff --git a/insights/tests/parsers/test_gcp_instance_type.py b/insights/tests/parsers/test_gcp_instance_type.py index 36261b6dbe..408390eb2b 100644 --- a/insights/tests/parsers/test_gcp_instance_type.py +++ b/insights/tests/parsers/test_gcp_instance_type.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import gcp_instance_type from insights.parsers.gcp_instance_type import GCPInstanceType from insights.tests import context_wrap @@ -31,13 +31,13 @@ def test_gcp_instance_type_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPInstanceType(context_wrap(GOOGLE_TYPE_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPInstanceType(context_wrap(GOOGLE_TYPE_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPInstanceType(context_wrap(GOOGLE_TYPE_AB_3)) with pytest.raises(ParseException) as pe: @@ -46,7 +46,7 @@ def test_gcp_instance_type_ab_other(): def test_gcp_instance_type_ab_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPInstanceType(context_wrap('')) diff --git a/insights/tests/parsers/test_gcp_license_codes.py b/insights/tests/parsers/test_gcp_license_codes.py index 5369deb4fa..127bddbe21 100644 --- a/insights/tests/parsers/test_gcp_license_codes.py +++ b/insights/tests/parsers/test_gcp_license_codes.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import gcp_license_codes from insights.parsers.gcp_license_codes import GCPLicenseCodes from insights.tests import context_wrap @@ -32,16 +32,16 @@ def test_azure_instance_place_ab_other(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPLicenseCodes(context_wrap(GCP_LICENSE_CODES_AB_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPLicenseCodes(context_wrap(GCP_LICENSE_CODES_AB_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPLicenseCodes(context_wrap(GCP_LICENSE_CODES_AB_3)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GCPLicenseCodes(context_wrap('')) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_getsebool.py b/insights/tests/parsers/test_getsebool.py index 1bdfd87b5f..fd8c60196f 100644 --- a/insights/tests/parsers/test_getsebool.py +++ b/insights/tests/parsers/test_getsebool.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import getsebool from insights.tests import context_wrap @@ -40,6 +40,6 @@ def test_getsebool(): def test_getsebool_disabled(): - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: getsebool.Getsebool(context_wrap(SELINUX_DISABLED)) assert 'SELinux is disabled' in str(excinfo.value) diff --git a/insights/tests/parsers/test_gfs2_file_system_block_size.py b/insights/tests/parsers/test_gfs2_file_system_block_size.py index 77d9c12013..36fb4f0599 100644 --- a/insights/tests/parsers/test_gfs2_file_system_block_size.py +++ b/insights/tests/parsers/test_gfs2_file_system_block_size.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import gfs2_file_system_block_size from insights.tests import context_wrap @@ -29,11 +29,11 @@ def test_exp(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): gfs2_file_system_block_size.GFS2FileSystemBlockSize(context_wrap(BLOCK_SIZE_OUTPUT_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): gfs2_file_system_block_size.GFS2FileSystemBlockSize(context_wrap(BLOCK_SIZE_OUTPUT_4)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): gfs2_file_system_block_size.GFS2FileSystemBlockSize(context_wrap(BLOCK_SIZE_OUTPUT_5)) diff --git a/insights/tests/parsers/test_gluster_peer_status.py b/insights/tests/parsers/test_gluster_peer_status.py index f6194b6ac8..1b749cd5ae 100644 --- a/insights/tests/parsers/test_gluster_peer_status.py +++ b/insights/tests/parsers/test_gluster_peer_status.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import gluster_peer_status from insights.tests import context_wrap @@ -41,7 +41,7 @@ def test_output(): def test_blank_output(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: gluster_peer_status.GlusterPeerStatus(context_wrap("")) assert "No data." in str(e) diff --git a/insights/tests/parsers/test_grubby.py b/insights/tests/parsers/test_grubby.py index 1686fd5ffe..023304c774 100644 --- a/insights/tests/parsers/test_grubby.py +++ b/insights/tests/parsers/test_grubby.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import grubby from insights.parsers.grubby import GrubbyDefaultIndex, GrubbyDefaultKernel from insights.tests import context_wrap @@ -29,7 +29,7 @@ def test_grubby_default_index(): def test_grubby_default_index_ab(): - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: GrubbyDefaultIndex(context_wrap(ABDEFAULT_INDEX_EMPTY)) assert 'Empty output' in str(excinfo.value) @@ -39,7 +39,7 @@ def test_grubby_default_index_ab(): def test_grubby_default_kernel_ab(): - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: GrubbyDefaultKernel(context_wrap(DEFAULT_KERNEL_EMPTY)) assert 'Empty output' in str(excinfo.value) diff --git a/insights/tests/parsers/test_grubenv.py b/insights/tests/parsers/test_grubenv.py index 8c42618769..20682ea83d 100644 --- a/insights/tests/parsers/test_grubenv.py +++ b/insights/tests/parsers/test_grubenv.py @@ -1,8 +1,8 @@ import doctest from insights.parsers import grubenv -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check GRUBENV_WITH_TUNED_PARAMS = """ @@ -73,8 +73,8 @@ def test_r7(): def test_skip(): - skip_exception_check(grubenv.GrubEnv, output_str="# test") - skip_exception_check(grubenv.GrubEnv) + skip_component_check(grubenv.GrubEnv, output_str="# test") + skip_component_check(grubenv.GrubEnv) def test_error(): diff --git a/insights/tests/parsers/test_hammer_ping.py b/insights/tests/parsers/test_hammer_ping.py index 2267556700..76d8d175ea 100644 --- a/insights/tests/parsers/test_hammer_ping.py +++ b/insights/tests/parsers/test_hammer_ping.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import hammer_ping from insights.parsers.hammer_ping import HammerPing from insights.tests import context_wrap @@ -261,7 +261,7 @@ def test_raw_content(): def test_content_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): HammerPing(context_wrap(HAMMERPING_EMPTY)) diff --git a/insights/tests/parsers/test_hosts.py b/insights/tests/parsers/test_hosts.py index fe7f4d198b..723a45f75e 100644 --- a/insights/tests/parsers/test_hosts.py +++ b/insights/tests/parsers/test_hosts.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import hosts from insights.parsers.hosts import Hosts from insights.tests import context_wrap @@ -108,7 +108,7 @@ def test_ip_of(): def test_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Hosts(context_wrap("")) diff --git a/insights/tests/parsers/test_httpd_V.py b/insights/tests/parsers/test_httpd_V.py index 1423115c15..bff4fb3cc5 100644 --- a/insights/tests/parsers/test_httpd_V.py +++ b/insights/tests/parsers/test_httpd_V.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import httpd_V from insights.parsers.httpd_V import HttpdV from insights.tests import context_wrap @@ -108,11 +108,11 @@ def test_httpd_V(): def test_httpd_V_exp(): - with pytest.raises(SkipException) as sc: + with pytest.raises(SkipComponent) as sc: HttpdV(context_wrap("")) assert "Input content is empty" in str(sc) - with pytest.raises(SkipException) as sc: + with pytest.raises(SkipComponent) as sc: HttpdV(context_wrap("TEST")) assert "Input content is not empty but there is no useful parsed data." in str(sc) diff --git a/insights/tests/parsers/test_httpd_open_nfs.py b/insights/tests/parsers/test_httpd_open_nfs.py index 9e68bb1496..091c67b000 100644 --- a/insights/tests/parsers/test_httpd_open_nfs.py +++ b/insights/tests/parsers/test_httpd_open_nfs.py @@ -2,8 +2,8 @@ from insights.parsers import httpd_open_nfs from insights.parsers.httpd_open_nfs import HttpdOnNFSFilesCount -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check http_nfs = """ {"http_ids": [1787, 2399], "nfs_mounts": ["/data", "/www"], "open_nfs_files": 1000} @@ -19,7 +19,7 @@ def test_http_nfs(): def test_empty(): - assert 'Empty output.' in skip_exception_check(HttpdOnNFSFilesCount) + assert 'Empty output.' in skip_component_check(HttpdOnNFSFilesCount) def test_http_nfs_documentation(): diff --git a/insights/tests/parsers/test_ibm_proc.py b/insights/tests/parsers/test_ibm_proc.py index c3f0430432..cd56fd50e5 100644 --- a/insights/tests/parsers/test_ibm_proc.py +++ b/insights/tests/parsers/test_ibm_proc.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ibm_proc from insights.parsers.ibm_proc import IBMPpcLparCfg, IBMFirmwareLevel from insights.tests import context_wrap @@ -31,13 +31,13 @@ def test_ibm_proc(): def test_ibm_proc_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): IBMPpcLparCfg(context_wrap('')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): IBMFirmwareLevel(context_wrap('')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): IBMFirmwareLevel(context_wrap(PROC_IBM_FWL_NG)) diff --git a/insights/tests/parsers/test_imagemagick_policy.py b/insights/tests/parsers/test_imagemagick_policy.py index 07f2bf72df..6bafac621a 100644 --- a/insights/tests/parsers/test_imagemagick_policy.py +++ b/insights/tests/parsers/test_imagemagick_policy.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import imagemagick_policy from insights.parsers.imagemagick_policy import ImageMagickPolicy from insights.tests import context_wrap @@ -93,7 +93,7 @@ def test_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ImageMagickPolicy(context_wrap("")) diff --git a/insights/tests/parsers/test_ip_netns_exec_namespace_lsof.py b/insights/tests/parsers/test_ip_netns_exec_namespace_lsof.py index 7bb62a86aa..260d8dd0a5 100644 --- a/insights/tests/parsers/test_ip_netns_exec_namespace_lsof.py +++ b/insights/tests/parsers/test_ip_netns_exec_namespace_lsof.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ip_netns_exec_namespace_lsof from insights.parsers.ip_netns_exec_namespace_lsof import IpNetnsExecNamespaceLsofI from insights.tests import context_wrap @@ -39,12 +39,12 @@ def test_ip_netns_exec_namespace_lsof_documentation(): def test_ip_netns_exec_namespace_lsof_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: IpNetnsExecNamespaceLsofI(context_wrap(EXCEPTION1)) assert "Empty file" in str(e) def test_ip_netns_exec_namespace_lsof_exception2(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: IpNetnsExecNamespaceLsofI(context_wrap(EXCEPTION2)) assert "Useless data" in str(e) diff --git a/insights/tests/parsers/test_ipcs.py b/insights/tests/parsers/test_ipcs.py index 3aa6ce7509..c605d5a944 100644 --- a/insights/tests/parsers/test_ipcs.py +++ b/insights/tests/parsers/test_ipcs.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import ipcs from insights.parsers.ipcs import IpcsS, IpcsSI, IpcsM, IpcsMP from insights.tests import context_wrap @@ -98,7 +98,7 @@ def test_ipcs_mp(): def test_ipcs_abnormal(): - with pytest.raises(SkipException) as pe: + with pytest.raises(SkipComponent) as pe: IpcsMP(context_wrap("")) assert "Nothing to parse." in str(pe) diff --git a/insights/tests/parsers/test_ipsec_conf.py b/insights/tests/parsers/test_ipsec_conf.py index 19df6d8367..3f7669edcb 100644 --- a/insights/tests/parsers/test_ipsec_conf.py +++ b/insights/tests/parsers/test_ipsec_conf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ipsec_conf from insights.parsers.ipsec_conf import IpsecConf from insights.tests import context_wrap @@ -32,7 +32,7 @@ def test_config_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): IpsecConf(context_wrap("")) diff --git a/insights/tests/parsers/test_kernel_config.py b/insights/tests/parsers/test_kernel_config.py index 8e79e90250..7a2b1c9cda 100644 --- a/insights/tests/parsers/test_kernel_config.py +++ b/insights/tests/parsers/test_kernel_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import kernel_config from insights.parsers.kernel_config import KernelConf from insights.tests import context_wrap @@ -61,7 +61,7 @@ def test_kernel_config(): r = KernelConf(context_wrap(KERNEL_CONFIG_2, KCONFIG_FILE_PATH)) assert len(r) == 7 - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: r = KernelConf(context_wrap(KERNEL_CONFIG_NO, KCONFIG_FILE_PATH)) assert 'No Contents' in str(exc) diff --git a/insights/tests/parsers/test_kpatch_list.py b/insights/tests/parsers/test_kpatch_list.py index 034622d5ca..ed6287fd37 100644 --- a/insights/tests/parsers/test_kpatch_list.py +++ b/insights/tests/parsers/test_kpatch_list.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import kpatch_list from insights.tests import context_wrap @@ -63,6 +63,6 @@ def test_kpatch_list(): def test_fail(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: kpatch_list.KpatchList(context_wrap(BAD_OUTPUT1)) assert "No Data from command: /usr/sbin/kpatch list" in str(e) diff --git a/insights/tests/parsers/test_ksmstate.py b/insights/tests/parsers/test_ksmstate.py index 130dd54a93..e3bc307533 100644 --- a/insights/tests/parsers/test_ksmstate.py +++ b/insights/tests/parsers/test_ksmstate.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import ksmstate from insights.parsers.ksmstate import KSMState from insights.tests import context_wrap @@ -32,7 +32,7 @@ def test_ksmstate(): def test_ksmstate_exp(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): KSMState(context_wrap(KSMSTATE_ab0)) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_ktimer_lockless.py b/insights/tests/parsers/test_ktimer_lockless.py index b9434e47f7..5e198c8837 100644 --- a/insights/tests/parsers/test_ktimer_lockless.py +++ b/insights/tests/parsers/test_ktimer_lockless.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ktimer_lockless from insights.parsers.ktimer_lockless import KTimerLockless from insights.tests import context_wrap @@ -17,7 +17,7 @@ def test_ktimer_lockless_parser(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: KTimerLockless(context_wrap(KTIMER_LOCKLESS_EMPTY)) assert 'The file is empty' in str(e) diff --git a/insights/tests/parsers/test_ld_library_path.py b/insights/tests/parsers/test_ld_library_path.py index 3024efd955..f010de6f47 100644 --- a/insights/tests/parsers/test_ld_library_path.py +++ b/insights/tests/parsers/test_ld_library_path.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ld_library_path from insights.parsers.ld_library_path import UserLdLibraryPath from insights.tests import context_wrap @@ -45,7 +45,7 @@ def test_ld_library_path(): def test_empty_and_invalid(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): UserLdLibraryPath(context_wrap(LD_LIBRARY_PATH_EMPTY)) diff --git a/insights/tests/parsers/test_ldif_config.py b/insights/tests/parsers/test_ldif_config.py index 32612672d1..6267dd9b2b 100644 --- a/insights/tests/parsers/test_ldif_config.py +++ b/insights/tests/parsers/test_ldif_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +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 @@ -214,7 +214,7 @@ def test_ldif_parser(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: LDIFParser(context_wrap(LDIF_CONFIG_EMPTY)) assert 'The file is empty' in str(e) diff --git a/insights/tests/parsers/test_libssh_config.py b/insights/tests/parsers/test_libssh_config.py index 98d31e3874..af8853e82d 100644 --- a/insights/tests/parsers/test_libssh_config.py +++ b/insights/tests/parsers/test_libssh_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import libssh_config from insights.parsers.libssh_config import LibsshConfig from insights.tests import context_wrap @@ -22,7 +22,7 @@ def test_config_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): LibsshConfig(context_wrap("")) diff --git a/insights/tests/parsers/test_losetup.py b/insights/tests/parsers/test_losetup.py index 7fad1db0dc..de571d86d4 100644 --- a/insights/tests/parsers/test_losetup.py +++ b/insights/tests/parsers/test_losetup.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import losetup from insights.parsers.losetup import LoSetup from insights.tests import context_wrap @@ -56,7 +56,7 @@ def test_losetup(): assert 'DIO' not in losetup[0] assert 'LOG-SEC' not in losetup[0] - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): LoSetup(context_wrap(LOSETUP_EMPTY)) diff --git a/insights/tests/parsers/test_lpstat.py b/insights/tests/parsers/test_lpstat.py index 28edb540d5..dab27b7757 100644 --- a/insights/tests/parsers/test_lpstat.py +++ b/insights/tests/parsers/test_lpstat.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import lpstat from insights.parsers.lpstat import LpstatPrinters, LpstatProtocol from insights.tests import context_wrap @@ -89,11 +89,11 @@ def test_lpstat_protocol(): def test_lpstat_protocol_invalid_state(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: LpstatProtocol(context_wrap(LPSTAT_V_OUTPUT_INVALID_1)) assert 'No Valid Output' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: LpstatProtocol(context_wrap(LPSTAT_V_OUTPUT_INVALID_2)) assert 'No Valid Output' in str(exc) diff --git a/insights/tests/parsers/test_lscpu.py b/insights/tests/parsers/test_lscpu.py index 5cedc55012..f01773fc38 100644 --- a/insights/tests/parsers/test_lscpu.py +++ b/insights/tests/parsers/test_lscpu.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import lscpu from insights.tests import context_wrap @@ -139,7 +139,7 @@ def test_lscpu_output(): def test_lscpu_blank_output(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: lscpu.LsCPU(context_wrap(BLANK)) assert "No data." in str(e) diff --git a/insights/tests/parsers/test_lspci.py b/insights/tests/parsers/test_lspci.py index 3ac99bb964..949e84d724 100644 --- a/insights/tests/parsers/test_lspci.py +++ b/insights/tests/parsers/test_lspci.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import lspci from insights.parsers.lspci import LsPci, LsPciVmmkn from insights.tests import context_wrap @@ -315,10 +315,10 @@ def test_lspci_vmmkn(): def test_lspci_vmmkn_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): LsPciVmmkn(context_wrap('')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): LsPciVmmkn(context_wrap(' \n '.splitlines())) diff --git a/insights/tests/parsers/test_lssap.py b/insights/tests/parsers/test_lssap.py index 533ad6d600..23731951a3 100644 --- a/insights/tests/parsers/test_lssap.py +++ b/insights/tests/parsers/test_lssap.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import lssap from insights.tests import context_wrap from insights.util import keys_in @@ -162,7 +162,7 @@ def test_fail(): lssap.Lssap(context_wrap(Lssap_BAD1)) assert "Lssap: Unable to parse 1 line(s) of content: (['HA2| 16| D16| lu0417'])" in str(excinfo) - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: lssap.Lssap(context_wrap(Lssap_BAD2)) with pytest.raises(ParseException) as excinfo: diff --git a/insights/tests/parsers/test_lvm.py b/insights/tests/parsers/test_lvm.py index 9b4584fedc..bca111f2df 100644 --- a/insights/tests/parsers/test_lvm.py +++ b/insights/tests/parsers/test_lvm.py @@ -2,7 +2,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import lvm from insights.tests import context_wrap from insights.tests.parsers.lvm_test_data import LVMCONFIG, LVMCONFIG2, LVMCONFIG3 @@ -224,7 +224,7 @@ def test_system_devices(): def test_system_devices_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): lvm.LvmSystemDevices(context_wrap(SYSTEM_DEVICES3)) diff --git a/insights/tests/parsers/test_max_uid.py b/insights/tests/parsers/test_max_uid.py index 41bc547871..2f1a764721 100644 --- a/insights/tests/parsers/test_max_uid.py +++ b/insights/tests/parsers/test_max_uid.py @@ -1,14 +1,14 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import max_uid from insights.parsers.max_uid import MaxUID from insights.tests import context_wrap def test_max_uid(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): MaxUID(context_wrap("")) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_mdstat.py b/insights/tests/parsers/test_mdstat.py index 4db8a9a67d..db3630c58a 100644 --- a/insights/tests/parsers/test_mdstat.py +++ b/insights/tests/parsers/test_mdstat.py @@ -4,7 +4,7 @@ from insights.core.exceptions import ParseException from insights.parsers import mdstat from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check MDSTAT_TEST_1 = """ Personalities : [raid1] [raid6] [raid5] [raid4] @@ -244,5 +244,5 @@ def compare_mdstat_data(test_data, parser_obj): def test_skip(): - skip_exception_check(mdstat.Mdstat, output_str=NO_MD_DEVICES) - skip_exception_check(mdstat.Mdstat) + skip_component_check(mdstat.Mdstat, output_str=NO_MD_DEVICES) + skip_component_check(mdstat.Mdstat) diff --git a/insights/tests/parsers/test_modinfo.py b/insights/tests/parsers/test_modinfo.py index 3a133e897f..450ca636dd 100644 --- a/insights/tests/parsers/test_modinfo.py +++ b/insights/tests/parsers/test_modinfo.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import modinfo from insights.parsers.modinfo import ModInfoEach, ModInfoAll, KernelModulesInfo from insights.tests import context_wrap @@ -206,11 +206,11 @@ def test_kernel_modules_info(): assert modules_info['igb'].module_name == 'igb' assert modules_info['igb'].module_path == '/lib/modules/3.10.0-327.10.1.el7.jump7.x86_64/kernel/drivers/net/ethernet/intel/igb/igb.ko' - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: KernelModulesInfo(context_wrap(MODINFO_NO_1)) assert 'No Parsed Contents' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: KernelModulesInfo(context_wrap('')) assert 'No Contents' in str(exc) diff --git a/insights/tests/parsers/test_mount.py b/insights/tests/parsers/test_mount.py index 21b4becc37..b11290a32e 100644 --- a/insights/tests/parsers/test_mount.py +++ b/insights/tests/parsers/test_mount.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import mount from insights.parsers.mount import Mount, ProcMounts, MountInfo from insights.tests import context_wrap @@ -267,7 +267,7 @@ def test_proc_mount(): def test_proc_mount_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: ProcMounts(context_wrap(PROC_EXCEPTION1)) assert 'Empty content' in str(e) diff --git a/insights/tests/parsers/test_mpirun.py b/insights/tests/parsers/test_mpirun.py index 2ef525ed4d..e5ad0a5807 100644 --- a/insights/tests/parsers/test_mpirun.py +++ b/insights/tests/parsers/test_mpirun.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import mpirun from insights.parsers.mpirun import MPIrunVersion from insights.tests import context_wrap @@ -34,11 +34,11 @@ def test_mpirun_version(): def test_mpirun_version_ab(): - with pytest.raises(SkipException) as e_skip: + with pytest.raises(SkipComponent) as e_skip: MPIrunVersion(context_wrap(MPIRUN_VERSION_4)) assert "Empty content" in str(e_skip.value) - with pytest.raises(SkipException) as e_skip: + with pytest.raises(SkipComponent) as e_skip: MPIrunVersion(context_wrap(MPIRUN_VERSION_3)) assert "Content not parsable" in str(e_skip.value) diff --git a/insights/tests/parsers/test_multipath_conf.py b/insights/tests/parsers/test_multipath_conf.py index 8cec12be22..cd0a3533d1 100644 --- a/insights/tests/parsers/test_multipath_conf.py +++ b/insights/tests/parsers/test_multipath_conf.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import multipath_conf from insights.parsr.query import first, last from insights.tests import context_wrap @@ -94,16 +94,16 @@ def test_multipath_conf_trees(): def test_empty_multipath_conf_tree(): - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: multipath_conf.MultipathConfTree(context_wrap(INPUT_EMPTY)) assert "Empty content." in str(e_info.value) - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: multipath_conf.MultipathConfTreeInitramfs(context_wrap(INPUT_EMPTY)) assert "Empty content." in str(e_info.value) def test_empty_multipath_conf(): - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: multipath_conf.MultipathConfParser(context_wrap(INPUT_EMPTY)) assert "Empty content." in str(e_info.value) diff --git a/insights/tests/parsers/test_mysqladmin.py b/insights/tests/parsers/test_mysqladmin.py index 63d369be6f..d46b84c9b4 100644 --- a/insights/tests/parsers/test_mysqladmin.py +++ b/insights/tests/parsers/test_mysqladmin.py @@ -1,7 +1,7 @@ -import pytest import doctest +import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import mysqladmin from insights.parsers.mysqladmin import MysqladminVars, MysqladminStatus from insights.tests import context_wrap @@ -31,7 +31,7 @@ def test_mysqladmin_status(): def test_mysqlstat_blank_input(): - with pytest.raises(SkipException) as sc: + with pytest.raises(SkipComponent) as sc: MysqladminStatus(context_wrap(BLANK_SAMPLE)) assert "Content is empty." in str(sc.value) @@ -106,7 +106,7 @@ def test_mysqladmin_vars(): def test_empty_mysqladmin_var(): - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: MysqladminVars(context_wrap("")) assert "Empty content." in str(e_info.value) diff --git a/insights/tests/parsers/test_named_checkconf.py b/insights/tests/parsers/test_named_checkconf.py index 317be56125..d5948257e4 100644 --- a/insights/tests/parsers/test_named_checkconf.py +++ b/insights/tests/parsers/test_named_checkconf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import named_checkconf from insights.parsers.named_checkconf import NamedCheckconf from insights.tests import context_wrap @@ -171,7 +171,7 @@ def test_config_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NamedCheckconf(context_wrap("")) diff --git a/insights/tests/parsers/test_named_conf.py b/insights/tests/parsers/test_named_conf.py index fb54c0ad03..be7c7680be 100644 --- a/insights/tests/parsers/test_named_conf.py +++ b/insights/tests/parsers/test_named_conf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import named_conf from insights.parsers.named_conf import NamedConf from insights.tests import context_wrap @@ -196,12 +196,12 @@ def test_config_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NamedConf(context_wrap("")) def test_config_invalid_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NamedConf(context_wrap(CONFIG_INVALID_SECTIONS)) diff --git a/insights/tests/parsers/test_ndctl_list.py b/insights/tests/parsers/test_ndctl_list.py index b12cfd6db9..e16eddab55 100644 --- a/insights/tests/parsers/test_ndctl_list.py +++ b/insights/tests/parsers/test_ndctl_list.py @@ -2,7 +2,7 @@ from insights.parsers import ndctl_list from insights.parsers.ndctl_list import NdctlListNi -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check from insights.tests import context_wrap NDCTL_OUTPUT = """ @@ -54,4 +54,4 @@ def test_get_dev_attr(): def test_empty(): - assert 'Empty output.' in skip_exception_check(NdctlListNi) + assert 'Empty output.' in skip_component_check(NdctlListNi) diff --git a/insights/tests/parsers/test_net_namespace.py b/insights/tests/parsers/test_net_namespace.py index 00298cebdc..643ca67ff9 100644 --- a/insights/tests/parsers/test_net_namespace.py +++ b/insights/tests/parsers/test_net_namespace.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import net_namespace from insights.parsers.net_namespace import NetworkNamespace from insights.tests import context_wrap @@ -58,10 +58,10 @@ def test_bond_class(): def test_abnormal(): - with pytest.raises(SkipException) as pe: + with pytest.raises(SkipComponent) as pe: NetworkNamespace(context_wrap(LIST_NAMESPACE_3)) assert "Nothing to parse." in str(pe) - with pytest.raises(SkipException) as pe: + with pytest.raises(SkipComponent) as pe: NetworkNamespace(context_wrap(CMD_LIST_NAMESPACE_3)) assert "Nothing to parse." in str(pe) diff --git a/insights/tests/parsers/test_netstat.py b/insights/tests/parsers/test_netstat.py index 2f2236893e..2c038e0527 100644 --- a/insights/tests/parsers/test_netstat.py +++ b/insights/tests/parsers/test_netstat.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import netstat from insights.parsers.netstat import Netstat, NetstatAGN, NetstatS, Netstat_I, SsTULPN, SsTUPNA, ProcNsat from insights.tests import context_wrap @@ -774,7 +774,7 @@ def test_proc_netstat(): assert len(pnstat.data) == 131 assert pnstat.get_stats('TCPWqueueTooBig') == 10 - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: pnstat = ProcNsat(context_wrap(PROC_NETSTAT_3)) assert 'No Contents' in str(exc) with pytest.raises(ParseException) as exc: diff --git a/insights/tests/parsers/test_networkmanager_dhclient.py b/insights/tests/parsers/test_networkmanager_dhclient.py index 67b7b2ba66..e583227a8c 100644 --- a/insights/tests/parsers/test_networkmanager_dhclient.py +++ b/insights/tests/parsers/test_networkmanager_dhclient.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import networkmanager_dhclient from insights.parsers.networkmanager_dhclient import NetworkManagerDhclient from insights.tests import context_wrap @@ -97,7 +97,7 @@ def test_no_data(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NetworkManagerDhclient(context_wrap("")) diff --git a/insights/tests/parsers/test_nfnetlink_queue.py b/insights/tests/parsers/test_nfnetlink_queue.py index 3b40eeb37f..63611c3de3 100644 --- a/insights/tests/parsers/test_nfnetlink_queue.py +++ b/insights/tests/parsers/test_nfnetlink_queue.py @@ -4,7 +4,7 @@ from insights.core.exceptions import ParseException from insights.parsers import nfnetlink_queue from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check NFNETLINK_QUEUE = """ @@ -82,4 +82,4 @@ def test_wrong_type(): def test_empty_content(): - skip_exception_check(nfnetlink_queue.NfnetLinkQueue) + skip_component_check(nfnetlink_queue.NfnetLinkQueue) diff --git a/insights/tests/parsers/test_nmcli.py b/insights/tests/parsers/test_nmcli.py index f8952caab7..580738dad9 100644 --- a/insights/tests/parsers/test_nmcli.py +++ b/insights/tests/parsers/test_nmcli.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import nmcli from insights.parsers.nmcli import NmcliConnShow, NmcliDevShow, NmcliDevShowSos from insights.tests import context_wrap @@ -233,13 +233,13 @@ def test_static_connection_test_4(): def test_nmcli_dev_show_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NmcliDevShow(context_wrap('')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NmcliDevShow(context_wrap('GENERAL.TYPE: ethernet')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NmcliDevShow(context_wrap('Error')) @@ -254,7 +254,7 @@ def test_nmcli_doc_examples(): def test_nmcli_exceptions(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: nmcli_obj = NmcliConnShow(context_wrap(NMCLI_SHOW_ERROR)) nmcli_obj = NmcliConnShow(context_wrap(NMCLI_SHOW_ERROR_2)) assert nmcli_obj is None diff --git a/insights/tests/parsers/test_nova_user_ids.py b/insights/tests/parsers/test_nova_user_ids.py index 4056457504..e8eaad561b 100644 --- a/insights/tests/parsers/test_nova_user_ids.py +++ b/insights/tests/parsers/test_nova_user_ids.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import nova_user_ids from insights.tests import context_wrap @@ -34,12 +34,12 @@ def test_nova_uid(): assert nova_uid.data == 162 # 'nova' user not found - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: nova_user_ids.NovaUID(context_wrap(NOVA_USER_NOT_FOUND)) assert '' in str(ex) # Blank input - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: nova_user_ids.NovaUID(context_wrap('')) assert '' in str(ex) @@ -54,12 +54,12 @@ def test_nova_migration_uid(): assert nova_migration_uid.data == 153 # 'nova_migration' user not found - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: nova_user_ids.NovaMigrationUID(context_wrap(NOVA_MIGRATION_USER_NOT_FOUND)) assert '' in str(ex) # Blank input - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: nova_user_ids.NovaMigrationUID(context_wrap('')) assert '' in str(ex) diff --git a/insights/tests/parsers/test_numa_cpus.py b/insights/tests/parsers/test_numa_cpus.py index 624deb1c73..ea7dcb9b90 100644 --- a/insights/tests/parsers/test_numa_cpus.py +++ b/insights/tests/parsers/test_numa_cpus.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import numa_cpus from insights.parsers.numa_cpus import NUMACpus from insights.tests import context_wrap @@ -55,7 +55,7 @@ def test_cpulist_node0(): assert cpu_obj.numa_node_cpus == ['4-7'] assert cpu_obj.total_numa_node_cpus == 4 - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: cpu_obj = NUMACpus(context_wrap(NODE1_CPULIST_RANGE, NODE1_PATH)) assert cpu_obj.numa_node_name == 'node1' assert not cpu_obj.total_numa_node_cpus diff --git a/insights/tests/parsers/test_nvme_core_io_timeout.py b/insights/tests/parsers/test_nvme_core_io_timeout.py index ca35d60c51..d62b63a436 100644 --- a/insights/tests/parsers/test_nvme_core_io_timeout.py +++ b/insights/tests/parsers/test_nvme_core_io_timeout.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import nvme_core_io_timeout from insights.parsers.nvme_core_io_timeout import NVMeCoreIOTimeout from insights.tests import context_wrap @@ -17,10 +17,10 @@ def test_nvme_core_io_timeout_se(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NVMeCoreIOTimeout(context_wrap('')) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): NVMeCoreIOTimeout(context_wrap(NVME_CORE_IO_TIMEOUT_INVALID_1)) diff --git a/insights/tests/parsers/test_od_cpu_dma_latency.py b/insights/tests/parsers/test_od_cpu_dma_latency.py index 5292cf7fc6..28aaccf913 100644 --- a/insights/tests/parsers/test_od_cpu_dma_latency.py +++ b/insights/tests/parsers/test_od_cpu_dma_latency.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import od_cpu_dma_latency from insights.parsers.od_cpu_dma_latency import OdCpuDmaLatency from insights.tests import context_wrap @@ -23,5 +23,5 @@ def test_OdCpuDmaLatency(): d = OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY)) assert d.force_latency == 2000000000 - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY_EMPTY)) diff --git a/insights/tests/parsers/test_open_vm_tools.py b/insights/tests/parsers/test_open_vm_tools.py index ccedc5ccec..d7e7f5d0e7 100644 --- a/insights/tests/parsers/test_open_vm_tools.py +++ b/insights/tests/parsers/test_open_vm_tools.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import open_vm_tools from insights.parsers.open_vm_tools import OpenVmToolsStatRawTextSession from insights.tests import context_wrap @@ -24,10 +24,10 @@ def test_OpenVmToolsStatRawTextSession(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): OpenVmToolsStatRawTextSession(context_wrap(V_OUT1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): OpenVmToolsStatRawTextSession(context_wrap(V_OUT2)) o1 = OpenVmToolsStatRawTextSession(context_wrap(V_OUT3)) diff --git a/insights/tests/parsers/test_ovs_appctl_fdb_show_bridge.py b/insights/tests/parsers/test_ovs_appctl_fdb_show_bridge.py index 548cc878df..caefbed981 100644 --- a/insights/tests/parsers/test_ovs_appctl_fdb_show_bridge.py +++ b/insights/tests/parsers/test_ovs_appctl_fdb_show_bridge.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ovs_appctl_fdb_show_bridge from insights.parsers.ovs_appctl_fdb_show_bridge import OVSappctlFdbShowBridge from insights.tests import context_wrap @@ -49,12 +49,12 @@ def test_ovs_appctl_fdb_show_bridge_documentation(): def test_ovs_appctl_fdb_show_bridge_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: OVSappctlFdbShowBridge(context_wrap(EXCEPTION1, path=PATH_BR_INT)) assert "Empty file" in str(e) def test_ovs_appctl_fdb_show_bridge_exception2(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: OVSappctlFdbShowBridge(context_wrap(EXCEPTION2, path=PATH_BR_TUN)) assert "No data present for br_tun" in str(e) diff --git a/insights/tests/parsers/test_ovs_ofctl_dump_flows.py b/insights/tests/parsers/test_ovs_ofctl_dump_flows.py index 02dc2f6bf6..e7fde210b4 100644 --- a/insights/tests/parsers/test_ovs_ofctl_dump_flows.py +++ b/insights/tests/parsers/test_ovs_ofctl_dump_flows.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ovs_ofctl_dump_flows from insights.parsers.ovs_ofctl_dump_flows import OVSofctlDumpFlows from insights.tests import context_wrap @@ -60,15 +60,15 @@ def test_ovs_appctl_fdb_show_bridge(): assert ovs_dump.flow_dumps == sorted([{'cookie': '0x0', 'duration': '4.602s', 'table': '0', 'n_packets': '2', 'n_bytes': '196', 'idle_timeout': '60', 'priority': '65535', 'in_port': '"s1-eth1"', 'vlan_tci': '0x0000', 'dl_src': 'd6:fc:9c:e7:a2:f9', 'dl_dst': 'a2:72:e7:06:75:2e', 'nw_src': '10.0.0.1', 'nw_dst': '10.0.0.3', 'nw_tos': '0', 'icmp_type': '0', 'icmp_code': '0 actions=output:"s1-eth3"'}]) assert ovs_dump._bridges == [{'cookie': '0x0', 'duration': '4.602s', 'table': '0', 'n_packets': '2', 'n_bytes': '196', 'idle_timeout': '60', 'priority': '65535', 'in_port': '"s1-eth1"', 'vlan_tci': '0x0000', 'dl_src': 'd6:fc:9c:e7:a2:f9', 'dl_dst': 'a2:72:e7:06:75:2e', 'nw_src': '10.0.0.1', 'nw_dst': '10.0.0.3', 'nw_tos': '0', 'icmp_type': '0', 'icmp_code': '0 actions=output:"s1-eth3"'}] - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: ovs_obj = OVSofctlDumpFlows(context_wrap(OVS_FLOW_DUMPS_NO, path=PATH_BR0)) assert 'Empty Content!' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: ovs_obj = OVSofctlDumpFlows(context_wrap(OVS_FLOW_DUMPS, path=OVS_PATH_NO)) assert 'Invalid Path!' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: ovs_obj = OVSofctlDumpFlows(context_wrap(OVS_FLOW_DUMPS_NO_2, path=PATH_BR_INT)) assert ovs_obj is None assert 'Invalid Content!' in str(exc) diff --git a/insights/tests/parsers/test_ovs_vsctl.py b/insights/tests/parsers/test_ovs_vsctl.py index ccc6dfb7d8..2fabb205a6 100644 --- a/insights/tests/parsers/test_ovs_vsctl.py +++ b/insights/tests/parsers/test_ovs_vsctl.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ovs_vsctl from insights.parsers.ovs_vsctl import OVSvsctlListBridge from insights.tests import context_wrap @@ -112,6 +112,6 @@ def test_ovs_vsctl(): def test_ovs_vsctl_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: OVSvsctlListBridge(context_wrap(EXCEPTION1)) assert "Empty file" in str(e) diff --git a/insights/tests/parsers/test_ovs_vsctl_list_bridge.py b/insights/tests/parsers/test_ovs_vsctl_list_bridge.py index 1cbe794b63..0aa818c08c 100644 --- a/insights/tests/parsers/test_ovs_vsctl_list_bridge.py +++ b/insights/tests/parsers/test_ovs_vsctl_list_bridge.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ovs_vsctl_list_bridge from insights.parsers.ovs_vsctl_list_bridge import OVSvsctlListBridge from insights.tests import context_wrap @@ -112,6 +112,6 @@ def test_ovs_vsctl_list_bridge(): def test_ovs_vsctl_list_bridge_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: OVSvsctlListBridge(context_wrap(EXCEPTION1)) assert "Empty file" in str(e) diff --git a/insights/tests/parsers/test_package_provides.py b/insights/tests/parsers/test_package_provides.py index f76e05e334..225bbaed02 100644 --- a/insights/tests/parsers/test_package_provides.py +++ b/insights/tests/parsers/test_package_provides.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import package_provides from insights.parsers.package_provides import PackageProvidesCommand from insights.tests import context_wrap @@ -33,7 +33,7 @@ def test_package_provides_command(): def test_package_provides_command_AB(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PackageProvidesCommand(context_wrap(PACKAGE_COMMAND_EMPTY)) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_parsers_module.py b/insights/tests/parsers/test_parsers_module.py index 150f8e4873..c569fa16d3 100644 --- a/insights/tests/parsers/test_parsers_module.py +++ b/insights/tests/parsers/test_parsers_module.py @@ -2,7 +2,7 @@ from collections import OrderedDict -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import (calc_offset, keyword_search, optlist_to_dict, parse_delimited_table, parse_fixed_table, split_kv_pairs, unsplit_lines) @@ -664,6 +664,6 @@ def test_parse_exception(): def test_skip_exception(): - with pytest.raises(SkipException) as e_info: - raise SkipException('This is a skip exception') + with pytest.raises(SkipComponent) as e_info: + raise SkipComponent('This is a skip exception') assert 'This is a skip exception' == str(e_info.value) diff --git a/insights/tests/parsers/test_partitions.py b/insights/tests/parsers/test_partitions.py index cf6aa31a80..4036291792 100644 --- a/insights/tests/parsers/test_partitions.py +++ b/insights/tests/parsers/test_partitions.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import partitions from insights.parsers.partitions import Partitions from insights.tests import context_wrap @@ -96,7 +96,7 @@ def test_partitions_invalid_data(): def test_empty_content(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: Partitions(context_wrap(EMPTY_CONTENT)) assert 'Empty content' in str(exc) diff --git a/insights/tests/parsers/test_passenger_status.py b/insights/tests/parsers/test_passenger_status.py index a775f1e2af..0d0612cda4 100644 --- a/insights/tests/parsers/test_passenger_status.py +++ b/insights/tests/parsers/test_passenger_status.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import passenger_status from insights.parsers.passenger_status import PassengerStatus from insights.tests import context_wrap @@ -101,7 +101,7 @@ def test_passenger_status_2(): def test_passenger_status_ex(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PassengerStatus(context_wrap(PASS_STATUS_EXP1)) diff --git a/insights/tests/parsers/test_pci_rport_target_disk_paths.py b/insights/tests/parsers/test_pci_rport_target_disk_paths.py index 66a5ac16b6..e60943c312 100644 --- a/insights/tests/parsers/test_pci_rport_target_disk_paths.py +++ b/insights/tests/parsers/test_pci_rport_target_disk_paths.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import pci_rport_target_disk_paths from insights.parsers.pci_rport_target_disk_paths import PciRportTargetDiskPaths as PCIPaths from insights.tests import context_wrap @@ -65,7 +65,7 @@ def test_status_exp(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: PCIPaths(context_wrap('')) assert "Input content is empty" in str(sc1) diff --git a/insights/tests/parsers/test_pcs_quorum_status.py b/insights/tests/parsers/test_pcs_quorum_status.py index d80212dd11..e445aee5e3 100644 --- a/insights/tests/parsers/test_pcs_quorum_status.py +++ b/insights/tests/parsers/test_pcs_quorum_status.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import pcs_quorum_status from insights.parsers.pcs_quorum_status import PcsQuorumStatus from insights.tests import context_wrap @@ -79,7 +79,7 @@ def test_invalid(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: PcsQuorumStatus(context_wrap(PCS_QUORUM_STATUS_EMPTY)) assert "Empty content" in str(e) diff --git a/insights/tests/parsers/test_php_ini.py b/insights/tests/parsers/test_php_ini.py index dc829e1df2..ff6a583218 100644 --- a/insights/tests/parsers/test_php_ini.py +++ b/insights/tests/parsers/test_php_ini.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers.php_ini import PHPConf from insights.tests import context_wrap @@ -202,7 +202,7 @@ def test_php_conf_default(): def test_php_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PHPConf(context_wrap(INI_EMPTY)) diff --git a/insights/tests/parsers/test_pmrep.py b/insights/tests/parsers/test_pmrep.py index 4c1357b430..7a98b91188 100644 --- a/insights/tests/parsers/test_pmrep.py +++ b/insights/tests/parsers/test_pmrep.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import pmrep from insights.parsers.pmrep import PMREPMetrics from insights.tests import context_wrap @@ -52,13 +52,13 @@ def test_pmrep_info(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: PMREPMetrics(context_wrap(PMREPMETRIC_EMPTY_DATA)) assert 'There is no data in the table' in str(e) def test_wrong_data(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: PMREPMetrics(context_wrap(PMREPMETRIC_WRONG_DATA)) assert 'There is no data in the table' in str(e) diff --git a/insights/tests/parsers/test_podman_inspect.py b/insights/tests/parsers/test_podman_inspect.py index e394b666e2..bb7793b706 100644 --- a/insights/tests/parsers/test_podman_inspect.py +++ b/insights/tests/parsers/test_podman_inspect.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import podman_inspect from insights.tests import context_wrap @@ -454,7 +454,7 @@ def test_podman_object_image_inspect(): def test_podman_container_inspect_truncated_input(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): podman_inspect.PodmanInspectContainer(context_wrap(PODMAN_CONTAINER_INSPECT_TRUNCATED)) diff --git a/insights/tests/parsers/test_podman_list.py b/insights/tests/parsers/test_podman_list.py index 9b03811e78..004dcbd70c 100644 --- a/insights/tests/parsers/test_podman_list.py +++ b/insights/tests/parsers/test_podman_list.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import podman_list from insights.tests import context_wrap @@ -70,7 +70,7 @@ def test_podman_list_containers(): def test_podman_list_images_no_data(): - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: podman_list.PodmanListImages(context_wrap(PODMAN_LIST_IMAGES_NO_DATA)) assert 'No data.' in str(ex) diff --git a/insights/tests/parsers/test_postconf.py b/insights/tests/parsers/test_postconf.py index d7dfc19acc..c0689f5b01 100644 --- a/insights/tests/parsers/test_postconf.py +++ b/insights/tests/parsers/test_postconf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, SkipException +from insights.core.exceptions import ContentException, SkipComponent from insights.parsers import postconf from insights.parsers.postconf import PostconfBuiltin, Postconf, _Postconf from insights.tests import context_wrap @@ -22,7 +22,7 @@ def test_PostconfBuiltin(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PostconfBuiltin(context_wrap(V_OUT1)) with pytest.raises(ContentException): @@ -36,7 +36,7 @@ def test_PostconfBuiltin(): def test_Postconf(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Postconf(context_wrap(V_OUT1)) with pytest.raises(ContentException): @@ -50,16 +50,16 @@ def test_Postconf(): def test_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PostconfBuiltin(context_wrap("")) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Postconf(context_wrap("")) def test_invalid(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): PostconfBuiltin(context_wrap("asdf")) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Postconf(context_wrap("asdf")) diff --git a/insights/tests/parsers/test_proc_environ.py b/insights/tests/parsers/test_proc_environ.py index 161e5e556e..48455f1995 100644 --- a/insights/tests/parsers/test_proc_environ.py +++ b/insights/tests/parsers/test_proc_environ.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import proc_environ from insights.parsers.proc_environ import ProcEnviron, OpenshiftFluentdEnviron, OpenshiftRouterEnviron from insights.tests import context_wrap @@ -39,7 +39,7 @@ def test_invalid(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: ProcEnviron(context_wrap(PROC_ENVIRON_EMPTY)) assert "Empty output." in str(e) diff --git a/insights/tests/parsers/test_proc_keys.py b/insights/tests/parsers/test_proc_keys.py index 3915178d2e..39c6852958 100644 --- a/insights/tests/parsers/test_proc_keys.py +++ b/insights/tests/parsers/test_proc_keys.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import proc_keys from insights.parsers.proc_keys import ProcKeys from insights.tests import context_wrap @@ -43,11 +43,11 @@ def test_etc_systemd(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: ProcKeys(context_wrap(PROC_KEYS_EMPTY)) assert 'No Contents' in str(e) - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: ProcKeys(context_wrap(PROC_KEYS_INVALID)) assert "Invalid Contents: unknow_case" in str(e) diff --git a/insights/tests/parsers/test_puppet_ca_cert_expire_date.py b/insights/tests/parsers/test_puppet_ca_cert_expire_date.py index d8507240c7..11a73c30e1 100644 --- a/insights/tests/parsers/test_puppet_ca_cert_expire_date.py +++ b/insights/tests/parsers/test_puppet_ca_cert_expire_date.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import puppet_ca_cert_expire_date from insights.tests import context_wrap @@ -52,5 +52,5 @@ def test_wrong_output(): puppet_ca_cert_expire_date.PuppetCertExpireDate(context_wrap(WRONG_PUPPET_CERT_INFO_3)) with pytest.raises(ParseException): puppet_ca_cert_expire_date.PuppetCertExpireDate(context_wrap(WRONG_PUPPET_CERT_INFO_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): puppet_ca_cert_expire_date.PuppetCertExpireDate(context_wrap(WRONG_PUPPET_CERT_INFO_4)) diff --git a/insights/tests/parsers/test_rdma_config.py b/insights/tests/parsers/test_rdma_config.py index 0ee411a4fa..d466ade831 100644 --- a/insights/tests/parsers/test_rdma_config.py +++ b/insights/tests/parsers/test_rdma_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import rdma_config as scc from insights.tests import context_wrap @@ -70,7 +70,7 @@ def test_rdma_config(): def test_rdma_config_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): scc.RdmaConfig(context_wrap(RDMA_CONFIG_INPUT_EMPTY)) diff --git a/insights/tests/parsers/test_readlink_mtab.py b/insights/tests/parsers/test_readlink_mtab.py index 15a41aa2c7..e8b40fcbee 100644 --- a/insights/tests/parsers/test_readlink_mtab.py +++ b/insights/tests/parsers/test_readlink_mtab.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import readlink_e_mtab from insights.tests import context_wrap @@ -28,6 +28,6 @@ def test_readlink_e_mtab(): def test_fail(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: readlink_e_mtab.ReadLinkEMtab(context_wrap(BAD_FILE_PATH)) assert "No Data from command: readlink -e /etc/mtab" in str(e) diff --git a/insights/tests/parsers/test_readlink_openshift_certs.py b/insights/tests/parsers/test_readlink_openshift_certs.py index 1736892baa..f0549d634e 100644 --- a/insights/tests/parsers/test_readlink_openshift_certs.py +++ b/insights/tests/parsers/test_readlink_openshift_certs.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import readlink_openshift_certs from insights.tests import context_wrap @@ -38,10 +38,10 @@ def test_readlink_openshift_certs(): def test_fail(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: readlink_openshift_certs.ReadLinkEKubeletClientCurrent(context_wrap(BAD_FILE_PATH)) assert "No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-client-current.pem" in str(e) - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: readlink_openshift_certs.ReadLinkEKubeletServerCurrent(context_wrap(BAD_FILE_PATH)) assert "No Data from command: /usr/bin/readlink -e /etc/origin/node/certificates/kubelet-server-current.pem" in str(e) diff --git a/insights/tests/parsers/test_rhev_data_center.py b/insights/tests/parsers/test_rhev_data_center.py index 1befa07c96..a37c629d98 100644 --- a/insights/tests/parsers/test_rhev_data_center.py +++ b/insights/tests/parsers/test_rhev_data_center.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import rhev_data_center as ls_dc from insights.tests import context_wrap @@ -21,7 +21,7 @@ def test_rhev_data_center(): def test_no_data(): - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: ls_dc.RhevDataCenter(context_wrap('')) assert 'No files found with incorrect ownership.' in str(ex) diff --git a/insights/tests/parsers/test_rhsm_releasever.py b/insights/tests/parsers/test_rhsm_releasever.py index 64052f90d8..86e1946d48 100644 --- a/insights/tests/parsers/test_rhsm_releasever.py +++ b/insights/tests/parsers/test_rhsm_releasever.py @@ -1,11 +1,11 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import rhsm_releasever as rhsm_releasever_module from insights.parsers.rhsm_releasever import RhsmReleaseVer from insights.tests import context_wrap -from insights.tests.parsers import skip_exception_check +from insights.tests.parsers import skip_component_check RHEL_MAJ_MIN = '{"releaseVer": "6.10"}' RHEL_MAJ_1 = '{"releaseVer": "7Server"}' @@ -46,13 +46,13 @@ def test_rhsm_releasever(): assert relver.major is None assert relver.minor is None - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: RhsmReleaseVer(context_wrap(RHEL_EMPTY)) assert "releaseVer is not in data" in str(e_info.value) def test_empty(): - assert 'Empty output.' in skip_exception_check(RhsmReleaseVer) + assert 'Empty output.' in skip_component_check(RhsmReleaseVer) def test_doc_examples(): diff --git a/insights/tests/parsers/test_rhv_log_collector_analyzer.py b/insights/tests/parsers/test_rhv_log_collector_analyzer.py index 6fbf20103f..b7670fd425 100644 --- a/insights/tests/parsers/test_rhv_log_collector_analyzer.py +++ b/insights/tests/parsers/test_rhv_log_collector_analyzer.py @@ -1,6 +1,6 @@ from insights.parsers.rhv_log_collector_analyzer import RhvLogCollectorJson -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check RHV_ANALYZER_JSON = """ { @@ -139,4 +139,4 @@ def test_rhv_log_collector_json(self): assert result['rhv-log-collector-analyzer'][0]['file'] == 'cluster_query_migration_policy_check_legacy.sql' def test_empty(self): - assert 'Empty output.' in skip_exception_check(RhvLogCollectorJson) + assert 'Empty output.' in skip_component_check(RhvLogCollectorJson) diff --git a/insights/tests/parsers/test_rndc_status.py b/insights/tests/parsers/test_rndc_status.py index 9cab29a945..80af2fda80 100644 --- a/insights/tests/parsers/test_rndc_status.py +++ b/insights/tests/parsers/test_rndc_status.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import rndc_status from insights.parsers.rndc_status import RndcStatus from insights.tests import context_wrap @@ -49,7 +49,7 @@ def test_invalid(): def test_empty(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: RndcStatus(context_wrap(RNDC_STATUS_EMPTY)) assert "Empty content" in str(e) diff --git a/insights/tests/parsers/test_sap_hana_python_script.py b/insights/tests/parsers/test_sap_hana_python_script.py index ff1d315816..a104c7614a 100644 --- a/insights/tests/parsers/test_sap_hana_python_script.py +++ b/insights/tests/parsers/test_sap_hana_python_script.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sap_hana_python_script from insights.parsers.sap_hana_python_script import HanaLandscape from insights.tests import context_wrap @@ -50,7 +50,7 @@ def test_doc_examples(): def test_HanaLandscape_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): HanaLandscape(context_wrap(LANDSCAPE_SCALE_UP_AB_1)) diff --git a/insights/tests/parsers/test_sap_hdb_version.py b/insights/tests/parsers/test_sap_hdb_version.py index 03e74ec759..8a55c6c9ce 100644 --- a/insights/tests/parsers/test_sap_hdb_version.py +++ b/insights/tests/parsers/test_sap_hdb_version.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sap_hdb_version from insights.parsers.sap_hdb_version import HDBVersion from insights.tests import context_wrap @@ -59,11 +59,11 @@ def test_HDBVersion_doc(): def test_HDBVersion_ng(): - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: HDBVersion(context_wrap(HDB_VER_NG_1)) assert "Incorrect content." in str(e_info.value) - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: HDBVersion(context_wrap(HDB_VER_NG_2)) assert "Incorrect HDB version: 2.00.020.1500920972" in str(e_info.value) diff --git a/insights/tests/parsers/test_sap_host_profile.py b/insights/tests/parsers/test_sap_host_profile.py index 2f45506ec7..fe86be9d7b 100644 --- a/insights/tests/parsers/test_sap_host_profile.py +++ b/insights/tests/parsers/test_sap_host_profile.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sap_host_profile from insights.parsers.sap_host_profile import SAPHostProfile from insights.tests import context_wrap @@ -37,7 +37,7 @@ def test_sap_host_profile(): def test_sap_host_profile_abnormal(): - with pytest.raises(SkipException) as s: + with pytest.raises(SkipComponent) as s: SAPHostProfile(context_wrap(HOST_PROFILE_AB)) assert "Incorrect line: 'DIR_GLOBAL'" in str(s) diff --git a/insights/tests/parsers/test_sapcontrol.py b/insights/tests/parsers/test_sapcontrol.py index 00b117ff7c..1441b3b44a 100644 --- a/insights/tests/parsers/test_sapcontrol.py +++ b/insights/tests/parsers/test_sapcontrol.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import sapcontrol from insights.parsers.sapcontrol import SAPControlSystemUpdateList from insights.tests import context_wrap @@ -34,11 +34,11 @@ def test_sapcontrol_rks_abnormal(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SAPControlSystemUpdateList(context_wrap(RKS_STATUS_AB1)) with pytest.raises(ParseException): SAPControlSystemUpdateList(context_wrap(RKS_STATUS_AB2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SAPControlSystemUpdateList(context_wrap(RKS_STATUS_AB3)) diff --git a/insights/tests/parsers/test_saphostctrl.py b/insights/tests/parsers/test_saphostctrl.py index f37026604d..e8fec782fb 100644 --- a/insights/tests/parsers/test_saphostctrl.py +++ b/insights/tests/parsers/test_saphostctrl.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import saphostctrl from insights.parsers.saphostctrl import SAPHostCtrlInstances from insights.tests import context_wrap @@ -189,7 +189,7 @@ def test_saphostctrl_old(): def test_saphostctrl_bad(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SAPHostCtrlInstances(context_wrap('')) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_saphostexec.py b/insights/tests/parsers/test_saphostexec.py index 870afa8fd6..5acc61a180 100644 --- a/insights/tests/parsers/test_saphostexec.py +++ b/insights/tests/parsers/test_saphostexec.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import saphostexec from insights.parsers.saphostexec import SAPHostExecStatus, SAPHostExecVersion from insights.tests import context_wrap @@ -56,7 +56,7 @@ def test_saphostexec_status_abnormal(): SAPHostExecStatus(context_wrap(STATUS_ABNORMAL)) assert "Incorrect line: 'sapstartsrv'" in str(s) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SAPHostExecStatus(context_wrap('')) @@ -73,7 +73,7 @@ def test_saphostexec_status(): def test_saphostexec_version_abnormal(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SAPHostExecVersion(context_wrap('')) diff --git a/insights/tests/parsers/test_sat5_insights_properties.py b/insights/tests/parsers/test_sat5_insights_properties.py index 6bf69d83b7..62d61bbdab 100644 --- a/insights/tests/parsers/test_sat5_insights_properties.py +++ b/insights/tests/parsers/test_sat5_insights_properties.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sat5_insights_properties from insights.parsers.sat5_insights_properties import Sat5InsightsProperties from insights.tests import context_wrap @@ -32,5 +32,5 @@ def test_doc(): def test_AB(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Sat5InsightsProperties(context_wrap('')) diff --git a/insights/tests/parsers/test_satellite_content_hosts_count.py b/insights/tests/parsers/test_satellite_content_hosts_count.py index 43043bd46f..c54bd5bb91 100644 --- a/insights/tests/parsers/test_satellite_content_hosts_count.py +++ b/insights/tests/parsers/test_satellite_content_hosts_count.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import satellite_content_hosts_count from insights.tests import context_wrap @@ -47,9 +47,9 @@ def test_HTL_doc_examples(): def test_wrong_output(): with pytest.raises(ContentException): satellite_content_hosts_count.SatelliteContentHostsCount(context_wrap(SATELLITE_CONTENT_HOSTS_COUNT_WRONG_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_content_hosts_count.SatelliteContentHostsCount(context_wrap(SATELLITE_CONTENT_HOSTS_COUNT_WRONG_2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_content_hosts_count.SatelliteContentHostsCount(context_wrap(SATELLITE_CONTENT_HOSTS_COUNT_WRONG_3)) with pytest.raises(ParseException): satellite_content_hosts_count.SatelliteContentHostsCount(context_wrap(SATELLITE_CONTENT_HOSTS_COUNT_WRONG_4)) diff --git a/insights/tests/parsers/test_satellite_enabled_features.py b/insights/tests/parsers/test_satellite_enabled_features.py index ffe01a84db..556f8191ff 100644 --- a/insights/tests/parsers/test_satellite_enabled_features.py +++ b/insights/tests/parsers/test_satellite_enabled_features.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import satellite_enabled_features from insights.tests import context_wrap @@ -30,5 +30,5 @@ def test_features_on_satellite(): def test_empty_features(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_enabled_features.SatelliteEnabledFeatures(context_wrap(empty_enabled_features)) diff --git a/insights/tests/parsers/test_satellite_mongodb.py b/insights/tests/parsers/test_satellite_mongodb.py index ddbf01999d..56060a88b3 100644 --- a/insights/tests/parsers/test_satellite_mongodb.py +++ b/insights/tests/parsers/test_satellite_mongodb.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import satellite_mongodb from insights.tests import context_wrap @@ -81,16 +81,16 @@ def test_satellite(): def test_no_storage_engine(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_mongodb.MongoDBStorageEngine(context_wrap(MONGO_PULP_STORAGE_ENGINE_OUTPUT2)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_mongodb.MongoDBStorageEngine(context_wrap(MONGO_PULP_STORAGE_ENGINE_OUTPUT3)) with pytest.raises(ParseException): satellite_mongodb.MongoDBStorageEngine(context_wrap(MONGO_PULP_STORAGE_ENGINE_OUTPUT4)) def test_bad_yum_repos_output(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_mongodb.MongoDBNonYumTypeRepos(context_wrap(MONGO_PULP_NON_YUM_TYPE_REPOS_OUTPUT1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_mongodb.MongoDBNonYumTypeRepos(context_wrap(MONGO_PULP_NON_YUM_TYPE_REPOS_OUTPUT3)) diff --git a/insights/tests/parsers/test_satellite_postgresql_query.py b/insights/tests/parsers/test_satellite_postgresql_query.py index d1d70ce5cb..896b0d94ec 100644 --- a/insights/tests/parsers/test_satellite_postgresql_query.py +++ b/insights/tests/parsers/test_satellite_postgresql_query.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import satellite_postgresql_query from insights.tests import context_wrap @@ -244,7 +244,7 @@ def test_basic_output_with_satellite_admin_setting(): satellite_postgresql_query.SatelliteAdminSettings(context_wrap(SATELLITE_POSTGRESQL_WRONG_3)) with pytest.raises(ValueError): satellite_postgresql_query.SatelliteAdminSettings(context_wrap(SATELLITE_POSTGRESQL_WRONG_4)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_postgresql_query.SatelliteAdminSettings(context_wrap(SATELLITE_POSTGRESQL_WRONG_5)) @@ -304,7 +304,7 @@ def test_satellite_katello_empty_url_repositories(): assert table[0]['id'] == '1' assert table[0]['name'] == 'Puppet_Base' - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_postgresql_query.SatelliteKatelloEmptyURLRepositories(context_wrap(SATELLITE_QUERY_DATA2)) with pytest.raises(ValueError): @@ -321,7 +321,7 @@ def test_satellite_qulified_capsules(): assert len(capsules) == 2 assert capsules[0]['name'] == 'capsule1.test.com' - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_postgresql_query.SatelliteQualifiedCapsules(context_wrap(SATELLITE_CAPSULES_WITH_BACKGROUND_DOWNLOADPOLICY_2)) @@ -347,7 +347,7 @@ def test_satellite_provision_params(): def test_satellite_provision_params_excep(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): satellite_postgresql_query.SatelliteProvisionParamSettings(context_wrap(SATELLITE_PROVISION_PARAMETERS_HIT_2)) diff --git a/insights/tests/parsers/test_sctp.py b/insights/tests/parsers/test_sctp.py index 298eaecac2..bf2534b07b 100644 --- a/insights/tests/parsers/test_sctp.py +++ b/insights/tests/parsers/test_sctp.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import sctp from insights.parsers.sctp import SCTPAsc, SCTPAsc7, SCTPEps, SCTPSnmp from insights.tests import context_wrap @@ -151,7 +151,7 @@ def test_sctp_eps_exceptions(): assert sctp_obj is None # Just added to remove flake8 warnings assert 'The following line is not compatible with this parser' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: sctp_obj = SCTPEps(context_wrap(SCTP_EPS_DETAILS_NO_2)) assert sctp_obj is None # Just added to remove flake8 warnings assert 'No Contents' in str(exc) @@ -162,7 +162,7 @@ def test_sctp_asc_exceptions(): sctp_asc = SCTPAsc(context_wrap(SCTP_ASSOC_NO_2)) assert sctp_asc is None assert 'The following line is not compatible with this parser' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: sctp_asc = SCTPAsc(context_wrap(SCTP_ASSOC_NO)) assert sctp_asc is None assert 'No Contents' in str(exc) @@ -190,7 +190,7 @@ def test_sctp_snmp(): def test_sctp_snmp_exceptions(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: sctp_snmp = SCTPSnmp(context_wrap(SCTP_SNMP_NO_1)) assert sctp_snmp is None diff --git a/insights/tests/parsers/test_setup_named_chroot.py b/insights/tests/parsers/test_setup_named_chroot.py index af8c011546..4bb2db9e61 100644 --- a/insights/tests/parsers/test_setup_named_chroot.py +++ b/insights/tests/parsers/test_setup_named_chroot.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import setup_named_chroot from insights.parsers.setup_named_chroot import SetupNamedChroot from insights.tests import context_wrap @@ -147,12 +147,12 @@ def test_doc_examples(): def test_setup_named_chroot_exception1(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: SetupNamedChroot(context_wrap(EXCEPTION1)) assert "Empty file" in str(e) def test_setup_named_chroot_exception2(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: SetupNamedChroot(context_wrap(EXCEPTION2)) assert "Input content is not empty but there is no useful parsed data." in str(e) diff --git a/insights/tests/parsers/test_slabinfo.py b/insights/tests/parsers/test_slabinfo.py index d64f1cf168..0c60c410b5 100644 --- a/insights/tests/parsers/test_slabinfo.py +++ b/insights/tests/parsers/test_slabinfo.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import slabinfo from insights.parsers.slabinfo import SlabInfo from insights.tests import context_wrap @@ -183,22 +183,22 @@ def test_slabinfo_doc_examples(): def test_slabinfo_exception(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: pslabinfo = SlabInfo(context_wrap(SLABINFO_DETAILS)) assert pslabinfo is None assert 'No Contents' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: pslabinfo_1 = SlabInfo(context_wrap(SLABINFO_DETAILS_2)) assert pslabinfo_1 is None assert 'Invalid Contents' in str(exc) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: pslabinfo_2 = SlabInfo(context_wrap(SLABINFO_DETAILS_3)) assert pslabinfo_2 is None assert 'Invalid Contents' in str(exc) - with pytest.raises(SkipException) as exc_1: + with pytest.raises(SkipComponent) as exc_1: pslabinfo_3 = SlabInfo(context_wrap(SLABINFO_DETAILS_LEN_MISS_MATCH)) assert pslabinfo_3 is None assert 'Invalid Contents' in str(exc_1) diff --git a/insights/tests/parsers/test_smbstatus.py b/insights/tests/parsers/test_smbstatus.py index 1c09a06867..2b6bf99885 100644 --- a/insights/tests/parsers/test_smbstatus.py +++ b/insights/tests/parsers/test_smbstatus.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import smbstatus from insights.parsers.smbstatus import SmbstatusS, Smbstatusp, Statuslist from insights.tests import context_wrap @@ -78,7 +78,7 @@ def test_smbstatusp(): def test_statuslist_empty_exp(): - with pytest.raises(SkipException) as pe: + with pytest.raises(SkipComponent) as pe: Statuslist(context_wrap('')) assert "Empty content." in str(pe) @@ -100,7 +100,7 @@ def test_smbstatusp_exp(): Smbstatusp(context_wrap(SMBSTATUSP_EXP1)) assert "Cannot find the header line." in str(pe) - with pytest.raises(SkipException) as pe: + with pytest.raises(SkipComponent) as pe: Smbstatusp(context_wrap(SMBSTATUSP_EXP2)) assert "Empty content." in str(pe) diff --git a/insights/tests/parsers/test_smt.py b/insights/tests/parsers/test_smt.py index 4b58d32961..dc82e1871a 100644 --- a/insights/tests/parsers/test_smt.py +++ b/insights/tests/parsers/test_smt.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import smt from insights.parsers.smt import CpuSMTActive, CpuSMTControl, CpuCoreOnline, CpuSiblings from insights.tests import context_wrap @@ -63,7 +63,7 @@ def test_cpu_siblings(setting, core_id, siblings): CpuSiblings ]) def test_exceptions(parser): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): parser(context_wrap("")) diff --git a/insights/tests/parsers/test_sockstat.py b/insights/tests/parsers/test_sockstat.py index 521033a464..0153aa64d9 100644 --- a/insights/tests/parsers/test_sockstat.py +++ b/insights/tests/parsers/test_sockstat.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sockstat from insights.parsers.sockstat import SockStats from insights.tests import context_wrap @@ -43,7 +43,7 @@ def test_sockstat(): assert stats.seg_element_details(None, None) is None assert stats.seg_element_details('tcp', 'abc') is None assert len(stats.sock_stats) - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: sock_obj = SockStats(context_wrap(SOCK_STATS_NO)) assert sock_obj is not None assert 'No Contents' in str(exc) diff --git a/insights/tests/parsers/test_ssh_client_config.py b/insights/tests/parsers/test_ssh_client_config.py index 8e908d2f6e..840e525d8b 100644 --- a/insights/tests/parsers/test_ssh_client_config.py +++ b/insights/tests/parsers/test_ssh_client_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import ssh_client_config as scc from insights.tests import context_wrap @@ -82,7 +82,7 @@ def test_ssh_client_config(): def test_ssh_config_AB(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): scc.ForemanProxySshConfig(context_wrap(SSH_CONFIG_INPUT_EMPTY)) diff --git a/insights/tests/parsers/test_ssl_certificate.py b/insights/tests/parsers/test_ssl_certificate.py index 322115fa07..a3a1787aa9 100644 --- a/insights/tests/parsers/test_ssl_certificate.py +++ b/insights/tests/parsers/test_ssl_certificate.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, ParseException, SkipComponent, SkipException +from insights.core.exceptions import ContentException, ParseException, SkipComponent from insights.parsers import ssl_certificate from insights.tests import context_wrap @@ -106,12 +106,12 @@ def test_certificate_info_exception(): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT2)) with pytest.raises(ContentException): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT3)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT4)) def test_certificate_chain_exception(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ssl_certificate.CertificateChain(context_wrap(BAD_OUTPUT4)) diff --git a/insights/tests/parsers/test_subscription_manager.py b/insights/tests/parsers/test_subscription_manager.py index d37f81b6d7..8faeb0f945 100644 --- a/insights/tests/parsers/test_subscription_manager.py +++ b/insights/tests/parsers/test_subscription_manager.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import subscription_manager from insights.parsers.subscription_manager import SubscriptionManagerFacts from insights.tests import context_wrap @@ -34,7 +34,7 @@ def test_subscription_manager_release_show_ng(): with pytest.raises(ParseException): SubscriptionManagerFacts(context_wrap(INPUT_NG_1)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SubscriptionManagerFacts(context_wrap(INPUT_NG_2)) diff --git a/insights/tests/parsers/test_subscription_manager_release.py b/insights/tests/parsers/test_subscription_manager_release.py index d334b287a1..6dba02c8ea 100644 --- a/insights/tests/parsers/test_subscription_manager_release.py +++ b/insights/tests/parsers/test_subscription_manager_release.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import subscription_manager_release from insights.parsers.subscription_manager_release import SubscriptionManagerReleaseShow from insights.tests import context_wrap @@ -65,19 +65,19 @@ def test_subscription_manager_release_show_not_set(): def test_subscription_manager_release_show_ng(): - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: SubscriptionManagerReleaseShow(context_wrap(INPUT_NG_1)) assert "Content takes at most 1 line (2 given)." in str(e_info.value) - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: SubscriptionManagerReleaseShow(context_wrap(INPUT_NG_2)) assert "Incorrect content: Release: 7.x" in str(e_info.value) - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: SubscriptionManagerReleaseShow(context_wrap(INPUT_NG_3)) assert "Incorrect content: Release: 7.x DUMMY" in str(e_info.value) - with pytest.raises(SkipException) as e_info: + with pytest.raises(SkipComponent) as e_info: SubscriptionManagerReleaseShow(context_wrap(INPUT_NG_4)) assert "Incorrect content: Release: 7x" in str(e_info.value) diff --git a/insights/tests/parsers/test_sudoers.py b/insights/tests/parsers/test_sudoers.py index 299ab4b81a..30bb1922d0 100644 --- a/insights/tests/parsers/test_sudoers.py +++ b/insights/tests/parsers/test_sudoers.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sudoers from insights.parsers.sudoers import EtcSudoers from insights.tests import context_wrap @@ -26,7 +26,7 @@ def test_etc_sudoers(): def test_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): EtcSudoers(context_wrap(SUDOERS_EMPTY)) sudo = EtcSudoers(context_wrap(SUDOERS)) diff --git a/insights/tests/parsers/test_sys_module.py b/insights/tests/parsers/test_sys_module.py index 264fa315e8..fe63391dd6 100644 --- a/insights/tests/parsers/test_sys_module.py +++ b/insights/tests/parsers/test_sys_module.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sys_module from insights.parsers.sys_module import (DMModUseBlkMq, KernelCrashKexecPostNotifiers, LpfcMaxLUNs, MaxLUNs, Ql2xMaxLUN, Ql2xmqSupport, SCSIModMaxReportLUNs, SCSIModUseBlkMq, VHostNetZeroCopyTx) @@ -103,7 +103,7 @@ def test_MaxLUNs(): def test_class_exceptions(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): dm_mod = DMModUseBlkMq(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_EMPTY)) assert dm_mod is None @@ -112,7 +112,7 @@ def test_class_exceptions(): dm_mod_unknow.is_on assert "Unexpected value unknow_case, please get raw data from attribute 'val' and tell is_on by yourself." in str(e) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): max_luns = MaxLUNs(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_EMPTY)) assert max_luns is None @@ -121,7 +121,7 @@ def test_class_exceptions(): max_luns_not_digit.val assert "Unexpected content: unknow_case" in str(e) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ql2xmqsuppor_empty = Ql2xmqSupport(context_wrap(SCSI_DM_MOD_USE_BLK_MQ_EMPTY)) assert ql2xmqsuppor_empty is None diff --git a/insights/tests/parsers/test_sys_vmbus.py b/insights/tests/parsers/test_sys_vmbus.py index 5865de1d51..3e45aba2b7 100644 --- a/insights/tests/parsers/test_sys_vmbus.py +++ b/insights/tests/parsers/test_sys_vmbus.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import sys_vmbus from insights.tests import context_wrap @@ -55,11 +55,11 @@ def test_class_id(): def test_blank_output(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): output = sys_vmbus.SysVmbusDeviceID(context_wrap(BLANK, path='/sys/bus/vmbus/devices/47505500-0001-0000-3130-444531444234/device_id')) assert output is None - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): output = sys_vmbus.SysVmbusClassID(context_wrap(BLANK, path='/sys/bus/vmbus/devices/47505500-0001-0000-3130-444531444234/class_id')) assert output is None diff --git a/insights/tests/parsers/test_systemctl_show.py b/insights/tests/parsers/test_systemctl_show.py index 1e021aed34..f07fbd906c 100644 --- a/insights/tests/parsers/test_systemctl_show.py +++ b/insights/tests/parsers/test_systemctl_show.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import systemctl_show from insights.parsers.systemctl_show import ( SystemctlShowServiceAll, SystemctlShowTarget, SystemctlShowAllServiceWithLimitedProperties @@ -340,7 +340,7 @@ def test_systemctl_show_target(): def test_systemctl_show_service_all_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): SystemctlShowServiceAll(context_wrap('')) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_systemd_analyze.py b/insights/tests/parsers/test_systemd_analyze.py index 13a2e1ced5..340ece1ac9 100644 --- a/insights/tests/parsers/test_systemd_analyze.py +++ b/insights/tests/parsers/test_systemd_analyze.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import systemd_analyze from insights.tests import context_wrap @@ -36,7 +36,7 @@ def test_output(): assert output.get('dev-sdd.device', 0) == 291450.859 assert output.get('dev-sdy.device', 0) == 35921033.782 - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert systemd_analyze.SystemdAnalyzeBlame(context_wrap("")) is None diff --git a/insights/tests/parsers/test_systemd_config.py b/insights/tests/parsers/test_systemd_config.py index 4932ca33d0..2b158f8a21 100644 --- a/insights/tests/parsers/test_systemd_config.py +++ b/insights/tests/parsers/test_systemd_config.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ContentException, SkipException +from insights.core.exceptions import ContentException, SkipComponent from insights.parsers.systemd import config from insights.tests import context_wrap @@ -276,7 +276,7 @@ def test_systemd_dnsmasq_conf(): def test_systemd_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert config.SystemdLogindConf(context_wrap('')) is None diff --git a/insights/tests/parsers/test_tags.py b/insights/tests/parsers/test_tags.py index a205e6d522..5a4d9bf9d6 100644 --- a/insights/tests/parsers/test_tags.py +++ b/insights/tests/parsers/test_tags.py @@ -1,6 +1,6 @@ from insights.parsers.tags import Tags -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check tags_json_content = """ {"zone": "east", "owner": "test", "exclude": "true", "group": "app-db-01"} @@ -29,4 +29,4 @@ def test_tags_json_bytes(): def test_tags_empty(): - assert 'Empty output.' in skip_exception_check(Tags) + assert 'Empty output.' in skip_component_check(Tags) diff --git a/insights/tests/parsers/test_teamdctl_config_dump.py b/insights/tests/parsers/test_teamdctl_config_dump.py index 676e8817cf..facddbeda6 100644 --- a/insights/tests/parsers/test_teamdctl_config_dump.py +++ b/insights/tests/parsers/test_teamdctl_config_dump.py @@ -2,8 +2,8 @@ from insights.parsers import teamdctl_config_dump from insights.parsers.teamdctl_config_dump import TeamdctlConfigDump -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check TEAMDCTL_CONFIG_DUMP_INFO = """ { @@ -41,7 +41,7 @@ def test_teamdctl_state_dump(): def test_teamdctl_state_dump_empty(): - assert 'Empty output.' in skip_exception_check(TeamdctlConfigDump) + assert 'Empty output.' in skip_component_check(TeamdctlConfigDump) def test_nmcli_doc_examples(): diff --git a/insights/tests/parsers/test_teamdctl_state_dump.py b/insights/tests/parsers/test_teamdctl_state_dump.py index eb9e57684b..eec7e1668d 100644 --- a/insights/tests/parsers/test_teamdctl_state_dump.py +++ b/insights/tests/parsers/test_teamdctl_state_dump.py @@ -1,6 +1,6 @@ from insights.parsers.teamdctl_state_dump import TeamdctlStateDump -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check TEAMDCTL_STATE_DUMP_INFO = """ { @@ -114,4 +114,4 @@ def test_teamdctl_state_dump_none(): def test_teamdctl_state_dump_empty(): - assert 'Empty output.' in skip_exception_check(TeamdctlStateDump) + assert 'Empty output.' in skip_component_check(TeamdctlStateDump) diff --git a/insights/tests/parsers/test_tomcat_virtual_dir_context.py b/insights/tests/parsers/test_tomcat_virtual_dir_context.py index 2f48d3e734..7adefe5806 100644 --- a/insights/tests/parsers/test_tomcat_virtual_dir_context.py +++ b/insights/tests/parsers/test_tomcat_virtual_dir_context.py @@ -1,6 +1,6 @@ import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.tomcat_virtual_dir_context import TomcatVirtualDirContextFallback, TomcatVirtualDirContextTargeted from insights.tests import context_wrap @@ -55,13 +55,13 @@ def test_tomcat_virtual_dir_context_found(): def test_tomcat_virtual_dir_context_not_found(): for parser in [TomcatVirtualDirContextFallback, TomcatVirtualDirContextTargeted]: - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: parser(context_wrap(NOT_FOUND)) assert 'VirtualDirContext not used.' in str(excinfo.value) def test_tomcat_virtual_dir_context_exceptions(): for parser in [TomcatVirtualDirContextFallback, TomcatVirtualDirContextTargeted]: - with pytest.raises(SkipException) as excinfo: + with pytest.raises(SkipComponent) as excinfo: parser(context_wrap(ERRORS_2)) assert 'VirtualDirContext not used.' in str(excinfo.value) diff --git a/insights/tests/parsers/test_tuned.py b/insights/tests/parsers/test_tuned.py index ef739240c8..2789b0b56d 100644 --- a/insights/tests/parsers/test_tuned.py +++ b/insights/tests/parsers/test_tuned.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import tuned from insights.parsers.tuned import Tuned from insights.tests import context_wrap @@ -94,7 +94,7 @@ def test_tuned_profile(): assert 'sap-netweaver' in tuned_output.get('available') assert 'virtual-guest-vmware' in tuned_output.get('available') - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): Tuned(context_wrap('')) diff --git a/insights/tests/parsers/test_unitfiles.py b/insights/tests/parsers/test_unitfiles.py index b75649d9de..989b48c1ec 100644 --- a/insights/tests/parsers/test_unitfiles.py +++ b/insights/tests/parsers/test_unitfiles.py @@ -3,7 +3,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers.systemd import unitfiles from insights.parsers.systemd.unitfiles import ListUnits, UnitFiles from insights.tests import context_wrap @@ -445,8 +445,8 @@ def test_unitfiles_doc_examples(): def test_unitfile_NG(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): UnitFiles(context_wrap(UNITFILES_NG)) - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): ListUnits(context_wrap(LISTUNITS_NG)) diff --git a/insights/tests/parsers/test_upstart.py b/insights/tests/parsers/test_upstart.py index 06a458d65c..825b6f997d 100644 --- a/insights/tests/parsers/test_upstart.py +++ b/insights/tests/parsers/test_upstart.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import upstart from insights.parsers.upstart import UpstartInitctlList from insights.tests import context_wrap @@ -68,7 +68,7 @@ def test_upstart(): def test_execp_upstart(): - with pytest.raises(SkipException) as exc: + with pytest.raises(SkipComponent) as exc: UpstartInitctlList(context_wrap('')) assert 'No Contents' in str(exc.value) diff --git a/insights/tests/parsers/test_user_group.py b/insights/tests/parsers/test_user_group.py index 74d8501016..9c7fcb2ae7 100644 --- a/insights/tests/parsers/test_user_group.py +++ b/insights/tests/parsers/test_user_group.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import user_group from insights.parsers.user_group import GroupInfo from insights.tests import context_wrap @@ -28,7 +28,7 @@ def test_grp(): def test_ab(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): GroupInfo(context_wrap(GRP_EMPTY)) with pytest.raises(ParseException): diff --git a/insights/tests/parsers/test_version_info.py b/insights/tests/parsers/test_version_info.py index 7a75b9c03f..5ef7dc4969 100644 --- a/insights/tests/parsers/test_version_info.py +++ b/insights/tests/parsers/test_version_info.py @@ -1,8 +1,8 @@ import doctest from insights.parsers import version_info -from insights.tests.parsers import skip_exception_check from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check VER_INFO_1 = """ @@ -25,7 +25,7 @@ def test_version_info(): def test_version_info_empty(): - assert 'Empty output.' in skip_exception_check(version_info.VersionInfo) + assert 'Empty output.' in skip_component_check(version_info.VersionInfo) def test_doc_examples(): diff --git a/insights/tests/parsers/test_virt_uuid_facts.py b/insights/tests/parsers/test_virt_uuid_facts.py index bd9fee6d6a..f5c7162020 100644 --- a/insights/tests/parsers/test_virt_uuid_facts.py +++ b/insights/tests/parsers/test_virt_uuid_facts.py @@ -1,9 +1,9 @@ import doctest from insights.parsers import virt_uuid_facts -from insights.tests.parsers import skip_exception_check from insights.parsers.virt_uuid_facts import VirtUuidFacts from insights.tests import context_wrap +from insights.tests.parsers import skip_component_check VIRT_UUID_FACTS = """ @@ -22,7 +22,7 @@ def test_virt_uuid_facts(): def test_virt_uuid_facts_empty(): - assert 'Empty output.' in skip_exception_check(VirtUuidFacts) + assert 'Empty output.' in skip_component_check(VirtUuidFacts) def test_virt_uuid_facts_doc_examples(): diff --git a/insights/tests/parsers/test_virt_who_conf.py b/insights/tests/parsers/test_virt_who_conf.py index c7a3d0fc87..7738743476 100644 --- a/insights/tests/parsers/test_virt_who_conf.py +++ b/insights/tests/parsers/test_virt_who_conf.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import virt_who_conf from insights.tests import context_wrap @@ -44,7 +44,7 @@ def test_doc_examples(): def test_virt_who_conf_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert virt_who_conf.VirtWhoConf(context_wrap('')) is None diff --git a/insights/tests/parsers/test_vma_ra_enabled_s390x.py b/insights/tests/parsers/test_vma_ra_enabled_s390x.py index 0a6dcce357..acf31f1ec5 100644 --- a/insights/tests/parsers/test_vma_ra_enabled_s390x.py +++ b/insights/tests/parsers/test_vma_ra_enabled_s390x.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import vma_ra_enabled_s390x from insights.parsers.vma_ra_enabled_s390x import VmaRaEnabledS390x from insights.tests import context_wrap @@ -26,7 +26,7 @@ def test_vma_ra_enabled_s390x_exp(): """ Here test the examples cause expections """ - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: VmaRaEnabledS390x(context_wrap('')) assert "Input content is empty" in str(sc1) diff --git a/insights/tests/parsers/test_x86_debug.py b/insights/tests/parsers/test_x86_debug.py index f97cccf545..d343ecdd94 100644 --- a/insights/tests/parsers/test_x86_debug.py +++ b/insights/tests/parsers/test_x86_debug.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import x86_debug from insights.parsers.x86_debug import X86IBPBEnabled, X86IBRSEnabled, X86PTIEnabled, X86RETPEnabled from insights.tests import context_wrap @@ -81,7 +81,7 @@ def test_x86_ibpb_enabled_exp(): Here test the examples cause expections """ # ibpb - with pytest.raises(SkipException) as sc1: + with pytest.raises(SkipComponent) as sc1: X86IBPBEnabled(context_wrap("")) assert "Input content is empty" in str(sc1) @@ -91,7 +91,7 @@ def test_x86_pti_enabled_exp(): Here test the examples cause expections """ # pti - with pytest.raises(SkipException) as sc2: + with pytest.raises(SkipComponent) as sc2: X86PTIEnabled(context_wrap("")) assert "Input content is empty" in str(sc2) @@ -101,7 +101,7 @@ def test_x86_ibrs_enabled_exp(): Here test the examples cause expections """ # ibrs - with pytest.raises(SkipException) as sc3: + with pytest.raises(SkipComponent) as sc3: X86IBRSEnabled(context_wrap("")) assert "Input content is empty" in str(sc3) @@ -111,6 +111,6 @@ def test_x86_retp_enabled_exp(): Here test the examples cause expections """ # retp - with pytest.raises(SkipException) as sc4: + with pytest.raises(SkipComponent) as sc4: X86RETPEnabled(context_wrap("")) assert "Input content is empty" in str(sc4) diff --git a/insights/tests/parsers/test_yum_repolist.py b/insights/tests/parsers/test_yum_repolist.py index 36c4cad24d..f6c5a82fb8 100644 --- a/insights/tests/parsers/test_yum_repolist.py +++ b/insights/tests/parsers/test_yum_repolist.py @@ -1,7 +1,7 @@ import doctest import pytest -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.parsers import yum from insights.parsers.yum import YumRepoList from insights.tests import context_wrap @@ -196,11 +196,11 @@ def test_rhel_repos_missing_status(): def test_rhel_repos_empty(): - with pytest.raises(SkipException) as se: + with pytest.raises(SkipComponent) as se: YumRepoList(context_wrap('')) assert 'No repolist.' in str(se) - with pytest.raises(SkipException) as se: + with pytest.raises(SkipComponent) as se: YumRepoList(context_wrap(YUM_REPOLIST_CONTENT_EMPTY)) assert 'No repolist.' in str(se) @@ -248,7 +248,7 @@ def test_repos_without_ends(): def test_repolist_zero(): - with pytest.raises(SkipException) as se: + with pytest.raises(SkipComponent) as se: YumRepoList(context_wrap(YUM_REPOLIST_ZERO)) assert 'No repolist.' in str(se) diff --git a/insights/tests/parsers/test_zdump_v.py b/insights/tests/parsers/test_zdump_v.py index 5646e5e684..86ce2e5eef 100644 --- a/insights/tests/parsers/test_zdump_v.py +++ b/insights/tests/parsers/test_zdump_v.py @@ -3,7 +3,7 @@ from datetime import datetime -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.parsers import zdump_v from insights.tests import context_wrap @@ -96,6 +96,6 @@ def test_zdump_v(): def test_fail(): - with pytest.raises(SkipException) as e: + with pytest.raises(SkipComponent) as e: zdump_v.ZdumpV(context_wrap(BAD_OUTPUT1)) assert "No Data from command: /usr/sbin/zdump -v /etc/localtime -c 2019,2039" in str(e) diff --git a/insights/tests/test_config_parser.py b/insights/tests/test_config_parser.py index 92431bd34a..ec3aee4d99 100644 --- a/insights/tests/test_config_parser.py +++ b/insights/tests/test_config_parser.py @@ -2,7 +2,7 @@ from insights.contrib.ConfigParser import NoOptionError from insights.core import ConfigParser, IniConfigFile -from insights.core.exceptions import SkipException +from insights.core.exceptions import SkipComponent from insights.tests import context_wrap # An example config file with a few tricks and traps for the parser @@ -99,8 +99,8 @@ def test_ini_config_file_parser(): def test_config_parser_empty(): - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert ConfigParser(context_wrap('')) is None - with pytest.raises(SkipException): + with pytest.raises(SkipComponent): assert IniConfigFile(context_wrap('')) is None diff --git a/insights/tests/test_yaml_parser.py b/insights/tests/test_yaml_parser.py index 9a77c3d559..a398d8ce74 100644 --- a/insights/tests/test_yaml_parser.py +++ b/insights/tests/test_yaml_parser.py @@ -2,7 +2,7 @@ import pytest from insights.core import YAMLParser -from insights.core.exceptions import ParseException, SkipException +from insights.core.exceptions import ParseException, SkipComponent from insights.tests import context_wrap @@ -71,7 +71,7 @@ def test_settings_yml_list(): def test_empty_content(): ctx = context_wrap(empty_yaml_content) - with pytest.raises(SkipException) as ex: + with pytest.raises(SkipComponent) as ex: FakeYamlParser(ctx) assert "There is no data" in ex.value.args[0] From 97b47dd95d77bdb5f1107a96858c7b9d4fd0e50b Mon Sep 17 00:00:00 2001 From: Xiangce Liu Date: Thu, 2 Feb 2023 08:50:22 +0800 Subject: [PATCH 10/14] feat: add CloudInstance to canonical_facts (#3654) * feat: add CloudInstance and OSRelease to canonical_facts Signed-off-by: Xiangce Liu * insert value only when match, and add tests * enable AWSInstanceIdDoc only * fix: provider_type should be cloud_instance.provider * make the new items must exist: None by default * fix the tests * remove is_rhel Signed-off-by: Xiangce Liu --- insights/tests/test_canonical_facts.py | 20 +++++++++-- insights/util/canonical_facts.py | 46 +++++++++++++++++++++----- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/insights/tests/test_canonical_facts.py b/insights/tests/test_canonical_facts.py index ad1bfc1e78..788b1bac2f 100644 --- a/insights/tests/test_canonical_facts.py +++ b/insights/tests/test_canonical_facts.py @@ -1,8 +1,14 @@ import uuid +from insights.combiners.cloud_instance import CloudInstance +from insights.combiners.cloud_provider import CloudProvider +from insights.parsers.aws_instance_id import AWSInstanceIdDoc +from insights.parsers.installed_rpms import InstalledRpms from insights.tests import context_wrap +from insights.tests.combiners.test_cloud_provider import RPMS_AWS +from insights.tests.parsers.test_aws_instance_id import AWS_ID_DOC from insights.util.canonical_facts import ( - _filter_falsy, _safe_parse, IPs, valid_ipv4_address_or_None, valid_mac_addresses, - valid_uuid_or_None) + _filter_falsy, _safe_parse, canonical_facts, IPs, valid_ipv4_address_or_None, + valid_mac_addresses, valid_uuid_or_None) def test_identity(): @@ -95,3 +101,13 @@ def test_safe_parse(): assert result is None result = _safe_parse(None) assert result is None + + +def test_canonical_facts_providers(): + rpms = InstalledRpms(context_wrap(RPMS_AWS)) + _id = AWSInstanceIdDoc(context_wrap(AWS_ID_DOC)) + cp = CloudProvider(rpms, None, None, None) + ci = CloudInstance(cp, _id, None, None, None, None) + ret = canonical_facts(None, None, None, None, None, None, None, ci) + assert ret.get('provider_id') == 'i-1234567890abcdef0' + assert ret.get('provider_type') == 'aws' diff --git a/insights/util/canonical_facts.py b/insights/util/canonical_facts.py index 6bf7dab6eb..e9c3f24f02 100644 --- a/insights/util/canonical_facts.py +++ b/insights/util/canonical_facts.py @@ -4,13 +4,23 @@ import re import socket +import uuid -from insights import rule, make_metadata, run -from insights.specs import Specs +from insights import rule, run, make_metadata +from insights.combiners.cloud_instance import CloudInstance +from insights.combiners.cloud_provider import CloudProvider from insights.core import Parser -from insights.core.plugins import parser from insights.core.dr import set_enabled, load_components -import uuid +from insights.core.plugins import parser +from insights.parsers.aws_instance_id import AWSInstanceIdDoc +from insights.parsers.azure_instance import AzureInstanceID, AzureInstanceType +from insights.parsers.dmidecode import DMIDecode +from insights.parsers.gcp_instance_type import GCPInstanceType +from insights.parsers.installed_rpms import InstalledRpms +from insights.parsers.rhsm_conf import RHSMConf +from insights.parsers.subscription_manager import SubscriptionManagerFacts +from insights.parsers.yum import YumRepoList +from insights.specs import Specs def valid_uuid_or_None(s): @@ -115,10 +125,12 @@ def _filter_falsy(dict_): IPs, Specs.hostname, Specs.mac_addresses, + CloudInstance, ] ) def canonical_facts( - insights_id, machine_id, bios_uuid, submanid, ips, fqdn, mac_addresses + insights_id, machine_id, bios_uuid, submanid, ips, fqdn, mac_addresses, + cloud_instance, ): facts = dict( @@ -129,6 +141,8 @@ def canonical_facts( ip_addresses=ips.data if ips else [], mac_addresses=valid_mac_addresses(mac_addresses) if mac_addresses else [], fqdn=_safe_parse(fqdn), + provider_id=cloud_instance.id if cloud_instance else None, + provider_type=cloud_instance.provider if cloud_instance else None, ) return make_metadata(**_filter_falsy(facts)) @@ -137,9 +151,25 @@ def canonical_facts( def get_canonical_facts(path=None): load_components("insights.specs.default", "insights.specs.insights_archive") - set_enabled(canonical_facts, True) - set_enabled(SubscriptionManagerID, True) - set_enabled(IPs, True) + required_components = [ + AWSInstanceIdDoc, + AzureInstanceID, + AzureInstanceType, + DMIDecode, + GCPInstanceType, + IPs, + InstalledRpms, + RHSMConf, + SubscriptionManagerFacts, + SubscriptionManagerID, + YumRepoList, + CloudProvider, + CloudInstance, + canonical_facts, + ] + for comp in required_components: + set_enabled(comp, True) + br = run(canonical_facts, root=path) d = br[canonical_facts] del d["type"] From 3cfcfc1b9dd304a0eba2b0cd3e2607470bb63e4e Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 2 Feb 2023 02:20:00 +0100 Subject: [PATCH 11/14] fix: use LC_ALL=C.UTF-8 for subscription-manager (#3669) The default environment for "simple_command" includes LC_ALL=C, which means ASCII (and not unicode); in case the language of the system is set to a non-English locale that uses unicode characters (e.g. non-Latin1 languages), then subscription-manager will fail to output that with encoding issues (e.g. [1]). As a simple solution, enforce an unicode English locale for subscription-manager, which should avoid those encoding issues. [1] https://bugzilla.redhat.com/show_bug.cgi?id=2074745 Signed-off-by: Pino Toscano --- insights/specs/default.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/insights/specs/default.py b/insights/specs/default.py index e16eafbbc0..ad8d4f597e 100644 --- a/insights/specs/default.py +++ b/insights/specs/default.py @@ -600,8 +600,10 @@ class DefaultSpecs(Specs): sshd_config = simple_file("/etc/ssh/sshd_config") sshd_config_perms = simple_command("/bin/ls -lH /etc/ssh/sshd_config") sssd_config = simple_file("/etc/sssd/sssd.conf") - subscription_manager_facts = simple_command("/usr/sbin/subscription-manager facts") - subscription_manager_id = simple_command("/usr/sbin/subscription-manager identity") # use "/usr/sbin" here, BZ#1690529 + subscription_manager_facts = simple_command("/usr/sbin/subscription-manager facts", + override_env={"LC_ALL": "C.UTF-8"}) + subscription_manager_id = simple_command("/usr/sbin/subscription-manager identity", # use "/usr/sbin" here, BZ#1690529 + override_env={"LC_ALL": "C.UTF-8"}) subscription_manager_installed_product_ids = simple_command("/usr/bin/find /etc/pki/product-default/ /etc/pki/product/ -name '*pem' -exec rct cat-cert --no-content '{}' \;") sudoers = glob_file(["/etc/sudoers", "/etc/sudoers.d/*"]) swift_object_expirer_conf = first_file(["/var/lib/config-data/puppet-generated/swift/etc/swift/object-expirer.conf", "/etc/swift/object-expirer.conf"]) From f5a6f32f464a39b0e4165125c82addc6d775e3cf Mon Sep 17 00:00:00 2001 From: wushiqinlou Date: Thu, 2 Feb 2023 15:59:00 +0800 Subject: [PATCH 12/14] fix: Enhance datasource kernel_module_filters to check the loaded modules (#3670) * Enhance datasource kernel_module_filters to check the loaded modules * Update the datasource test accordingly * Add lsmod into insights.collect.default_manifest module, raise a SkipComponent when no modules are loaded. * Update the preload parser name Signed-off-by: jiazhang --- insights/collect.py | 4 +- .../specs/datasources/kernel_module_list.py | 11 +++++- .../datasources/test_kernel_module_list.py | 37 +++++++++++++++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/insights/collect.py b/insights/collect.py index ac14dc296f..287fb9a63c 100755 --- a/insights/collect.py +++ b/insights/collect.py @@ -204,8 +204,8 @@ - name: insights.components.virtualization.IsBareMetal enabled: true - # needed for the 'pre-check' of the 'ss' spec - - name: insights.parsers.lsmod + # needed for the 'pre-check' of the 'ss' spec and the 'modinfo_filtered_modules' spec + - name: insights.parsers.lsmod.LsMod enabled: true # needed for the 'pre-check' of the 'is_satellite_server' spec diff --git a/insights/specs/datasources/kernel_module_list.py b/insights/specs/datasources/kernel_module_list.py index caab2a6c27..aaa0170c04 100644 --- a/insights/specs/datasources/kernel_module_list.py +++ b/insights/specs/datasources/kernel_module_list.py @@ -5,10 +5,11 @@ from insights.core.exceptions import SkipComponent from insights.core.filters import get_filters from insights.core.plugins import datasource +from insights.parsers.lsmod import LsMod from insights.specs import Specs -@datasource(HostContext) +@datasource(LsMod, HostContext) def kernel_module_filters(broker): """ Return a string of a list of modules from the spec filter, @@ -16,5 +17,11 @@ def kernel_module_filters(broker): """ filters = sorted((get_filters(Specs.modinfo_modules))) if filters: - return ' '.join(filters) + loaded_modules = [] + for item in filters: + if item in broker[LsMod]: + loaded_modules.append(item) + if loaded_modules: + return ' '.join(loaded_modules) + raise SkipComponent raise SkipComponent diff --git a/insights/tests/datasources/test_kernel_module_list.py b/insights/tests/datasources/test_kernel_module_list.py index 5ad41e06d6..52422dafc5 100644 --- a/insights/tests/datasources/test_kernel_module_list.py +++ b/insights/tests/datasources/test_kernel_module_list.py @@ -2,8 +2,28 @@ from insights.core import filters from insights.core.exceptions import SkipComponent +from insights.parsers.lsmod import LsMod from insights.specs import Specs from insights.specs.datasources.kernel_module_list import kernel_module_filters +from insights.tests import context_wrap + +LSMOD = """ +Module Size Used by +igb 249856 0 +i2c_algo_bit 16384 1 igb +dca 16384 1 igb +binfmt_misc 20480 1 +tcp_diag 16384 0 +udp_diag 16384 0 +inet_diag 24576 2 tcp_diag,udp_diag +binfmt_misc 69632 0 +udp_diag 18632 0 +""".strip() + +LSMOD_NO_LOADED = """ +Module Size Used by +tcp_diag 16384 0 +""".strip() def setup_function(func): @@ -13,18 +33,29 @@ def setup_function(func): del filters.FILTERS[Specs.modinfo_modules] if func is test_module_filters: - filters.add_filter(Specs.modinfo_modules, ["udp_diag", "binfmt_misc"]) + filters.add_filter(Specs.modinfo_modules, ["udp_diag", "binfmt_misc", "wireguard"]) + if func is test_module_no_loaded_modules: + filters.add_filter(Specs.modinfo_modules, ["udp_diag", "binfmt_misc", "wireguard"]) if func is test_module_filters_empty: filters.add_filter(Specs.modinfo_modules, []) def test_module_filters(): - broker = {} + lsmod_info = LsMod(context_wrap(LSMOD)) + broker = {LsMod: lsmod_info} result = kernel_module_filters(broker) assert 'binfmt_misc udp_diag' == result def test_module_filters_empty(): - broker = {} + lsmod_info = LsMod(context_wrap(LSMOD)) + broker = {LsMod: lsmod_info} + with pytest.raises(SkipComponent): + kernel_module_filters(broker) + + +def test_module_no_loaded_modules(): + lsmod_info = LsMod(context_wrap(LSMOD_NO_LOADED)) + broker = {LsMod: lsmod_info} with pytest.raises(SkipComponent): kernel_module_filters(broker) From b062e58367700bd1a6c7558c301ed1242ce00886 Mon Sep 17 00:00:00 2001 From: Ryan Blakley Date: Mon, 6 Feb 2023 02:24:31 -0500 Subject: [PATCH 13/14] Change sos archive lvm spec names (#3672) * Trying to make the spec name more specific, I'm working adding tags to the sos project it was requested for a more specific spec/tag name. Signed-off-by: Ryan Blakley --- insights/parsers/lvm.py | 6 +++--- insights/specs/__init__.py | 6 +++--- insights/specs/sos_archive.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/insights/parsers/lvm.py b/insights/parsers/lvm.py index d259d324dd..39a3047169 100644 --- a/insights/parsers/lvm.py +++ b/insights/parsers/lvm.py @@ -243,7 +243,7 @@ class PvsAll(Pvs): pass -@parser(Specs.pvs) +@parser(Specs.pvs_headings) class PvsHeadings(LvmHeadings): """ Parses the output of the @@ -395,7 +395,7 @@ class VgsAll(Vgs): pass -@parser(Specs.vgs) +@parser(Specs.vgs_headings) class VgsHeadings(LvmHeadings): """ Parses output of the @@ -588,7 +588,7 @@ class LvsAll(Lvs): pass -@parser(Specs.lvs) +@parser(Specs.lvs_headings) class LvsHeadings(LvmHeadings): """ Process output of the command `/sbin/lvs -a -o +lv_tags,devices --config="global{locking_type=0}"`. diff --git a/insights/specs/__init__.py b/insights/specs/__init__.py index 20f28bd9c4..c0b37ed334 100644 --- a/insights/specs/__init__.py +++ b/insights/specs/__init__.py @@ -367,7 +367,7 @@ class Specs(SpecSet): lvm_conf = RegistryPoint(filterable=True) lvm_system_devices = RegistryPoint() lvmconfig = RegistryPoint() - lvs = RegistryPoint() + lvs_headings = RegistryPoint() lvs_noheadings = RegistryPoint() lvs_noheadings_all = RegistryPoint() mac_addresses = RegistryPoint(multi_output=True) @@ -542,7 +542,7 @@ class Specs(SpecSet): puppet_ca_cert_expire_date = RegistryPoint() puppet_ssl_cert_ca_pem = RegistryPoint() puppetserver_config = RegistryPoint(filterable=True) - pvs = RegistryPoint() + pvs_headings = RegistryPoint() pvs_noheadings = RegistryPoint() pvs_noheadings_all = RegistryPoint() qemu_conf = RegistryPoint() @@ -746,7 +746,7 @@ class Specs(SpecSet): vdsm_logger_conf = RegistryPoint() version_info = RegistryPoint() vgdisplay = RegistryPoint() - vgs = RegistryPoint() + vgs_headings = RegistryPoint() vgs_noheadings = RegistryPoint() vgs_noheadings_all = RegistryPoint() vhost_net_zero_copy_tx = RegistryPoint() diff --git a/insights/specs/sos_archive.py b/insights/specs/sos_archive.py index 7e03902c08..09afebe55d 100644 --- a/insights/specs/sos_archive.py +++ b/insights/specs/sos_archive.py @@ -145,7 +145,7 @@ class SosSpecs(Specs): simple_file("sos_commands/pci/lspci") ]) lsscsi = simple_file("sos_commands/scsi/lsscsi") - lvs = first_file([ + lvs_headings = first_file([ "sos_commands/lvm2/lvs_-a_-o_lv_tags_devices_lv_kernel_read_ahead_lv_read_ahead_stripes_stripesize_--config_global_metadata_read_only_1_--nolocking_--foreign", "sos_commands/lvm2/lvs_-a_-o_lv_tags_devices_lv_kernel_read_ahead_lv_read_ahead_stripes_stripesize_--config_global_locking_type_0_metadata_read_only_1", "sos_commands/lvm2/lvs_-a_-o_lv_tags_devices_--config_global_locking_type_0", @@ -210,7 +210,7 @@ class SosSpecs(Specs): "/etc/puppetlabs/puppet/ssl/certs/ca.pem", "sos_commands/foreman/foreman-debug/var/lib/puppet/ssl/certs/ca.pem" ]) - pvs = first_file([ + pvs_headings = first_file([ "sos_commands/lvm2/pvs_-a_-v_-o_pv_mda_free_pv_mda_size_pv_mda_count_pv_mda_used_count_pe_start_--config_global_metadata_read_only_1_--nolocking_--foreign", "sos_commands/lvm2/pvs_-a_-v_-o_pv_mda_free_pv_mda_size_pv_mda_count_pv_mda_used_count_pe_start_--config_global_locking_type_0_metadata_read_only_1", "sos_commands/lvm2/pvs_-a_-v_-o_pv_mda_free_pv_mda_size_pv_mda_count_pv_mda_used_count_pe_start_--config_global_locking_type_0", @@ -317,7 +317,7 @@ class SosSpecs(Specs): "sos_commands/lvm2/vgdisplay_-vv", "sos_commands/devicemapper/vgdisplay_-vv" ]) - vgs = first_file([ + vgs_headings = first_file([ "sos_commands/lvm2/vgs_-v_-o_vg_mda_count_vg_mda_free_vg_mda_size_vg_mda_used_count_vg_tags_systemid_--config_global_metadata_read_only_1_--nolocking_--foreign", "sos_commands/lvm2/vgs_-v_-o_vg_mda_count_vg_mda_free_vg_mda_size_vg_mda_used_count_vg_tags_--config_global_locking_type_0_metadata_read_only_1", "sos_commands/lvm2/vgs_-v_-o_vg_mda_count_vg_mda_free_vg_mda_size_vg_mda_used_count_vg_tags_--config_global_locking_type_0", From 5ec5c3a8a6984ad34e472a776e7706a339393bdd Mon Sep 17 00:00:00 2001 From: Ryan Blakley Date: Mon, 6 Feb 2023 04:25:58 -0500 Subject: [PATCH 14/14] feat: Capture blacklisted specs inside archive (#3664) * Capture the name of blacklisted specs, and dump them to a file in the archive. * Added parser and spec to parse the blacklisted specs and use in rules. Signed-off-by: Ryan Blakley --- docs/shared_parsers_catalog/blacklisted.rst | 3 ++ insights/client/data_collector.py | 11 ++++++ insights/collect.py | 43 +++++++++++++++++++++ insights/core/blacklist.py | 1 + insights/core/dr.py | 7 +++- insights/core/exceptions.py | 7 ++++ insights/core/spec_factory.py | 6 +-- insights/parsers/blacklisted.py | 30 ++++++++++++++ insights/specs/__init__.py | 1 + insights/specs/insights_archive.py | 1 + insights/tests/parsers/test_blacklist.py | 29 ++++++++++++++ 11 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 docs/shared_parsers_catalog/blacklisted.rst create mode 100644 insights/parsers/blacklisted.py create mode 100644 insights/tests/parsers/test_blacklist.py diff --git a/docs/shared_parsers_catalog/blacklisted.rst b/docs/shared_parsers_catalog/blacklisted.rst new file mode 100644 index 0000000000..1f65ea50c0 --- /dev/null +++ b/docs/shared_parsers_catalog/blacklisted.rst @@ -0,0 +1,3 @@ +.. automodule:: insights.parsers.blacklisted + :members: + :show-inheritance: diff --git a/insights/client/data_collector.py b/insights/client/data_collector.py index 2688d0f4e7..91dc54a491 100644 --- a/insights/client/data_collector.py +++ b/insights/client/data_collector.py @@ -15,6 +15,7 @@ from subprocess import Popen, PIPE, STDOUT from tempfile import NamedTemporaryFile +from insights.core.blacklist import BLACKLISTED_SPECS from insights.util import mangle from ..contrib.soscleaner import SOSCleaner from .utilities import _expand_paths, get_version_info, systemd_notify_init_thread, get_tags @@ -132,6 +133,10 @@ def _write_blacklist_report(self, blacklist_report): self.archive.add_metadata_to_archive( json.dumps(blacklist_report), '/blacklist_report') + if BLACKLISTED_SPECS: + self.archive.add_metadata_to_archive( + json.dumps({"specs": BLACKLISTED_SPECS}), '/blacklisted_specs.txt') + def _write_egg_release(self): logger.debug("Writing egg release to archive...") egg_release = '' @@ -327,11 +332,13 @@ def run_collection(self, conf, rm_conf, branch_info, blacklist_report): 'insights_commands', mangle.mangle_command(c['command'])) if c['command'] in rm_commands or c.get('symbolic_name') in rm_commands: logger.warn("WARNING: Skipping command %s", c['command']) + BLACKLISTED_SPECS.append(c['symbolic_name']) elif self.mountpoint == "/" or c.get("image"): cmd_specs = self._parse_command_spec(c, conf['pre_commands']) for s in cmd_specs: if s['command'] in rm_commands: logger.warn("WARNING: Skipping command %s", s['command']) + BLACKLISTED_SPECS.append(s['symbolic_name']) continue cmd_spec = InsightsCommand(self.config, s, self.mountpoint) self.archive.add_to_archive(cmd_spec) @@ -343,12 +350,14 @@ def run_collection(self, conf, rm_conf, branch_info, blacklist_report): for f in conf['files']: if f['file'] in rm_files or f.get('symbolic_name') in rm_files: logger.warn("WARNING: Skipping file %s", f['file']) + BLACKLISTED_SPECS.append(f['symbolic_name']) else: file_specs = self._parse_file_spec(f) for s in file_specs: # filter files post-wildcard parsing if s['file'] in rm_conf.get('files', []): logger.warn("WARNING: Skipping file %s", s['file']) + BLACKLISTED_SPECS.append(s['symbolic_name']) else: file_spec = InsightsFile(s, self.mountpoint) self.archive.add_to_archive(file_spec) @@ -361,11 +370,13 @@ def run_collection(self, conf, rm_conf, branch_info, blacklist_report): if g.get('symbolic_name') in rm_files: # ignore glob via symbolic name logger.warn("WARNING: Skipping file %s", g['glob']) + BLACKLISTED_SPECS.append(g['symbolic_name']) else: glob_specs = self._parse_glob_spec(g) for g in glob_specs: if g['file'] in rm_files: logger.warn("WARNING: Skipping file %s", g['file']) + BLACKLISTED_SPECS.append(g['symbolic_name']) else: glob_spec = InsightsFile(g, self.mountpoint) self.archive.add_to_archive(glob_spec) diff --git a/insights/collect.py b/insights/collect.py index 287fb9a63c..2888744931 100755 --- a/insights/collect.py +++ b/insights/collect.py @@ -9,6 +9,7 @@ """ from __future__ import print_function import argparse +import json import logging import os import sys @@ -19,6 +20,7 @@ from insights import apply_configs, apply_default_enabled, get_pool from insights.core import blacklist, dr, filters +from insights.core.blacklist import BLACKLISTED_SPECS from insights.core.exceptions import CalledProcessError from insights.core.serde import Hydration from insights.util import fs @@ -402,6 +404,7 @@ def collect(manifest=default_manifest, tmp_path=None, compress=False, rm_conf=No log.warning('WARNING: Unknown component in blacklist: %s' % component) else: dr.set_enabled(component, enabled=False) + BLACKLISTED_SPECS.append(component.split('.')[-1]) log.warning('WARNING: Skipping component: %s', component) to_persist = get_to_persist(client.get("persist", set())) @@ -438,6 +441,11 @@ def collect(manifest=default_manifest, tmp_path=None, compress=False, rm_conf=No broker.add_observer(h.make_persister(to_persist)) dr.run_all(broker=broker, pool=pool) + if BLACKLISTED_SPECS: + _write_out_blacklisted_specs(output_path) + # Delete the list so the specs aren't written again by the client. + del BLACKLISTED_SPECS[:] + collect_errors = _parse_broker_exceptions(broker, EXCEPTIONS_TO_REPORT) if compress: @@ -473,6 +481,41 @@ def _parse_broker_exceptions(broker, exceptions_to_report): return errors +def _write_out_blacklisted_specs(output_path): + """ + Write out the blacklisted specs to blacklisted_specs.txt, and create + a meta-data file for this file. That way it can be loaded when the + archive is processed. + + Args: + output_path (str): Path of the output directory. + """ + if os.path.exists(os.path.join(output_path, "meta_data")): + output_path_root = os.path.join(output_path, "data") + else: + output_path_root = output_path + + with open(os.path.join(output_path_root, "blacklisted_specs.txt"), "w") as of: + json.dump({"specs": BLACKLISTED_SPECS}, of) + + doc = { + "name": "insights.specs.Specs.blacklisted_specs", + "exec_time": 0.0, + "errors": [], + "results": { + "type": "insights.core.spec_factory.DatasourceProvider", + "object": { + "relative_path": "blacklisted_specs.txt" + } + }, + "ser_time": 0.0 + } + + meta_path = os.path.join(os.path.join(output_path, "meta_data"), "insights.specs.Specs.blacklisted_specs") + with open(meta_path, "w") as of: + json.dump(doc, of) + + def main(): # Remove command line args so that they are not parsed by any called modules # The main fxn is only invoked as a cli, if calling from another cli then diff --git a/insights/core/blacklist.py b/insights/core/blacklist.py index 64fe1f4558..271e28e08b 100644 --- a/insights/core/blacklist.py +++ b/insights/core/blacklist.py @@ -1,6 +1,7 @@ import re +BLACKLISTED_SPECS = [] _FILE_FILTERS = set() _COMMAND_FILTERS = set() _PATTERN_FILTERS = set() diff --git a/insights/core/dr.py b/insights/core/dr.py index ee8ff64744..fc2acf08d4 100644 --- a/insights/core/dr.py +++ b/insights/core/dr.py @@ -64,7 +64,8 @@ def add(a, b): from insights.contrib import importlib from insights.contrib.toposort import toposort_flatten -from insights.core.exceptions import MissingRequirements, ParseException, SkipComponent +from insights.core.blacklist import BLACKLISTED_SPECS +from insights.core.exceptions import BlacklistedSpec, MissingRequirements, ParseException, SkipComponent from insights.util import defaults, enum, KeyPassingDefaultDict log = logging.getLogger(__name__) @@ -1038,6 +1039,10 @@ def run_components(ordered_components, components, broker): log.info("Trying %s" % get_name(component)) result = DELEGATES[component].process(broker) broker[component] = result + except BlacklistedSpec as bs: + for x in get_registry_points(component): + BLACKLISTED_SPECS.append(str(x).split('.')[-1]) + broker.add_exception(component, bs, traceback.format_exc()) except MissingRequirements as mr: if log.isEnabledFor(logging.DEBUG): name = get_name(component) diff --git a/insights/core/exceptions.py b/insights/core/exceptions.py index aea9a8dfa4..2e155ba6be 100644 --- a/insights/core/exceptions.py +++ b/insights/core/exceptions.py @@ -1,6 +1,13 @@ from insights.util import deprecated +class BlacklistedSpec(Exception): + """ + Exception to be thrown when a blacklisted spec is found. + """ + pass + + class CalledProcessError(Exception): """ Raised if call fails. diff --git a/insights/core/spec_factory.py b/insights/core/spec_factory.py index 5d433f9230..3103e6d3e9 100644 --- a/insights/core/spec_factory.py +++ b/insights/core/spec_factory.py @@ -14,7 +14,7 @@ from insights.core import blacklist, dr from insights.core.context import ExecutionContext, FSRoots, HostContext -from insights.core.exceptions import ContentException, SkipComponent +from insights.core.exceptions import BlacklistedSpec, ContentException, SkipComponent from insights.core.filters import _add_filter, get_filters from insights.core.plugins import component, datasource, is_datasource from insights.core.serde import deserializer, serializer @@ -178,7 +178,7 @@ def __init__(self, relative_path, root="/", ds=None, ctx=None): def validate(self): if not blacklist.allow_file("/" + self.relative_path): log.warning("WARNING: Skipping file %s", "/" + self.relative_path) - raise SkipComponent() + raise BlacklistedSpec() if not os.path.exists(self.path): raise ContentException("%s does not exist." % self.path) @@ -333,7 +333,7 @@ def _misc_settings(self): def validate(self): if not blacklist.allow_command(self.cmd): log.warning("WARNING: Skipping command %s", self.cmd) - raise SkipComponent() + raise BlacklistedSpec() cmd = shlex.split(self.cmd)[0] if not which(cmd, env=self._env): diff --git a/insights/parsers/blacklisted.py b/insights/parsers/blacklisted.py new file mode 100644 index 0000000000..f82f38da6a --- /dev/null +++ b/insights/parsers/blacklisted.py @@ -0,0 +1,30 @@ +""" +BlacklistedSpecs - File ``blacklisted_specs.txt`` +================================================= +""" +from insights.core import JSONParser +from insights.core.plugins import parser +from insights.specs import Specs + + +@parser(Specs.blacklisted_specs) +class BlacklistedSpecs(JSONParser): + """ + Parses the blacklisted_specs.txt file generated on archive creation. + + Typical output:: + "{"specs": ["insights.specs.default.DefaultSpecs.dmesg", "insights.specs.default.DefaultSpecs.fstab"]}" + + Attributes: + specs (list): List of blacklisted specs. + + Examples: + >>> type(specs) + + >>> result = ['insights.specs.default.DefaultSpecs.dmesg', 'insights.specs.default.DefaultSpecs.fstab'] + >>> specs.specs == result + True + """ + @property + def specs(self): + return self.data['specs'] diff --git a/insights/specs/__init__.py b/insights/specs/__init__.py index c0b37ed334..c8ad2279da 100644 --- a/insights/specs/__init__.py +++ b/insights/specs/__init__.py @@ -25,6 +25,7 @@ class Specs(SpecSet): azure_instance_type = RegistryPoint() bdi_read_ahead_kb = RegistryPoint(multi_output=True) bios_uuid = RegistryPoint() + blacklisted_specs = RegistryPoint() blkid = RegistryPoint() bond = RegistryPoint(multi_output=True) bond_dynamic_lb = RegistryPoint(multi_output=True) diff --git a/insights/specs/insights_archive.py b/insights/specs/insights_archive.py index f3d51ead0e..5a9059e60f 100644 --- a/insights/specs/insights_archive.py +++ b/insights/specs/insights_archive.py @@ -24,6 +24,7 @@ class InsightsArchiveSpecs(Specs): 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") bios_uuid = simple_file("insights_commands/dmidecode_-s_system-uuid") + blacklisted_specs = simple_file("blacklisted_specs.txt") blkid = simple_file("insights_commands/blkid_-c_.dev.null") brctl_show = simple_file("insights_commands/brctl_show") ceph_df_detail = first_file(["insights_commands/ceph_df_detail_-f_json-pretty", "insights_commands/ceph_df_detail_-f_json"]) diff --git a/insights/tests/parsers/test_blacklist.py b/insights/tests/parsers/test_blacklist.py new file mode 100644 index 0000000000..67f6009117 --- /dev/null +++ b/insights/tests/parsers/test_blacklist.py @@ -0,0 +1,29 @@ +import doctest +import pytest + +from insights.core.exceptions import SkipComponent +from insights.parsers import blacklisted +from insights.parsers.blacklisted import BlacklistedSpecs +from insights.tests import context_wrap + + +SPECS = '{"specs": ["insights.specs.default.DefaultSpecs.dmesg", "insights.specs.default.DefaultSpecs.fstab"]}' + + +def test_blacklisted_doc_examples(): + env = { + "specs": BlacklistedSpecs(context_wrap(SPECS)), + } + failed, total = doctest.testmod(blacklisted, globs=env) + assert failed == 0 + + +def test_skip(): + with pytest.raises(SkipComponent) as ex: + BlacklistedSpecs(context_wrap("")) + assert "Empty output." in str(ex) + + +def test_blacklist_specs(): + bs = BlacklistedSpecs(context_wrap(SPECS)) + assert bs.specs[0] == "insights.specs.default.DefaultSpecs.dmesg"