update vlan parsers

This commit is contained in:
IluaAir
2025-06-30 22:48:26 +03:00
parent 338b9e69a7
commit 2934bfd0bd
2 changed files with 3 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ class BaseDevice(Protocol):
unamed_vlan_splitter: str = ','
unamed_vlan_counter = '-'
unamed_vlans_parse_pattern = r"^vlan\s+(?:\w+\s+)?([\d,-]*[ ,][\d (to),-]*)$"
unamed_vlans_parse_pattern = r"vlan\s+(?:\w+\s+)?([\d,-]*[ ,][\d (to),-]*)$"
def __init__(self, config):
self.config: str = config

View File

@@ -15,10 +15,11 @@ class Vrp(BaseDevice):
vlans = []
pattern = self.unamed_vlans_parse_pattern
for match in re.finditer(pattern, self.config, re.MULTILINE):
print(match)
tokens = match.group(1).split(self.unamed_vlan_splitter)
i = 0
while i < len(tokens):
if i + 2 < len(tokens) and tokens[i + 1].lower() == 'to':
if i + 2 < len(tokens) and tokens[i + 1].lower() == self.unamed_vlan_counter:
start = int(tokens[i])
end = int(tokens[i + 2])
for vlan_id in range(start, end + 1):