diff options
author | Andrew Butcher <abutcher@redhat.com> | 2016-01-12 16:39:06 -0500 |
---|---|---|
committer | Andrew Butcher <abutcher@redhat.com> | 2016-01-12 16:39:06 -0500 |
commit | 97be5890e2a34036a22d2d1e2586c83009ae6064 (patch) | |
tree | c52d7a106680601fec959154a7a80fae5f4735b9 /filter_plugins/openshift_master.py | |
parent | f9aaa8ac13adf841823f35be594641bdc2ebecac (diff) | |
download | openshift-97be5890e2a34036a22d2d1e2586c83009ae6064.tar.gz openshift-97be5890e2a34036a22d2d1e2586c83009ae6064.tar.bz2 openshift-97be5890e2a34036a22d2d1e2586c83009ae6064.tar.xz openshift-97be5890e2a34036a22d2d1e2586c83009ae6064.zip |
Validate pacemaker cluster members.
Diffstat (limited to 'filter_plugins/openshift_master.py')
-rw-r--r-- | filter_plugins/openshift_master.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/filter_plugins/openshift_master.py b/filter_plugins/openshift_master.py index 8d7c62ad1..7ababc51a 100644 --- a/filter_plugins/openshift_master.py +++ b/filter_plugins/openshift_master.py @@ -463,6 +463,32 @@ class FilterModule(object): IdentityProviderBase.validate_idp_list(idp_list) return yaml.safe_dump([idp.to_dict() for idp in idp_list], default_flow_style=False) + @staticmethod + def validate_pcs_cluster(data, masters=None): + ''' Validates output from "pcs status", ensuring that each master + provided is online. + Ex: data = ('...', + 'PCSD Status:', + 'master1.example.com: Online', + 'master2.example.com: Online', + 'master3.example.com: Online', + '...') + masters = ['master1.example.com', + 'master2.example.com', + 'master3.example.com'] + returns True + ''' + if not issubclass(type(data), str): + raise errors.AnsibleFilterError("|failed expects data is a string") + if not issubclass(type(masters), list): + raise errors.AnsibleFilterError("|failed expects masters is a list") + valid = True + for master in masters: + if "{0}: Online".format(master) not in data: + valid = False + return valid + def filters(self): ''' returns a mapping of filters to methods ''' - return {"translate_idps": self.translate_idps} + return {"translate_idps": self.translate_idps, + "validate_pcs_cluster": self.validate_pcs_cluster} |