'Check if host entry exists on ISE based on endpoint (IQN, WWNs)'

def _find_host(self, endpoints):

    if (type(endpoints) is list):
        for endpoint in endpoints:
            ep = endpoint
            break
    else:
        ep = endpoints
    LOG.debug('find_host:    Looking    for    host    %s.', ep)
    host = {}
    host['name'] = ''
    host['type'] = ''
    host['locator'] = ''
    params = {}
    url = ('/storage/arrays/%s/hosts' % self._get_ise_globalid())
    resp = self._send_cmd('GET', url, params)
    status = resp['status']
    if (resp['status'] != 200):
        LOG.error('Could    not    find    any    hosts    (%s)', status)
        RaiseXIODriverException()
    host_tree = etree.fromstring(resp['content'])
    for host_node in host_tree.iter():
        if (host_node.tag != 'host'):
            continue
        endpoints_node = host_node.find('endpoints')
        if (endpoints_node is None):
            continue
        for endpoint_node in endpoints_node.iter():
            if (endpoint_node.tag != 'endpoint'):
                continue
            gid = endpoint_node.find('globalid')
            if (gid is None):
                continue
            if (gid.text.upper() != ep.upper()):
                continue
            host['locator'] = host_node.attrib['self']
            type_tag = host_node.find('type')
            if (type_tag is not None):
                host['type'] = type_tag.text
            name_tag = host_node.find('name')
            if (name_tag is not None):
                host['name'] = name_tag.text
            break
    return host
