diff --git a/README.md b/README.md index 8fe633c..acc202d 100644 --- a/README.md +++ b/README.md @@ -85,11 +85,13 @@ from ciscoconfparse import CiscoConfParse # ipv6 address fe80::1 link-local # ipv6 enable # ipv6 ospf 11 area 0 -# standby 11 ip 172.16.2.254 -# standby 11 ipv6 autoconfig -# standby 11 priority 150 -# standby 11 preempt delay minimum 15 -# standby 11 track Dialer1 75 +# standby 110 ip 172.16.2.254 +# standby 110 ipv6 autoconfig +# standby 110 priority 150 +# standby 110 preempt delay minimum 15 +# standby 110 track Dialer1 75 +# standby 110 track FastEthernet0/1 20 +# standby 110 track FastEthernet1/0 30 # standby 111 ip 172.16.2.253 # standby 111 priority 150 # standby 111 preempt delay minimum 15 @@ -207,9 +209,9 @@ Interface FastEthernet0/0: 172.16.2.1/24 Tracking interface: Dialer1 Tracking decrement: 75 Tracking weighting: None - --- Tracking FastEthernet0/1 --- - Tracking interface: FastEthernet0/1 - Tracking decrement: 20 + --- Tracking FastEthernet 0/1 --- + Tracking interface: FastEthernet 0/1 + Tracking decrement: 10 Tracking weighting: None --- Tracking FastEthernet1/0 --- Tracking interface: FastEthernet1/0 @@ -220,6 +222,8 @@ Interface FastEthernet0/0: 172.16.2.1/24 Tracking interface: Dialer1 Tracking decrement: 50 Tracking weighting: None +GRP {'addr': } +RESULT ``` diff --git a/ciscoconfparse/models_cisco.py b/ciscoconfparse/models_cisco.py index 720d5d8..2b9124d 100644 --- a/ciscoconfparse/models_cisco.py +++ b/ciscoconfparse/models_cisco.py @@ -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 @@ -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\S.+?)\s+(?P\d+)$", - groupdict={"intf": str, "decr": int}, + interface = None + decrement = 10 + _gg = obj.re_match_iter_typed( + r"standby\s(\d+)\s+track\s+(?P\S.+?)(?P\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),