Skip to content

Commit

Permalink
Fix CiscoRange() logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Oct 13, 2023
1 parent 2b5e465 commit 0be96e1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ciscoconfparse/ccp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3365,15 +3365,16 @@ def parse_text_list(self, text, debug=False):
expanded_interfaces = []
raw_parts = text.split(",")
for idx, raw_part in enumerate(raw_parts):

if debug is True:
logger.info(f" CiscoRange() for --> {raw_part} <--")

# Set the begin_obj...
if len(raw_part.split("-")) == 2:
# Append a whole range of interfaces...
begin_obj = CiscoInterface(raw_part.split("-")[0])
end_ordinal = int(raw_part.split("-")[1].strip())
else:
begin_obj = CiscoInterface(raw_part)
end_ordinal = None

##############################################################
# Walk all possible attributes to find which target_attribute
Expand All @@ -3397,6 +3398,17 @@ def parse_text_list(self, text, debug=False):
logger.info(f" CiscoRange(text={text}, debug=True) iterate_attribute: {self.iterate_attribute}")
logger.info(f" CiscoRange(text={text}, debug=True) begin_obj: {begin_obj}")

# Set the end_ordinal... keep this separate from begin_obj logic...
if self.iterate_attribute is None:
raise ValueError()
if len(raw_part.split("-")) == 2:
# Append a whole range of interfaces...
end_ordinal = int(raw_part.split("-")[1].strip())
else:
end_ordinal = getattr(begin_obj, self.iterate_attribute, None)

if debug is True:
logger.info(f" CiscoRange(text={text}, debug=True) end_ordinal: {end_ordinal}")

##################################################################
# Reference interface is for the base starting interface instance
Expand All @@ -3417,7 +3429,7 @@ def parse_text_list(self, text, debug=False):

if idx > 0:

if True:
if False:
if self.iterate_attribute == 'channel' and isinstance(reference_interface.channel, int):
#############################################################
# Base the new reference_interface off the lowest digit
Expand Down Expand Up @@ -3455,6 +3467,7 @@ def parse_text_list(self, text, debug=False):
expanded_interfaces.append(copy.deepcopy(reference_interface))
continue

print("LOOP HERE")
if self.iterate_attribute == 'channel' and isinstance(template_interface.channel, int):
##############################################################
# Handle incrementing channel numbers
Expand Down

0 comments on commit 0be96e1

Please sign in to comment.