Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
brian-dashboard-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
geant-swd
brian
brian-dashboard-manager
Commits
a7a1d453
Commit
a7a1d453
authored
4 months ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Sort targets & panels for aggregate dashboards
parent
0e27124b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
brian_dashboard_manager/templating/helpers.py
+9
-5
9 additions, 5 deletions
brian_dashboard_manager/templating/helpers.py
with
9 additions
and
5 deletions
brian_dashboard_manager/templating/helpers.py
+
9
−
5
View file @
a7a1d453
...
@@ -490,7 +490,7 @@ def get_interface_data(interfaces):
...
@@ -490,7 +490,7 @@ def get_interface_data(interfaces):
return
result
return
result
def
get_aggregate_interface_data
(
interfaces
,
agg_name
,
group_field
):
def
get_aggregate_interface_data
(
interfaces
,
group_field
):
"""
"""
Helper for grouping interface data to be used for generating
Helper for grouping interface data to be used for generating
aggregate dashboards.
aggregate dashboards.
...
@@ -509,7 +509,7 @@ def get_aggregate_interface_data(interfaces, agg_name, group_field):
...
@@ -509,7 +509,7 @@ def get_aggregate_interface_data(interfaces, agg_name, group_field):
:return: dictionary of aggregate dashboards and their interface data
:return: dictionary of aggregate dashboards and their interface data
"""
"""
result
=
[]
targets
=
[]
def
get_reduce_func_for_field
(
field
):
def
get_reduce_func_for_field
(
field
):
def
reduce_func
(
prev
,
curr
):
def
reduce_func
(
prev
,
curr
):
...
@@ -532,15 +532,19 @@ def get_aggregate_interface_data(interfaces, agg_name, group_field):
...
@@ -532,15 +532,19 @@ def get_aggregate_interface_data(interfaces, agg_name, group_field):
for
info
in
interface
[
'
dashboards_info
'
]:
for
info
in
interface
[
'
dashboards_info
'
]:
remote
=
info
[
'
name
'
]
remote
=
info
[
'
name
'
]
location
=
host
.
split
(
'
.
'
)[
1
].
upper
()
location
=
host
.
split
(
'
.
'
)[
1
].
upper
()
result
.
append
({
targets
.
append
({
'
type
'
:
agg_name
,
'
interface
'
:
interface_name
,
'
interface
'
:
interface_name
,
'
hostname
'
:
host
,
'
hostname
'
:
host
,
'
remote
'
:
remote
,
'
remote
'
:
remote
,
'
location
'
:
location
,
'
location
'
:
location
,
'
alias
'
:
f
"
{
router
}
-
{
remote
}
-
{
interface_name
}
"
,
'
alias
'
:
f
"
{
router
}
-
{
remote
}
-
{
interface_name
}
"
,
})
})
return
reduce
(
get_reduce_func_for_field
(
group_field
),
result
,
{})
targets
=
sorted
(
targets
,
key
=
lambda
x
:
x
[
group_field
])
result
=
reduce
(
get_reduce_func_for_field
(
group_field
),
targets
,
{})
for
key
in
result
:
result
[
key
]
=
sorted
(
result
[
key
],
key
=
lambda
x
:
x
[
group_field
])
return
result
def
get_aggregate_targets
(
targets
):
def
get_aggregate_targets
(
targets
):
...
...
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