Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_interfaces_ip for non ipv6 devices #627

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,24 +1137,25 @@ def get_interfaces_ip(self):
ipv4.update({ip: {"prefix_length": int(prefix)}})
interfaces[interface_name] = {'ipv4': ipv4}

for line in show_ipv6_interface.splitlines():
if(len(line.strip()) == 0):
continue
if(line[0] != ' '):
ifname = line.split()[0]
ipv6 = {}
if ifname not in interfaces:
interfaces[ifname] = {'ipv6': ipv6}
else:
interfaces[ifname].update({'ipv6': ipv6})
m = re.match(LINK_LOCAL_ADDRESS, line)
if m:
ip = m.group(1)
ipv6.update({ip: {"prefix_length": 10}})
m = re.match(GLOBAL_ADDRESS, line)
if m:
ip, prefix = m.groups()
ipv6.update({ip: {"prefix_length": int(prefix)}})
if '% Invalid input detected at' not in show_ipv6_interface:
for line in show_ipv6_interface.splitlines():
if(len(line.strip()) == 0):
continue
if(line[0] != ' '):
ifname = line.split()[0]
ipv6 = {}
if ifname not in interfaces:
interfaces[ifname] = {'ipv6': ipv6}
else:
interfaces[ifname].update({'ipv6': ipv6})
m = re.match(LINK_LOCAL_ADDRESS, line)
if m:
ip = m.group(1)
ipv6.update({ip: {"prefix_length": 10}})
m = re.match(GLOBAL_ADDRESS, line)
if m:
ip, prefix = m.groups()
ipv6.update({ip: {"prefix_length": int(prefix)}})

# Interface without ipv6 doesn't appears in show ipv6 interface
return interfaces
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Vlan20": {
"ipv4": {
"172.29.50.3": {
"prefix_length": 27
}
}
},
"Vlan41": {
"ipv4": {
"172.29.52.34": {
"prefix_length": 27
},
"192.168.81.34": {
"prefix_length": 24
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Vlan20 is up, line protocol is up
Internet address is 172.29.50.3/27
Broadcast address is 255.255.255.255
Address determined by non-volatile memory
MTU is 1500 bytes
Helper addresses are 172.16.0.1
192.168.1.1
Directed broadcast forwarding is enabled
Multicast reserved groups joined: 224.0.0.102 224.0.0.5 224.0.0.6
Outgoing access list is not set
Inbound access list is not set
Proxy ARP is disabled
Local Proxy ARP is disabled
Security level is default
Split horizon is enabled
ICMP redirects are never sent
ICMP unreachables are never sent
ICMP mask replies are never sent
IP fast switching is enabled
IP Flow switching is disabled
IP CEF switching is enabled
IP CEF switching turbo vector
IP Null turbo vector
Associated unicast routing topologies:
Topology "base", operation state is UP
IP multicast fast switching is enabled
IP multicast distributed fast switching is disabled
IP route-cache flags are Fast, CEF
Router Discovery is disabled
IP output packet accounting is disabled
IP access violation accounting is disabled
TCP/IP header compression is disabled
RTP/IP header compression is disabled
Probe proxy name replies are disabled
Policy routing is disabled
Network address translation is disabled
BGP Policy Mapping is disabled
Input features: MCI Check
Output features: IP Post Routing Processing, HW Shortcut Installation
Post encapsulation features: MTU Processing, IP Protocol Output Counter, IP Sendself Check, HW Shortcut Installation
Sampled Netflow is disabled
IP Routed Flow creation is disabled in netflow table
IP Bridged Flow creation is disabled in netflow table
IPv4 WCCP Redirect outbound is disabled
IPv4 WCCP Redirect inbound is disabled
IPv4 WCCP Redirect exclude is disabled
IP multicast multilayer switching is disabled
GigabitEthernet1/1 is down, line protocol is down
GigabitEthernet1/2 is down, line protocol is down
GigabitEthernet1/3 is administratively down, line protocol is down
Internet protocol processing disabled
Vlan41 is up, line protocol is up
Internet address is 172.29.52.34/27
Broadcast address is 255.255.255.255
Address determined by non-volatile memory
MTU is 1514 bytes
Helper address is not set
Directed broadcast forwarding is disabled
Secondary address 192.168.81.34/24
Outgoing access list is not set
Inbound access list is not set
Proxy ARP is enabled
Local Proxy ARP is disabled
Security level is default
Split horizon is enabled
ICMP redirects are always sent
ICMP unreachables are always sent
ICMP mask replies are never sent
IP fast switching is enabled
IP fast switching on the same interface is disabled
IP Flow switching is disabled
IP CEF switching is enabled
IP CEF Fast switching turbo vector
IP multicast fast switching is enabled
IP multicast distributed fast switching is disabled
IP route-cache flags are Fast, CEF
Router Discovery is disabled
IP output packet accounting is disabled
IP access violation accounting is disabled
TCP/IP header compression is disabled
RTP/IP header compression is disabled
Policy routing is disabled
Network address translation is disabled
BGP Policy Mapping is disabled
WCCP Redirect outbound is disabled
WCCP Redirect inbound is disabled
WCCP Redirect exclude is disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^
% Invalid input detected at '^' marker.