-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
napalm_ios/ios.py
Outdated
ipv4.update({ip: {"prefix_length": int(prefix)}}) | ||
|
||
# Remove interfaces without ip | ||
interfaces = dict(filter(lambda x: x[1]['ipv4'] != {}, interfaces.items())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might this be more readable as
interfaces = {intf: details for intf, details in interfaces.items() if details['ipv4'] != {}}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think I would probably change this slightly to something like:
if(line[0] != ' '):
ipv4 = {}
interface_name = line.split()[0]
m = re.match(INTERNET_ADDRESS, line)
if m:
ip, prefix = m.groups()
ipv4.update({ip: {"prefix_length": int(prefix)}})
interfaces[interface_name] = {'ipv4': ipv4}
i.e. only add it to 'interfaces' if there is a positive match
FYI, we agreed on /10 for link-local addresses after reviewing some documents on it: napalm-automation/napalm-base#304 A bit of ambiguity on whether we should use /64 or /10 for this. |
Only other comment I have is that I need to verify how we handle secondary addresses by default. In other words, whether we do anything to differentiate between a secondary or primary address in the returned data structure. |
Thanks for your feebacks. |
The secondary address form is correct. So this should be right. |
Fix #204
As proposed in the issue by ktbyers I used
show ip[v6] interface
.I changed the documentation of get_interfaces_ip in the code as N/A was not accepted on link-local ipv6 prefix_length because it was not an integer. I replaced N/A by 64 which seems to be the prefix length of such addresses.