'Query the API server for the kubernetes hostname of the node
using the docker hostname as a filter.'

def get_node_hostname(self, host):

    node_filter = {'labelSelector': ('kubernetes.io/hostname=%s' % host)}
    node = self.retrieve_json_auth((self.kubernetes_api_url + ('/nodes?%s' % urlencode(node_filter))))
    if (len(node['items']) != 1):
        log.error(('Error    while    getting    node    hostname:    expected    1    node,    got    %s.' % len(node['items'])))
    else:
        addresses = (node or {}).get('items', [{}])[0].get('status', {}).get('addresses', [])
        for address in addresses:
            if (address.get('type') == 'Hostname'):
                return address['address']
    return None
