diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-03-22 16:51:25 +0100 |
---|---|---|
committer | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-03-28 11:54:52 +0200 |
commit | 4b657031ff309cb8b004cd7fbd44ae479ce09432 (patch) | |
tree | 02ae81e04d39685cc2b6f8d95bbb1177f966caa7 /roles/openshift_health_checker/openshift_checks/__init__.py | |
parent | 5e71e43a2a2e9089185d34e5406ee212cc478a75 (diff) | |
download | openshift-4b657031ff309cb8b004cd7fbd44ae479ce09432.tar.gz openshift-4b657031ff309cb8b004cd7fbd44ae479ce09432.tar.bz2 openshift-4b657031ff309cb8b004cd7fbd44ae479ce09432.tar.xz openshift-4b657031ff309cb8b004cd7fbd44ae479ce09432.zip |
Test OpenShift health check loader
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/__init__.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/__init__.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/__init__.py b/roles/openshift_health_checker/openshift_checks/__init__.py index 72d0b26df..be63d864a 100644 --- a/roles/openshift_health_checker/openshift_checks/__init__.py +++ b/roles/openshift_health_checker/openshift_checks/__init__.py @@ -63,6 +63,21 @@ class OpenShiftCheck(object): yield subclass +LOADER_EXCLUDES = ( + "__init__.py", + "mixins.py", +) + + +def load_checks(): + """Dynamically import all check modules for the side effect of registering checks.""" + return [ + import_module(__package__ + "." + name[:-3]) + for name in os.listdir(os.path.dirname(__file__)) + if name.endswith(".py") and name not in LOADER_EXCLUDES + ] + + def get_var(task_vars, *keys, **kwargs): """Helper function to get deeply nested values from task_vars. @@ -78,15 +93,3 @@ def get_var(task_vars, *keys, **kwargs): return kwargs["default"] raise OpenShiftCheckException("'{}' is undefined".format(".".join(map(str, keys)))) return value - - -# Dynamically import all submodules for the side effect of loading checks. - -EXCLUDES = ( - "__init__.py", - "mixins.py", -) - -for name in os.listdir(os.path.dirname(__file__)): - if name.endswith(".py") and name not in EXCLUDES: - import_module(__package__ + "." + name[:-3]) |