Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Status-Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Freifunk Hochstift
Status-Bot
Commits
c35b0cbc
Commit
c35b0cbc
authored
9 years ago
by
Maximilian Wilhelm
Browse files
Options
Downloads
Patches
Plain Diff
Be site aware when aggregating node IDs of salt output.
Signed-off-by:
Maximilian Wilhelm
<
max@rfc2324.org
>
parent
0145846b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ffpb.py
+26
-11
26 additions, 11 deletions
modules/ffpb.py
with
26 additions
and
11 deletions
modules/ffpb.py
+
26
−
11
View file @
c35b0cbc
...
...
@@ -608,29 +608,44 @@ def ffpb_print_cached_messages (bot):
def
_ffpb_aggregate_node_ids
(
bot
,
nodes
):
"""
Aggregate given list of node IDs as far as possbile (read: combine g
ateways
)
"""
Aggregate given list of node IDs as far as possbile (read: combine g
w*, lnx*, ...
)
and return aggregated and ordered list.
"""
aggr_patterns
=
(
'
gw
'
,
'
lnx
'
)
nodes_temp
=
{}
nodes_aggr
=
[]
for
node
in
nodes
:
match
=
re
.
search
(
"
^
gw(\d+)(.*)?$
"
,
node
)
match
=
re
.
search
(
"
^
([a-z-]+(\d+))(\.([a-z]+)\.?)?.*
"
,
node
,
re
.
I
)
if
match
:
expr
=
re
.
sub
(
"
^gw(\d+)
"
,
"
gw##
"
,
node
)
if
expr
not
in
nodes_temp
:
nodes_temp
[
expr
]
=
[]
site
=
match
.
group
(
4
)
if
match
.
group
(
4
)
else
None
expr
=
match
.
group
(
1
)
for
pattern
in
aggr_patterns
:
expr
=
re
.
sub
(
"
^%s(\d+)
"
%
pattern
,
"
%s##
"
%
pattern
,
expr
)
nodes_temp
[
expr
].
append
(
match
.
group
(
1
))
if
site
not
in
nodes_temp
:
nodes_temp
[
site
]
=
{}
if
expr
not
in
nodes_temp
[
site
]:
nodes_temp
[
site
][
expr
]
=
[]
nodes_temp
[
site
][
expr
].
append
(
match
.
group
(
2
))
continue
nodes_aggr
.
append
(
node
)
for
node
,
n_list
in
nodes_temp
.
items
():
if
len
(
n_list
)
==
1
:
nodes_aggr
.
append
(
re
.
sub
(
"
gw##
"
,
"
gw%s
"
%
n_list
[
0
],
node
))
else
:
nodes_aggr
.
append
(
re
.
sub
(
"
gw##
"
,
"
gw{%s}
"
%
"
,
"
.
join
(
sorted
(
n_list
)),
node
))
for
site
,
hosts
in
nodes_temp
.
items
():
for
node
,
n_list
in
hosts
.
items
():
if
len
(
n_list
)
==
1
:
node
=
re
.
sub
(
"
##
"
,
"
%s
"
%
n_list
[
0
],
node
)
else
:
node
=
re
.
sub
(
"
##
"
,
"
{%s}
"
%
"
,
"
.
join
(
sorted
(
n_list
)),
node
)
if
site
:
node
+=
"
.
"
+
site
nodes_aggr
.
append
(
node
)
return
"
,
"
.
join
(
sorted
(
nodes_aggr
))
...
...
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