|
@@ -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}
|