Skip to content

Commit

Permalink
Fix some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Oct 14, 2023
1 parent 4d29297 commit 17194f0
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions ciscoconfparse/models_cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
_IPV6_REGEX_STR_COMPRESSED2,
)
from ciscoconfparse.ccp_util import _IPV6_REGEX_STR_COMPRESSED3
from ciscoconfparse.ccp_util import CiscoRange, IPv4Obj, IPv6Obj
from ciscoconfparse.ccp_util import CiscoRange, CiscoInterface
from ciscoconfparse.ccp_util import IPv4Obj, IPv6Obj
from ciscoconfparse.ccp_abc import BaseCfgLine

from loguru import logger
Expand Down Expand Up @@ -1460,7 +1461,7 @@ def trunk_vlans_allowed(self):

# The default values...
if self.is_switchport and not self.has_manual_switch_access:
retval = CiscoRange("1-{0}".format(MAX_VLAN), result_type=int)
retval = CiscoRange(f"1-{MAX_VLAN}", result_type=str)
else:
return 0

Expand Down Expand Up @@ -1498,26 +1499,24 @@ def trunk_vlans_allowed(self):
}

## Analyze each vdict in sequence and apply to retval sequentially
for key, val in vdict.items():
if val != "_nomatch_":
for key, _value in vdict.items():
if _value != "_nomatch_":
## absolute in the key overrides previous values
if "absolute" in key:
if val.lower() == "all":
retval = CiscoRange(
"1-{0}".format(MAX_VLAN), result_type=int
)
elif val.lower() == "none":
retval = CiscoRange(result_type=int)
if _value.lower() == "all":
retval = CiscoRange(text=f"1-{MAX_VLAN}", result_type=str)
elif _value.lower() == "none":
# Vlan 1... the default vlan...
retval = CiscoRange(text="1", result_type=str)
else:
retval = CiscoRange(val, result_type=int)
retval = CiscoRange(text=_value, result_type=str)
elif "add" in key:
retval.append(val)
retval.append(_value)
elif "except" in key:
retval = CiscoRange("1-{0}".format(MAX_VLAN), result_type=int)
retval.remove(val)
retval = CiscoRange(text=f"1-{MAX_VLAN}", result_type=str)
retval.remove(_value)
elif "remove" in key:
retval.remove(val)

retval.remove(_value)
return retval

@property
Expand Down

0 comments on commit 17194f0

Please sign in to comment.