summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/accel-ppp/ipoe.config.tmpl2
-rw-r--r--python/vyos/template.py25
2 files changed, 26 insertions, 1 deletions
diff --git a/data/templates/accel-ppp/ipoe.config.tmpl b/data/templates/accel-ppp/ipoe.config.tmpl
index 476c922b8..0599b5501 100644
--- a/data/templates/accel-ppp/ipoe.config.tmpl
+++ b/data/templates/accel-ppp/ipoe.config.tmpl
@@ -26,7 +26,7 @@ verbose=1
{% for interface in interfaces %}
{% set ifname = interface.name %}
{% if interface.vlan_mon %}
-{% set ifname = 're:' ~ interface.name ~ '\.\d+' %}
+{% set ifname = 're:^' ~ interface.name ~ '\.' ~ interface.vlan_mon | range_to_regex ~ '$' %}
{% endif %}
interface={{ ifname }},shared={{ interface.shared }},mode={{ interface.mode }},ifcfg={{ interface.ifcfg }}{{ ',range=' ~ interface.range if interface.range is defined and interface.range is not none }},start={{ interface.sess_start }},ipv6=1
{% endfor %}
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 4778bf1c8..c98d6874e 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -362,3 +362,28 @@ def get_ipv4(interface):
""" Get interface IPv4 addresses"""
from vyos.ifconfig import Interface
return Interface(interface).get_addr_v4()
+
+@register_filter('range_to_regex')
+def range_to_regex(num_range):
+ """Convert range of numbers or list of ranges
+ to regex
+ % range_to_regex('11-12')
+ '(1[1-2])'
+ % range_to_regex(['11-12', '14-15'])
+ '(1[1-2]|1[4-5])'
+ """
+ from vyos.range_regex import range_to_regex
+ if isinstance(num_range, list):
+ data = []
+ for entry in num_range:
+ if '-' not in entry:
+ data.append(entry)
+ else:
+ data.append(range_to_regex(entry))
+ return f'({"|".join(data)})'
+
+ if '-' not in num_range:
+ return num_range
+
+ regex = range_to_regex(num_range)
+ return f'({regex})'