Пример #1
0
def get_individual_dashboard_setting_and_save(dashboards, folder_path,
                                              log_file, grafana_url,
                                              http_get_headers, verify_ssl,
                                              client_cert, debug):
    file_path = folder_path + '/' + log_file
    if dashboards:
        with open(u"{0}".format(file_path), 'w') as f:
            for board in dashboards:
                (status, content) = get_dashboard(board['uri'], grafana_url,
                                                  http_get_headers, verify_ssl,
                                                  client_cert, debug)
                if status == 200:
                    save_dashboard_setting(
                        to_python2_and_3_compatible_string(board['title']),
                        board['uid'], content, folder_path)
                    f.write('{0}\t{1}\n'.format(
                        board['uid'],
                        to_python2_and_3_compatible_string(board['title'])))
def get_individual_dashboard_setting_and_save(dashboards, folder_path, log_file, grafana_url, http_get_headers, verify_ssl, client_cert, debug, pretty_print, api_version):
    file_path = folder_path + '/' + log_file
    if dashboards:
        with open(u"{0}".format(file_path), 'w') as f:
            for board in dashboards:
                if left_ver_newer_than_right_ver(api_version, "4.6.3"):
                    board_uri = "uid/{0}".format(board['uid'])
                else:
                    board_uri = board['uri']

                (status, content) = get_dashboard(board_uri, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
                if status == 200:
                    save_dashboard_setting(
                        to_python2_and_3_compatible_string(board['title']), 
                        board['uid'], 
                        content,
                        folder_path,
                        pretty_print
                    )
                    f.write('{0}\t{1}\n'.format(board['uid'], to_python2_and_3_compatible_string(board['title'])))