summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-04-01 21:18:55 +0200
committerGitHub <noreply@github.com>2026-04-01 21:18:55 +0200
commit2ad37c4a8a963651bbc183d24662f2571c4682c6 (patch)
tree3268124b8de81434cc07c807f4c5d1d773367a43 /python
parentf1a412985288730cc65a250da2bd4f5b87ade43f (diff)
parentc036e37357141bb71a38df174e21101151e52620 (diff)
downloadvyos-1x-2ad37c4a8a963651bbc183d24662f2571c4682c6.tar.gz
vyos-1x-2ad37c4a8a963651bbc183d24662f2571c4682c6.zip
Merge pull request #5098 from alexandr-san4ez/T8275-current
firewall: T8275: Resolve migration issue for 'weekdays' option from 1.3.8
Diffstat (limited to 'python')
-rwxr-xr-xpython/vyos/firewall.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index 04e59eb25..c655e2de8 100755
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -662,6 +662,19 @@ def parse_tcp_flags(flags):
exclude = list(flags['not']) if 'not' in flags else []
return f'tcp flags & ({"|".join(include + exclude)}) == {"|".join(include) if include else "0x0"}'
+def expand_weekday(abbrev: str) -> str:
+ mapping = {
+ 'mon': 'monday',
+ 'tue': 'tuesday',
+ 'wed': 'wednesday',
+ 'thu': 'thursday',
+ 'fri': 'friday',
+ 'sat': 'saturday',
+ 'sun': 'sunday',
+ }
+ return mapping.get(abbrev.lower(), abbrev).lower()
+
+
def parse_time(time):
out = []
if 'startdate' in time:
@@ -679,7 +692,7 @@ def parse_time(time):
if 'stoptime' in time and 'stopdate' not in time:
out.append(f'hour < "{time["stoptime"]}"')
if 'weekdays' in time:
- days = time['weekdays'].split(",")
- out_days = [f'"{day}"' for day in days if day[0] != '!']
+ days = [day.strip() for day in time['weekdays'].split(",") if day]
+ out_days = [f'"{expand_weekday(day).title()}"' for day in days if day[0] != '!']
out.append(f'day {{{",".join(out_days)}}}')
return " ".join(out)