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

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