Skip to content

Commit

Permalink
Merge branch 'main' into t7013-route_maps_integration_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gaige authored Jan 31, 2025
2 parents ea1cd39 + f7f5fb5 commit 2a177f8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @vyos/ansible-collection-maintainers
* @vyos/vyos-ansible-collection-maintainers
3 changes: 3 additions & 0 deletions changelogs/fragments/T6833_fw_rules_limit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- firewall_rules - Fix limit parameter processing
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def _add_limit(self, attr, w, h, cmd, opr):
if opr and not (
h_limit
and self._is_w_same(rate, h_limit, "unit")
and self.is_w_same(rate, h_limit, "number")
and self._is_w_same(rate, h_limit, "number")
):
commands.append(
cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,6 @@ def parse_limit(self, conf, attrib=None):
cfg_dict["rate"] = self.parse_rate(conf, "rate")
return cfg_dict

def parse_rate(self, conf, attrib=None):
"""
This function triggers the parsing of 'rate' attributes.
:param conf: configuration.
:param attrib: 'rate'
:return: generated config dictionary.
"""
a_lst = ["unit", "number"]
cfg_dict = self.parse_attr(conf, a_lst, match=attrib)
return cfg_dict

def parse_attr(self, conf, attr_list, match=None):
"""
This function peforms the following:
Expand Down Expand Up @@ -472,6 +461,7 @@ def parse_attr(self, conf, attr_list, match=None):
if attrib == 'log':
out = search(r"^.*\d+" + " (log$)", conf, M)
if out:

val = out.group(1).strip("'")
if self.is_num(attrib):
val = int(val)
Expand Down Expand Up @@ -519,3 +509,21 @@ def is_num(self, attrib):
"""
num_set = ("time", "code", "type", "count", "burst", "number")
return True if attrib in num_set else False

def parse_rate(self, conf, match):
"""
This function triggers the parsing of 'rate' attributes.
:param conf: configuration.
:param attrib: 'rate'
:return: generated config dictionary.
"""
config = {}

out = search(r"^.*" + match + " (.+)", conf, M)
if out:
val = out.group(1).strip("'")
if "/" in val: # number/unit
(number, unit) = val.split("/")
config['number'] = number
config['unit'] = unit
return config

0 comments on commit 2a177f8

Please sign in to comment.