if a device is given, query nsot for that specific device, otherwise return
    all devices

    :param url: str
    :param headers: dict
    :param device: None or str
    :return:

def _query_nsot(url, headers, device=None):
    '''
    if a device is given, query nsot for that specific device, otherwise return
    all devices

    :param url: str
    :param headers: dict
    :param device: None or str
    :return:
    '''
    url = urlparse.urljoin(url, 'devices')
    ret = {}
    if not device:
        query = salt.utils.http.query(url, header_dict=headers, decode=True)
    else:
        url = urlparse.urljoin(url, device)
        query = salt.utils.http.query(url, header_dict=headers,
                                      decode=True)
    error = query.get('error')
    if error:
        log.error('can\'t get device(s) from nsot! reason: %s', error)
    else:
        ret = query['dict']

    return ret