Skip to content

Commit

Permalink
Fix HSRP decrement parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Oct 26, 2023
1 parent fff49a6 commit 22b43d9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ciscoconfparse/models_cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def group(self):
@property
@logger.catch(reraise=True)
def decrement(self):
if isinstance(self._decrement, (str, int)):
if isinstance(self._decrement, (str, int)) and str(self._decrement) != "":
return int(self._decrement)
else:
return None
Expand Down Expand Up @@ -304,12 +304,15 @@ def get_hsrp_tracked_interfaces(self):
for obj in self._parent.children:
obj_parts = obj.text.strip().split()
if obj_parts[0:3] == ["standby", str(self._group), "track"]:
_groupdict = obj.re_match_iter_typed(
r"standby\s(\d+)\s+track\s+(?P<intf>\S.+?)\s+(?P<decr>\d+)$",
groupdict={"intf": str, "decr": int},
interface = None
decrement = 10
_gg = obj.re_match_iter_typed(
r"standby\s(\d+)\s+track\s+(?P<intf>\S.+?)(?P<decr>\s+\d+)*$",
groupdict={"intf": str, "decr": str},
)
interface = _groupdict["intf"]
decrement = _groupdict["decr"]
interface = _gg["intf"]
if isinstance(_gg["decr"], str) and _gg["decr"] != "None":
decrement = int(_gg["decr"].strip())
retval.append(
TrackingInterface(
group=int(self._group),
Expand Down

0 comments on commit 22b43d9

Please sign in to comment.