Blame SOURCES/0004-Move-the-abstracted-plugin-runner-code-into-a-separa.patch

ef63c6
From 952fc6f6dee99523360c9826ad865086cd31474f Mon Sep 17 00:00:00 2001
ef63c6
From: Rob Crittenden <rcritten@redhat.com>
ef63c6
Date: Mon, 18 Nov 2019 14:33:32 -0500
ef63c6
Subject: [PATCH 4/5] Move the abstracted plugin runner code into a separate
ef63c6
 file
ef63c6
ef63c6
This way main.py contains just the ipa-healthcheck main code
ef63c6
and not the rest of the abstracted code.
ef63c6
ef63c6
Also replace sys.exit(1) with return 1.
ef63c6
---
ef63c6
 src/ipahealthcheck/core/core.py | 272 ++++++++++++++++++++++++++++++++
ef63c6
 src/ipahealthcheck/core/main.py | 267 +------------------------------
ef63c6
 2 files changed, 273 insertions(+), 266 deletions(-)
ef63c6
 create mode 100644 src/ipahealthcheck/core/core.py
ef63c6
ef63c6
diff --git a/src/ipahealthcheck/core/core.py b/src/ipahealthcheck/core/core.py
ef63c6
new file mode 100644
ef63c6
index 0000000..182eac3
ef63c6
--- /dev/null
ef63c6
+++ b/src/ipahealthcheck/core/core.py
ef63c6
@@ -0,0 +1,272 @@
ef63c6
+#
ef63c6
+# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
ef63c6
+#
ef63c6
+
ef63c6
+import argparse
ef63c6
+import json
ef63c6
+import logging
ef63c6
+import pkg_resources
ef63c6
+
ef63c6
+from datetime import datetime
ef63c6
+
ef63c6
+from ipahealthcheck.core.config import read_config
ef63c6
+from ipahealthcheck.core.plugin import Result, Results, json_to_results
ef63c6
+from ipahealthcheck.core.output import output_registry
ef63c6
+from ipahealthcheck.core import constants
ef63c6
+from ipahealthcheck.core.service import ServiceCheck
ef63c6
+
ef63c6
+logging.basicConfig(format='%(message)s')
ef63c6
+logger = logging.getLogger()
ef63c6
+
ef63c6
+
ef63c6
+def find_registries(entry_points):
ef63c6
+    registries = {}
ef63c6
+    for entry_point in entry_points:
ef63c6
+        registries.update({
ef63c6
+            ep.name: ep.resolve()
ef63c6
+            for ep in pkg_resources.iter_entry_points(entry_point)
ef63c6
+        })
ef63c6
+    return registries
ef63c6
+
ef63c6
+
ef63c6
+def find_plugins(name, registry):
ef63c6
+    for ep in pkg_resources.iter_entry_points(name):
ef63c6
+        # load module
ef63c6
+        ep.load()
ef63c6
+    return registry.get_plugins()
ef63c6
+
ef63c6
+
ef63c6
+def run_plugin(plugin, available=()):
ef63c6
+    # manually calculate duration when we create results of our own
ef63c6
+    start = datetime.utcnow()
ef63c6
+    try:
ef63c6
+        for result in plugin.check():
ef63c6
+            if result is None:
ef63c6
+                # Treat no result as success, fudge start time
ef63c6
+                result = Result(plugin, constants.SUCCESS, start=start)
ef63c6
+            yield result
ef63c6
+    except Exception as e:
ef63c6
+        logger.debug('Exception raised: %s', e)
ef63c6
+        yield Result(plugin, constants.CRITICAL, exception=str(e),
ef63c6
+                     start=start)
ef63c6
+
ef63c6
+
ef63c6
+def source_or_check_matches(plugin, source, check):
ef63c6
+    """Determine whether a given a plugin matches if a source
ef63c6
+       and optional check are provided.
ef63c6
+    """
ef63c6
+    if source is not None and plugin.__module__ != source:
ef63c6
+        return False
ef63c6
+
ef63c6
+    if check and plugin.__class__.__name__ != check:
ef63c6
+        return False
ef63c6
+
ef63c6
+    return True
ef63c6
+
ef63c6
+
ef63c6
+def run_service_plugins(plugins, config, source, check):
ef63c6
+    """Execute plugins with the base class of ServiceCheck
ef63c6
+
ef63c6
+       This is a specialized check to use systemd to determine
ef63c6
+       if a service is running or not.
ef63c6
+    """
ef63c6
+    results = Results()
ef63c6
+    available = []
ef63c6
+
ef63c6
+    for plugin in plugins:
ef63c6
+        if not isinstance(plugin, ServiceCheck):
ef63c6
+            continue
ef63c6
+
ef63c6
+        logger.debug('Calling check %s', plugin)
ef63c6
+        for result in plugin.check():
ef63c6
+            # always run the service checks so dependencies work
ef63c6
+            if result is not None and result.result == constants.SUCCESS:
ef63c6
+                available.append(plugin.service.service_name)
ef63c6
+            if not source_or_check_matches(plugin, source, check):
ef63c6
+                continue
ef63c6
+            if result is not None:
ef63c6
+                results.add(result)
ef63c6
+
ef63c6
+    return results, set(available)
ef63c6
+
ef63c6
+
ef63c6
+def run_plugins(plugins, config, available, source, check):
ef63c6
+    """Execute plugins without the base class of ServiceCheck
ef63c6
+
ef63c6
+       These are the remaining, non-service checking checks
ef63c6
+       that do validation for various parts of a system.
ef63c6
+    """
ef63c6
+    results = Results()
ef63c6
+
ef63c6
+    for plugin in plugins:
ef63c6
+        if isinstance(plugin, ServiceCheck):
ef63c6
+            continue
ef63c6
+
ef63c6
+        if not source_or_check_matches(plugin, source, check):
ef63c6
+            continue
ef63c6
+
ef63c6
+        logger.debug('Calling check %s' % plugin)
ef63c6
+        plugin.config = config
ef63c6
+        if not set(plugin.requires).issubset(available):
ef63c6
+            logger.debug('Skipping %s:%s because %s service(s) not running',
ef63c6
+                         plugin.__class__.__module__,
ef63c6
+                         plugin.__class__.__name__,
ef63c6
+                         ', '.join(set(plugin.requires) - available))
ef63c6
+            # Not providing a Result in this case because if a required
ef63c6
+            # service isn't available then this could generate a lot of
ef63c6
+            # false positives.
ef63c6
+        else:
ef63c6
+            for result in run_plugin(plugin, available):
ef63c6
+                results.add(result)
ef63c6
+
ef63c6
+    return results
ef63c6
+
ef63c6
+
ef63c6
+def list_sources(plugins):
ef63c6
+    """Print list of all sources and checks"""
ef63c6
+    source = None
ef63c6
+    for plugin in plugins:
ef63c6
+        if source != plugin.__class__.__module__:
ef63c6
+            print(plugin.__class__.__module__)
ef63c6
+            source = plugin.__class__.__module__
ef63c6
+        print("  ", plugin.__class__.__name__)
ef63c6
+
ef63c6
+    return 0
ef63c6
+
ef63c6
+
ef63c6
+def parse_options(output_registry):
ef63c6
+    output_names = [plugin.__name__.lower() for
ef63c6
+                    plugin in output_registry.plugins]
ef63c6
+    parser = argparse.ArgumentParser()
ef63c6
+    parser.add_argument('--debug', dest='debug', action='store_true',
ef63c6
+                        default=False, help='Include debug output')
ef63c6
+    parser.add_argument('--list-sources', dest='list_sources',
ef63c6
+                        action='store_true', default=False,
ef63c6
+                        help='List all available sources')
ef63c6
+    parser.add_argument('--source', dest='source',
ef63c6
+                        default=None,
ef63c6
+                        help='Source of checks, e.g. ipahealthcheck.foo.bar')
ef63c6
+    parser.add_argument('--check', dest='check',
ef63c6
+                        default=None,
ef63c6
+                        help='Check to execute, e.g. BazCheck')
ef63c6
+    parser.add_argument('--output-type', dest='output', choices=output_names,
ef63c6
+                        default='json', help='Output method')
ef63c6
+    parser.add_argument('--output-file', dest='outfile', default=None,
ef63c6
+                        help='File to store output')
ef63c6
+    parser.add_argument('--input-file', dest='infile',
ef63c6
+                        help='File to read as input')
ef63c6
+    parser.add_argument('--failures-only', dest='failures_only',
ef63c6
+                        action='store_true', default=False,
ef63c6
+                        help='Exclude SUCCESS results on output')
ef63c6
+    parser.add_argument('--severity', dest='severity', action="append",
ef63c6
+                        help='Include only the selected severity(s)',
ef63c6
+                        choices=[key for key in constants._nameToLevel])
ef63c6
+    for plugin in output_registry.plugins:
ef63c6
+        onelinedoc = plugin.__doc__.split('\n\n', 1)[0].strip()
ef63c6
+        group = parser.add_argument_group(plugin.__name__.lower(),
ef63c6
+                                          onelinedoc)
ef63c6
+        for option in plugin.options:
ef63c6
+            group.add_argument(option[0], **option[1])
ef63c6
+
ef63c6
+    options = parser.parse_args()
ef63c6
+
ef63c6
+    # Validation
ef63c6
+    if options.check and not options.source:
ef63c6
+        print("--source is required when --check is used")
ef63c6
+        return 1
ef63c6
+
ef63c6
+    return options
ef63c6
+
ef63c6
+
ef63c6
+def limit_results(results, source, check):
ef63c6
+    """Return ony those results which match source and/or check"""
ef63c6
+    new_results = Results()
ef63c6
+    for result in results.results:
ef63c6
+        if result.source == source:
ef63c6
+            if check is None or result.check == check:
ef63c6
+                new_results.add(result)
ef63c6
+    return new_results
ef63c6
+
ef63c6
+
ef63c6
+def run_healthcheck(entry_points, configfile):
ef63c6
+    framework = object()
ef63c6
+    plugins = []
ef63c6
+    output = constants.DEFAULT_OUTPUT
ef63c6
+
ef63c6
+    logger.setLevel(logging.INFO)
ef63c6
+
ef63c6
+    options = parse_options(output_registry)
ef63c6
+
ef63c6
+    if options.debug:
ef63c6
+        logger.setLevel(logging.DEBUG)
ef63c6
+
ef63c6
+    config = read_config(configfile)
ef63c6
+    if config is None:
ef63c6
+        return 1
ef63c6
+
ef63c6
+    for name, registry in find_registries(entry_points).items():
ef63c6
+        try:
ef63c6
+            registry.initialize(framework)
ef63c6
+        except Exception as e:
ef63c6
+            print("Unable to initialize %s: %s" % (name, e))
ef63c6
+            return 1
ef63c6
+        for plugin in find_plugins(name, registry):
ef63c6
+            plugins.append(plugin)
ef63c6
+
ef63c6
+    for out in output_registry.plugins:
ef63c6
+        if out.__name__.lower() == options.output:
ef63c6
+            output = out(options)
ef63c6
+
ef63c6
+    if options.list_sources:
ef63c6
+        return list_sources(plugins)
ef63c6
+
ef63c6
+    if options.infile:
ef63c6
+        try:
ef63c6
+            with open(options.infile, 'r') as f:
ef63c6
+                raw_data = f.read()
ef63c6
+
ef63c6
+            json_data = json.loads(raw_data)
ef63c6
+            results = json_to_results(json_data)
ef63c6
+            available = ()
ef63c6
+        except Exception as e:
ef63c6
+            print("Unable to import '%s': %s" % (options.infile, e))
ef63c6
+            return 1
ef63c6
+        if options.source:
ef63c6
+            results = limit_results(results, options.source, options.check)
ef63c6
+    else:
ef63c6
+        results, available = run_service_plugins(plugins, config,
ef63c6
+                                                 options.source,
ef63c6
+                                                 options.check)
ef63c6
+        results.extend(run_plugins(plugins, config, available,
ef63c6
+                                   options.source, options.check))
ef63c6
+
ef63c6
+    if options.source and len(results.results) == 0:
ef63c6
+        for plugin in plugins:
ef63c6
+            if not source_or_check_matches(plugin, options.source,
ef63c6
+                                           options.check):
ef63c6
+                continue
ef63c6
+
ef63c6
+            if not set(plugin.requires).issubset(available):
ef63c6
+                print("Source '%s' is missing one or more requirements '%s'" %
ef63c6
+                      (options.source, ', '.join(plugin.requires)))
ef63c6
+                return 1
ef63c6
+
ef63c6
+        if options.check:
ef63c6
+            print("Check '%s' not found in Source '%s'" %
ef63c6
+                  (options.check, options.source))
ef63c6
+        else:
ef63c6
+            print("Source '%s' not found" % options.source)
ef63c6
+        return 1
ef63c6
+
ef63c6
+    try:
ef63c6
+        output.render(results)
ef63c6
+    except Exception as e:
ef63c6
+        logger.error('Output raised %s: %s', e.__class__.__name__, e)
ef63c6
+
ef63c6
+    return_value = 0
ef63c6
+    for result in results.results:
ef63c6
+        if result.result != constants.SUCCESS:
ef63c6
+            return_value = 1
ef63c6
+            break
ef63c6
+
ef63c6
+    return return_value
ef63c6
diff --git a/src/ipahealthcheck/core/main.py b/src/ipahealthcheck/core/main.py
ef63c6
index 2b818d4..d9e85d7 100644
ef63c6
--- a/src/ipahealthcheck/core/main.py
ef63c6
+++ b/src/ipahealthcheck/core/main.py
ef63c6
@@ -2,276 +2,11 @@
ef63c6
 # Copyright (C) 2019 FreeIPA Contributors see COPYING for license
ef63c6
 #
ef63c6
 
ef63c6
-import argparse
ef63c6
-import json
ef63c6
-import logging
ef63c6
 from os import environ
ef63c6
-import pkg_resources
ef63c6
 import sys
ef63c6
 
ef63c6
-from datetime import datetime
ef63c6
-
ef63c6
-from ipahealthcheck.core.config import read_config
ef63c6
-from ipahealthcheck.core.plugin import Result, Results, json_to_results
ef63c6
-from ipahealthcheck.core.output import output_registry
ef63c6
 from ipahealthcheck.core import constants
ef63c6
-from ipahealthcheck.core.service import ServiceCheck
ef63c6
-
ef63c6
-logging.basicConfig(format='%(message)s')
ef63c6
-logger = logging.getLogger()
ef63c6
-
ef63c6
-
ef63c6
-def find_registries(entry_points):
ef63c6
-    registries = {}
ef63c6
-    for entry_point in entry_points:
ef63c6
-        registries.update({
ef63c6
-            ep.name: ep.resolve()
ef63c6
-            for ep in pkg_resources.iter_entry_points(entry_point)
ef63c6
-        })
ef63c6
-    return registries
ef63c6
-
ef63c6
-
ef63c6
-def find_plugins(name, registry):
ef63c6
-    for ep in pkg_resources.iter_entry_points(name):
ef63c6
-        # load module
ef63c6
-        ep.load()
ef63c6
-    return registry.get_plugins()
ef63c6
-
ef63c6
-
ef63c6
-def run_plugin(plugin, available=()):
ef63c6
-    # manually calculate duration when we create results of our own
ef63c6
-    start = datetime.utcnow()
ef63c6
-    try:
ef63c6
-        for result in plugin.check():
ef63c6
-            if result is None:
ef63c6
-                # Treat no result as success, fudge start time
ef63c6
-                result = Result(plugin, constants.SUCCESS, start=start)
ef63c6
-            yield result
ef63c6
-    except Exception as e:
ef63c6
-        logger.debug('Exception raised: %s', e)
ef63c6
-        yield Result(plugin, constants.CRITICAL, exception=str(e),
ef63c6
-                     start=start)
ef63c6
-
ef63c6
-
ef63c6
-def source_or_check_matches(plugin, source, check):
ef63c6
-    """Determine whether a given a plugin matches if a source
ef63c6
-       and optional check are provided.
ef63c6
-    """
ef63c6
-    if source is not None and plugin.__module__ != source:
ef63c6
-        return False
ef63c6
-
ef63c6
-    if check and plugin.__class__.__name__ != check:
ef63c6
-        return False
ef63c6
-
ef63c6
-    return True
ef63c6
-
ef63c6
-
ef63c6
-def run_service_plugins(plugins, config, source, check):
ef63c6
-    """Execute plugins with the base class of ServiceCheck
ef63c6
-
ef63c6
-       This is a specialized check to use systemd to determine
ef63c6
-       if a service is running or not.
ef63c6
-    """
ef63c6
-    results = Results()
ef63c6
-    available = []
ef63c6
-
ef63c6
-    for plugin in plugins:
ef63c6
-        if not isinstance(plugin, ServiceCheck):
ef63c6
-            continue
ef63c6
-
ef63c6
-        logger.debug('Calling check %s', plugin)
ef63c6
-        for result in plugin.check():
ef63c6
-            # always run the service checks so dependencies work
ef63c6
-            if result is not None and result.result == constants.SUCCESS:
ef63c6
-                available.append(plugin.service.service_name)
ef63c6
-            if not source_or_check_matches(plugin, source, check):
ef63c6
-                continue
ef63c6
-            if result is not None:
ef63c6
-                results.add(result)
ef63c6
-
ef63c6
-    return results, set(available)
ef63c6
-
ef63c6
-
ef63c6
-def run_plugins(plugins, config, available, source, check):
ef63c6
-    """Execute plugins without the base class of ServiceCheck
ef63c6
-
ef63c6
-       These are the remaining, non-service checking checks
ef63c6
-       that do validation for various parts of a system.
ef63c6
-    """
ef63c6
-    results = Results()
ef63c6
-
ef63c6
-    for plugin in plugins:
ef63c6
-        if isinstance(plugin, ServiceCheck):
ef63c6
-            continue
ef63c6
-
ef63c6
-        if not source_or_check_matches(plugin, source, check):
ef63c6
-            continue
ef63c6
-
ef63c6
-        logger.debug('Calling check %s' % plugin)
ef63c6
-        plugin.config = config
ef63c6
-        if not set(plugin.requires).issubset(available):
ef63c6
-            logger.debug('Skipping %s:%s because %s service(s) not running',
ef63c6
-                         plugin.__class__.__module__,
ef63c6
-                         plugin.__class__.__name__,
ef63c6
-                         ', '.join(set(plugin.requires) - available))
ef63c6
-            # Not providing a Result in this case because if a required
ef63c6
-            # service isn't available then this could generate a lot of
ef63c6
-            # false positives.
ef63c6
-        else:
ef63c6
-            for result in run_plugin(plugin, available):
ef63c6
-                results.add(result)
ef63c6
-
ef63c6
-    return results
ef63c6
-
ef63c6
-
ef63c6
-def list_sources(plugins):
ef63c6
-    """Print list of all sources and checks"""
ef63c6
-    source = None
ef63c6
-    for plugin in plugins:
ef63c6
-        if source != plugin.__class__.__module__:
ef63c6
-            print(plugin.__class__.__module__)
ef63c6
-            source = plugin.__class__.__module__
ef63c6
-        print("  ", plugin.__class__.__name__)
ef63c6
-
ef63c6
-    return 0
ef63c6
-
ef63c6
-
ef63c6
-def parse_options(output_registry):
ef63c6
-    output_names = [plugin.__name__.lower() for
ef63c6
-                    plugin in output_registry.plugins]
ef63c6
-    parser = argparse.ArgumentParser()
ef63c6
-    parser.add_argument('--debug', dest='debug', action='store_true',
ef63c6
-                        default=False, help='Include debug output')
ef63c6
-    parser.add_argument('--list-sources', dest='list_sources',
ef63c6
-                        action='store_true', default=False,
ef63c6
-                        help='List all available sources')
ef63c6
-    parser.add_argument('--source', dest='source',
ef63c6
-                        default=None,
ef63c6
-                        help='Source of checks, e.g. ipahealthcheck.foo.bar')
ef63c6
-    parser.add_argument('--check', dest='check',
ef63c6
-                        default=None,
ef63c6
-                        help='Check to execute, e.g. BazCheck')
ef63c6
-    parser.add_argument('--output-type', dest='output', choices=output_names,
ef63c6
-                        default='json', help='Output method')
ef63c6
-    parser.add_argument('--output-file', dest='outfile', default=None,
ef63c6
-                        help='File to store output')
ef63c6
-    parser.add_argument('--input-file', dest='infile',
ef63c6
-                        help='File to read as input')
ef63c6
-    parser.add_argument('--failures-only', dest='failures_only',
ef63c6
-                        action='store_true', default=False,
ef63c6
-                        help='Exclude SUCCESS results on output')
ef63c6
-    parser.add_argument('--severity', dest='severity', action="append",
ef63c6
-                        help='Include only the selected severity(s)',
ef63c6
-                        choices=[key for key in constants._nameToLevel])
ef63c6
-    for plugin in output_registry.plugins:
ef63c6
-        onelinedoc = plugin.__doc__.split('\n\n', 1)[0].strip()
ef63c6
-        group = parser.add_argument_group(plugin.__name__.lower(),
ef63c6
-                                          onelinedoc)
ef63c6
-        for option in plugin.options:
ef63c6
-            group.add_argument(option[0], **option[1])
ef63c6
-
ef63c6
-    options = parser.parse_args()
ef63c6
-
ef63c6
-    # Validation
ef63c6
-    if options.check and not options.source:
ef63c6
-        print("--source is required when --check is used")
ef63c6
-        sys.exit(1)
ef63c6
-
ef63c6
-    return options
ef63c6
-
ef63c6
-
ef63c6
-def limit_results(results, source, check):
ef63c6
-    """Return ony those results which match source and/or check"""
ef63c6
-    new_results = Results()
ef63c6
-    for result in results.results:
ef63c6
-        if result.source == source:
ef63c6
-            if check is None or result.check == check:
ef63c6
-                new_results.add(result)
ef63c6
-    return new_results
ef63c6
-
ef63c6
-
ef63c6
-def run_healthcheck(entry_points, configfile):
ef63c6
-    framework = object()
ef63c6
-    plugins = []
ef63c6
-    output = constants.DEFAULT_OUTPUT
ef63c6
-
ef63c6
-    logger.setLevel(logging.INFO)
ef63c6
-
ef63c6
-    options = parse_options(output_registry)
ef63c6
-
ef63c6
-    if options.debug:
ef63c6
-        logger.setLevel(logging.DEBUG)
ef63c6
-
ef63c6
-    config = read_config(configfile)
ef63c6
-    if config is None:
ef63c6
-        sys.exit(1)
ef63c6
-
ef63c6
-    for name, registry in find_registries(entry_points).items():
ef63c6
-        try:
ef63c6
-            registry.initialize(framework)
ef63c6
-        except Exception as e:
ef63c6
-            print("Unable to initialize %s: %s" % (name, e))
ef63c6
-            sys.exit(1)
ef63c6
-        for plugin in find_plugins(name, registry):
ef63c6
-            plugins.append(plugin)
ef63c6
-
ef63c6
-    for out in output_registry.plugins:
ef63c6
-        if out.__name__.lower() == options.output:
ef63c6
-            output = out(options)
ef63c6
-
ef63c6
-    if options.list_sources:
ef63c6
-        return list_sources(plugins)
ef63c6
-
ef63c6
-    if options.infile:
ef63c6
-        try:
ef63c6
-            with open(options.infile, 'r') as f:
ef63c6
-                raw_data = f.read()
ef63c6
-
ef63c6
-            json_data = json.loads(raw_data)
ef63c6
-            results = json_to_results(json_data)
ef63c6
-            available = ()
ef63c6
-        except Exception as e:
ef63c6
-            print("Unable to import '%s': %s" % (options.infile, e))
ef63c6
-            sys.exit(1)
ef63c6
-        if options.source:
ef63c6
-            results = limit_results(results, options.source, options.check)
ef63c6
-    else:
ef63c6
-        results, available = run_service_plugins(plugins, config,
ef63c6
-                                                 options.source,
ef63c6
-                                                 options.check)
ef63c6
-        results.extend(run_plugins(plugins, config, available,
ef63c6
-                                   options.source, options.check))
ef63c6
-
ef63c6
-    if options.source and len(results.results) == 0:
ef63c6
-        for plugin in plugins:
ef63c6
-            if not source_or_check_matches(plugin, options.source,
ef63c6
-                                           options.check):
ef63c6
-                continue
ef63c6
-
ef63c6
-            if not set(plugin.requires).issubset(available):
ef63c6
-                print("Source '%s' is missing one or more requirements '%s'" %
ef63c6
-                      (options.source, ', '.join(plugin.requires)))
ef63c6
-                sys.exit(1)
ef63c6
-
ef63c6
-        if options.check:
ef63c6
-            print("Check '%s' not found in Source '%s'" %
ef63c6
-                  (options.check, options.source))
ef63c6
-        else:
ef63c6
-            print("Source '%s' not found" % options.source)
ef63c6
-        sys.exit(1)
ef63c6
-
ef63c6
-    try:
ef63c6
-        output.render(results)
ef63c6
-    except Exception as e:
ef63c6
-        logger.error('Output raised %s: %s', e.__class__.__name__, e)
ef63c6
-
ef63c6
-    return_value = 0
ef63c6
-    for result in results.results:
ef63c6
-        if result.result != constants.SUCCESS:
ef63c6
-            return_value = 1
ef63c6
-            break
ef63c6
-
ef63c6
-    return return_value
ef63c6
+from ipahealthcheck.core.core import run_healthcheck
ef63c6
 
ef63c6
 
ef63c6
 def main():
ef63c6
-- 
ef63c6
2.20.1
ef63c6