summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2026-03-30 17:10:17 +0300
committerOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2026-04-01 11:54:31 +0300
commitc036e37357141bb71a38df174e21101151e52620 (patch)
tree8a96bfc9e82270c5bab520c09b29ff74f335a16f /python
parentad6f703b16464a6cb73f9052077a6100aff4db73 (diff)
downloadvyos-1x-c036e37357141bb71a38df174e21101151e52620.tar.gz
vyos-1x-c036e37357141bb71a38df174e21101151e52620.zip
firewall: T8275: Resolve migration issue for 'weekdays' option from 1.3.8
Fix error parsing for day of week while loading firewall configuration.
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)