diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-09-20 21:35:57 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-09-21 13:43:47 -0400 |
commit | 9698f76b641b7cc5964d2f4f318ea71702aa2245 (patch) | |
tree | 04f9ec59ae00ce8b79c82dd0526051ed6a0a3192 /roles/openshift_health_checker/openshift_checks/__init__.py | |
parent | 4f5839e585a78243eae2d215176047299c52a1eb (diff) | |
download | openshift-9698f76b641b7cc5964d2f4f318ea71702aa2245.tar.gz openshift-9698f76b641b7cc5964d2f4f318ea71702aa2245.tar.bz2 openshift-9698f76b641b7cc5964d2f4f318ea71702aa2245.tar.xz openshift-9698f76b641b7cc5964d2f4f318ea71702aa2245.zip |
health checks: add diagnostics check
Also, moved is_first_master method into superclass for reuse. And look
at oo_first_master and ansible_host instead of masters and
ansible_ssh_host.
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks/__init__.py')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/__init__.py b/roles/openshift_health_checker/openshift_checks/__init__.py index 28cb53cc5..ce05b44a4 100644 --- a/roles/openshift_health_checker/openshift_checks/__init__.py +++ b/roles/openshift_health_checker/openshift_checks/__init__.py @@ -13,6 +13,7 @@ from importlib import import_module from ansible.module_utils import six from ansible.module_utils.six.moves import reduce # pylint: disable=import-error,redefined-builtin +from ansible.module_utils.six import string_types from ansible.plugins.filter.core import to_bool as ansible_to_bool @@ -110,6 +111,11 @@ class OpenShiftCheck(object): """Returns true if this check applies to the ansible-playbook run.""" return True + def is_first_master(self): + """Determine if running on first master. Returns: bool""" + masters = self.get_var("groups", "oo_first_master", default=None) or [None] + return masters[0] == self.get_var("ansible_host") + @abstractmethod def run(self): """Executes a check against a host and returns a result hash similar to Ansible modules. @@ -283,6 +289,17 @@ class OpenShiftCheck(object): )) @staticmethod + def normalize(name_list): + """Return a clean list of names. + + The input may be a comma-separated string or a sequence. Leading and + trailing whitespace characters are removed. Empty items are discarded. + """ + if isinstance(name_list, string_types): + name_list = name_list.split(',') + return [name.strip() for name in name_list if name.strip()] + + @staticmethod def get_major_minor_version(openshift_image_tag): """Parse and return the deployed version of OpenShift as a tuple.""" if openshift_image_tag and openshift_image_tag[0] == 'v': |