in curator/helpers/waiters.py [0:0]
def health_check(client, **kwargs):
"""
This function calls `client.cluster.`
:py:meth:`~.elasticsearch.client.ClusterClient.health` and, based on the params
provided, will return ``True`` or ``False`` depending on whether that
particular keyword appears in the output, and has the expected value.
If multiple keys are provided, all must match for a ``True`` response.
:param client: A client connection object
:type client: :py:class:`~.elasticsearch.Elasticsearch`
:rtype: bool
"""
logger = logging.getLogger(__name__)
logger.debug('KWARGS= "%s"', kwargs)
klist = list(kwargs.keys())
if not klist:
raise MissingArgument('Must provide at least one keyword argument')
hc_data = client.cluster.health()
response = True
for k in klist:
# First, verify that all kwargs are in the list
if k not in list(hc_data.keys()):
raise ConfigurationError('Key "{0}" not in cluster health output')
if not hc_data[k] == kwargs[k]:
msg = (
f'NO MATCH: Value for key "{kwargs[k]}", '
f'health check data: {hc_data[k]}'
)
logger.debug(msg)
response = False
else:
msg = f'MATCH: Value for key "{kwargs[k]}", health check data: {hc_data[k]}'
logger.debug(msg)
if response:
logger.info('Health Check for all provided keys passed.')
return response