Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grafana Backup Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Migrated Projects
Tooling
Grafana Backup Tool
Commits
5fbbae5d
Commit
5fbbae5d
authored
4 years ago
by
Aaron Johnson
Browse files
Options
Downloads
Patches
Plain Diff
refactored paging_feature_check for @Mikey1993
parent
63d2de74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
grafana_backup/dashboardApi.py
+27
-23
27 additions, 23 deletions
grafana_backup/dashboardApi.py
with
27 additions
and
23 deletions
grafana_backup/dashboardApi.py
+
27
−
23
View file @
5fbbae5d
...
...
@@ -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_val
ue
s
:
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
el
if
status
is
Tr
ue
:
dashboard_two_values
=
content
else
:
paging_support
=
Tru
e
return
content
# Fail Messag
e
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment