Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F113380045
repro_with_collection.py
All Users
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
cr0ntab
May 1 2026, 3:58 PM
2026-05-01 15:58:26 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
repro_with_collection.py
View Options
#!/usr/bin/env python3
"""
Collection-level reproducer. Times Route_mapsTemplate14.parse() end-to-end.
Requires the vyos.vyos collection to be installed and importable
(default install location: ~/.ansible/collections/ansible_collections/vyos/vyos).
1. Builds a 12-line config (rule-lines under several route-maps).
2. Calls Route_mapsTemplate14(...).parse(), which is the same
call vyos_route_maps' facts module makes during state=gathered
or state=merged.
3. Times it.
Run:
ANSIBLE_COLLECTIONS_PATHS=~/.ansible/collections \
python3 repro_with_collection.py
"""
import
os
import
sys
import
time
# Discover the installed collection. Adjust if you put it elsewhere.
candidates
=
[
os
.
path
.
expanduser
(
"~/.ansible/collections"
),
"/usr/share/ansible/collections"
,
]
for
c
in
candidates
:
if
os
.
path
.
isdir
(
os
.
path
.
join
(
c
,
"ansible_collections/vyos/vyos"
)):
sys
.
path
.
insert
(
0
,
c
)
break
else
:
sys
.
exit
(
"Could not find ansible_collections/vyos/vyos under any of: "
+
", "
.
join
(
candidates
))
from
ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.route_maps_14
import
(
# noqa: E402
Route_mapsTemplate14
,
)
CONFIG
=
"""\
set policy route-map ADVERTISE-ANYCAST-v6 rule 10 action 'permit'
set policy route-map ADVERTISE-ANYCAST-v6 rule 10 match ipv6 address prefix-list 'ANYCAST-AGGREGATE-v6'
set policy route-map DEFAULT-ORIGINATE-SENTINEL-v6 rule 10 action 'permit'
set policy route-map DEFAULT-ORIGINATE-SENTINEL-v6 rule 10 match ipv6 address prefix-list 'AS64496-SENTINEL-v6'
set policy route-map DEFAULT-ORIGINATE-SENTINEL-v6 rule 10 set local-preference '120'
set policy route-map IXP-PEER-IN rule 10 action 'permit'
set policy route-map IXP-PEER-IN rule 10 match ip address prefix-list 'IXP-INBOUND-v4'
set policy route-map IXP-PEER-IN rule 10 set community 'additive 65000:100'
set policy route-map TRANSIT-OUT rule 100 action 'permit'
set policy route-map TRANSIT-OUT rule 100 match ip address prefix-list 'CUSTOMER-AGGREGATES-v4'
set policy route-map TRANSIT-OUT rule 100 set as-path prepend '65000 65000'
set policy route-map UPSTREAM-IN-v4 rule 10 action 'permit'
"""
def
main
():
lines
=
CONFIG
.
strip
()
.
splitlines
()
print
(
f
"input: {len(lines)} lines, {sum(len(l) for l in lines)} chars"
)
print
(
f
"PARSERS in Route_mapsTemplate14: {len(Route_mapsTemplate14.PARSERS)}"
)
parser
=
Route_mapsTemplate14
(
lines
=
lines
)
t0
=
time
.
perf_counter
()
result
=
parser
.
parse
()
dt
=
time
.
perf_counter
()
-
t0
n_route_maps
=
len
(
result
.
get
(
"route_maps"
,
{}))
print
(
f
"parse() elapsed: {dt:.2f}s (returned {n_route_maps} route_maps)"
)
print
()
if
dt
>
5
:
print
(
"Bug reproduced: parse() should finish in <0.1s."
)
else
:
print
(
"parse() finished quickly. Either the collection is patched, or"
)
print
(
"the route-map names in this input are too short to trigger the"
)
print
(
"slowdown. Try names of 20+ characters."
)
if
__name__
==
"__main__"
:
main
()
File Metadata
Details
Attached
Mime Type
text/x-script.python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3637784
Default Alt Text
repro_with_collection.py (2 KB)
Attached To
Mode
T8609: vyos_route_maps and other resource modules parse very slowly: stray regex quantifier in rm_templates
Attached
Detach File
Event Timeline
Log In to Comment