Skip to content
Snippets Groups Projects
Commit 5fbbae5d authored by Aaron Johnson's avatar Aaron Johnson
Browse files

refactored paging_feature_check for @Mikey1993

parent 63d2de74
No related branches found
No related tags found
No related merge requests found
......@@ -32,34 +32,38 @@ def uid_feature_check(grafana_url, http_get_headers, verify_ssl, client_cert, de
def paging_feature_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug):
# Get first dashboard on first page
(status, content) = search_dashboard(1, 1, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if status == 200 and len(content):
dashboard_one_values = sorted(content[0].items(), key=lambda kv: str(kv[1]))
else:
if len(content):
return "get dashboards failed, status: {0}, msg: {1}".format(status, content)
def get_first_dashboard_by_page(page):
(status, content) = search_dashboard(page, 1, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if status == 200 and len(content):
dashboard_values = sorted(content[0].items(), key=lambda kv: str(kv[1]))
return True, dashboard_values
else:
# No dashboards exist, disable paging feature
return False
if len(content):
return False, "get dashboards failed, status: {0}, msg: {1}".format(status, content)
else:
# No dashboards exist, disable paging feature
return False, False
# Get first dashboard on second page
(status, content) = search_dashboard(2, 1, grafana_url, http_get_headers, verify_ssl, client_cert, debug)
if status == 200 and len(content):
dashboard_two_values = sorted(content[0].items(), key=lambda kv: str(kv[1]))
# Get first dashboard on first page
(status, content) = get_first_dashboard_by_page(1)
if status is False and content is False:
return False # Paging feature not supported
elif status is True:
dashboard_one_values = content
else:
if len(content):
return "get dashboards failed, status: {0}, msg: {1}".format(status, content)
else:
# No dashboards exist, disable paging feature
return False
if dashboard_one_values == dashboard_two_values:
paging_support = False
return content # Fail Message
# Get second dashboard on second page
(status, content) = get_first_dashboard_by_page(2)
if status is False and content is False:
return False # Paging feature not supported
elif status is True:
dashboard_two_values = content
else:
paging_support = True
return content # Fail Message
return paging_support
# Compare both pages
return dashboard_one_values != dashboard_two_values
def search_dashboard(page, limit, grafana_url, http_get_headers, verify_ssl, client_cert, debug):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment