# Path: es_stats_zabbix/defaults/settings.py
# NODETYPES = ['cluster', 'coordinating', 'master', 'data', 'ml', 'ingest']
# 
# Path: es_stats_zabbix/exceptions.py
# class FailedExecution(ESZException):
#     """
#     Exception raised when a function fails to execute for some reason.
#     """
# 
# class NotFound(ESZException):
#     """
#     Exception raised when expected information is not found.
#     """


import socket
import logging
import requests
from es_stats_zabbix.defaults.settings import NODETYPES
from es_stats_zabbix.exceptions import FailedExecution, NotFound
    if state == 'green':
        retval = 0
    elif state == 'yellow':
        retval = 1
    elif state == 'red':
        retval = 2
    else:
        retval = 3 # fail
    return retval

def true_nodetypes(statobj, nodeid):
    """
    Return a list of nodetypes which have a `True` status"""
    nodeinfo = statobj.cached_read('nodeinfo')['nodes']
    settings = nodeinfo[nodeid]['settings']['node']
    retval = []
    for nodetype in NODETYPES:
        if nodetype in settings:
            if settings[nodetype].lower() == 'true':
                retval.append(nodetype)
        elif nodetype == 'ml':
            if settings['attr'][nodetype]['enabled']:
                retval.append(nodetype)
        elif nodetype == 'cluster':
            # We don't need this here.
            pass
        else:
            #  The default is true for each node type, so if it's not false, it's true.
            retval.append(nodetype)
    LOGGER.debug('RETVAL={0}'.format(retval))

# Path: es_stats_zabbix/defaults/settings.py
# NODETYPES = ['cluster', 'coordinating', 'master', 'data', 'ml', 'ingest']
# 
# Path: es_stats_zabbix/exceptions.py
# class FailedExecution(ESZException):
#     """
#     Exception raised when a function fails to execute for some reason.
#     """
# 
# class NotFound(ESZException):
#     """
#     Exception raised when expected information is not found.
#     """


# Path: es_stats_zabbix/helpers/utils.py
import socket
import logging
import requests
from es_stats_zabbix.defaults.settings import NODETYPES
from es_stats_zabbix.exceptions import FailedExecution, NotFound

    if state == 'green':
        retval = 0
    elif state == 'yellow':
        retval = 1
    elif state == 'red':
        retval = 2
    else:
        retval = 3 # fail
    return retval

def true_nodetypes(statobj, nodeid):
    """
    Return a list of nodetypes which have a `True` status"""
    nodeinfo = statobj.cached_read('nodeinfo')['nodes']
    settings = nodeinfo[nodeid]['settings']['node']
    retval = []
    for nodetype in NODETYPES:
        if nodetype in settings:
            if settings[nodetype].lower() == 'true':
                retval.append(nodetype)
        elif nodetype == 'ml':
            if settings['attr'][nodetype]['enabled']:
                retval.append(nodetype)
        elif nodetype == 'cluster':
            # We don't need this here.
            pass
        else:
            #  The default is true for each node type, so if it's not false, it's true.
            retval.append(nodetype)
    LOGGER.debug('RETVAL={0}'.format(retval))

    return retval