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

Return mtu -1 and speed -1.0 if regex does not find the data in nxos_ssh #1511

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ def parse_intf_section(interface):
re_is_enabled_2 = r"^admin state is (?P<is_enabled>\S+), "
re_is_enabled_3 = r"^.* is down.*Administratively down.*$"
re_mac = r"^\s+Hardware:\s+(?P<hardware>.*),\s+address:\s+(?P<mac_address>\S+) "
re_speed = (
r"\s+MTU (?P<mtu>\S+)\s+bytes,\s+BW\s+(?P<speed>\S+)\s+(?P<speed_unit>\S+).*$"
)
re_speed = r"\s+(MTU (?P<mtu>\S+)\s+bytes)?,\s+BW\s+(?P<speed>\S+)\s+(?P<speed_unit>\S+).*$"
re_mtu_nve = r"\s+MTU (?P<mtu_nve>\S+)\s+bytes.*$"
re_description_1 = r"^\s+Description:\s+(?P<description>.*) (?:MTU|Internet)"
re_description_2 = r"^\s+Description:\s+(?P<description>.*)$"
Expand Down Expand Up @@ -164,9 +162,10 @@ def parse_intf_section(interface):

if speed_exist:
match = re.search(re_speed, interface, flags=re.M)
speed = float(match.group("speed"))
mtu = int(match.group("mtu"))
speed_unit = match.group("speed_unit")
speed_data = match.groupdict(-1)
speed = float(speed_data["speed"])
mtu = int(speed_data["mtu"])
speed_unit = speed_data["speed_unit"]
speed_unit = speed_unit.rstrip(",")
# This was alway in Kbit (in the data I saw)
if speed_unit != "Kbit":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"Management0": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"is_up": true,
"mac_address": "2C:C2:60:12:EC:74",
"mtu": 1500,
"speed": 1000
},
"Ethernet2/1": {
"is_enabled": true,
"description": "Testing port descriptions",
"last_flapped": -1.0,
"is_up": true,
"mac_address": "2C:C2:60:4F:FE:B2",
"mtu": -1,
"speed": 1000
},
"Ethernet2/2": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"is_up": true,
"mac_address": "2C:C2:60:4F:FE:B2",
"mtu": -1,
"speed": 1000
},
"Loopback0": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"is_up": true,
"mac_address": "",
"mtu": 1500,
"speed": 8000
},
"Loopback55": {
"is_enabled": true,
"description": "",
"last_flapped": -1.0,
"is_up": true,
"mac_address": "",
"mtu": -1,
"speed": 8000
},
"Vlan1": {
"is_enabled": false,
"description": "",
"last_flapped": -1.0,
"is_up": false,
"mac_address": "",
"mtu": -1,
"speed": 1000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
mgmt0 is up
admin state is up
Hardware: Ethernet, address: 2cc2.6012.ec74 (bia 2cc2.6012.ec74)
Internet Address is 10.0.0.71/24
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec
reliability 245/255, txload 1/255, rxload 1/255
Encapsulation ARPA, medium is broadcast
Port mode is routed
full-duplex, 1000 Mb/s
Auto-Negotiation is turned on
Auto-mdix is turned off
EtherType is 0x0000
1 minute input rate 7208 bits/sec, 8 packets/sec
1 minute output rate 28432 bits/sec, 10 packets/sec
Rx
2322661 input packets 2284638 unicast packets 38022 multicast packets
1 broadcast packets 260628011 bytes
Tx
2084700 output packets 2046680 unicast packets 38018 multicast packets
2 broadcast packets 472741923 bytes
Ethernet2/1 is up
admin state is up, Dedicated Interface
Hardware: Ethernet, address: 2cc2.604f.feb2 (bia 2cc2.605e.5dba)
Description: Testing port descriptions
Internet Address is 10.10.10.10/24
, BW 1000000 Kbit, DLY 10 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, medium is broadcast
Port mode is routed
full-duplex, 1000 Mb/s
Beacon is turned off
Auto-Negotiation is turned off
Input flow-control is off, output flow-control is off
Auto-mdix is turned off
Switchport monitor is off
EtherType is 0x8100
EEE (efficient-ethernet) : n/a
Last link flapped 3week(s) 5day(s)
Last clearing of "show interface" counters never
1 interface resets
Load-Interval #1: 0 seconds
0 seconds input rate 0 bits/sec, 0 packets/sec
0 seconds output rate 0 bits/sec, 0 packets/sec
input rate 0 bps, 0 pps; output rate 0 bps, 0 pps
Load-Interval #2: 0 seconds
0 seconds input rate 0 bits/sec, 0 packets/sec
0 seconds output rate 0 bits/sec, 0 packets/sec
input rate 0 bps, 0 pps; output rate 0 bps, 0 pps
RX
0 unicast packets 0 multicast packets 0 broadcast packets
0 input packets 0 bytes
0 jumbo packets 0 storm suppression packets
0 runts 0 giants 0 CRC/FCS 0 no buffer
0 input error 0 short frame 0 overrun 0 underrun 0 ignored
0 watchdog 0 bad etype drop 0 bad proto drop 0 if down drop
0 input with dribble 0 input discard
0 Rx pause
TX
0 unicast packets 0 multicast packets 0 broadcast packets
0 output packets 0 bytes
0 jumbo packets
0 output error 0 collision 0 deferred 0 late collision
0 lost carrier 0 no carrier 0 babble 0 output discard
0 Tx pause
Ethernet2/2 is up
admin state is up, Dedicated Interface
Hardware: Ethernet, address: 2cc2.604f.feb2 (bia 2cc2.602f.90f4)
Internet Address is 10.100.100.1/24
, BW 1000000 Kbit, DLY 10 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, medium is broadcast
Port mode is routed
full-duplex, 1000 Mb/s
Beacon is turned off
Auto-Negotiation is turned off
Input flow-control is off, output flow-control is off
Auto-mdix is turned off
Switchport monitor is off
EtherType is 0x8100
EEE (efficient-ethernet) : n/a
Last link flapped 3week(s) 5day(s)
Last clearing of "show interface" counters never
1 interface resets
Load-Interval #1: 0 seconds
0 seconds input rate 0 bits/sec, 0 packets/sec
0 seconds output rate 0 bits/sec, 0 packets/sec
input rate 0 bps, 0 pps; output rate 0 bps, 0 pps
Load-Interval #2: 0 seconds
0 seconds input rate 0 bits/sec, 0 packets/sec
0 seconds output rate 0 bits/sec, 0 packets/sec
input rate 0 bps, 0 pps; output rate 0 bps, 0 pps
RX
0 unicast packets 0 multicast packets 0 broadcast packets
0 input packets 0 bytes
0 jumbo packets 0 storm suppression packets
0 runts 0 giants 0 CRC/FCS 0 no buffer
0 input error 0 short frame 0 overrun 0 underrun 0 ignored
0 watchdog 0 bad etype drop 0 bad proto drop 0 if down drop
0 input with dribble 0 input discard
0 Rx pause
TX
0 unicast packets 0 multicast packets 0 broadcast packets
0 output packets 0 bytes
0 jumbo packets
0 output error 0 collision 0 deferred 0 late collision
0 lost carrier 0 no carrier 0 babble 0 output discard
0 Tx pause
loopback0 is up
admin state is up
Hardware: Loopback
Internet Address is 1.1.2.225/32
MTU 1500 bytes, BW 8000000 Kbit, DLY 5000 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation LOOPBACK, medium is broadcast
Port mode is routed
Auto-mdix is turned off
0 packets input 0 bytes
0 multicast frames 0 compressed
0 input errors 0 frame 0 overrun 0 fifo
0 packets output 0 bytes 0 underruns
0 output errors 0 collisions 0 fifo
0 out_carrier_errors
loopback55 is up
admin state is up
Hardware: Loopback
Internet Address is 1.1.1.37/24
, BW 8000000 Kbit, DLY 5000 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation LOOPBACK, medium is broadcast
Port mode is routed
Auto-mdix is turned off
0 packets input 0 bytes
0 multicast frames 0 compressed
0 input errors 0 frame 0 overrun 0 fifo
0 packets output 0 bytes 0 underruns
0 output errors 0 collisions 0 fifo
0 out_carrier_errors
Vlan1 is down (Administratively down), line protocol is down, autostate enabled
Hardware is EtherSVI, address is 2cc2.605e.5de8
, BW 1000000 Kbit, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive not supported
ARP type: ARPA
Last clearing of "show interface" counters never
60 seconds input rate 0 bits/sec, 0 packets/sec
60 seconds output rate 0 bits/sec, 0 packets/sec
Load-Interval #2: 5 minute (300 seconds)
input rate 0 bps, 0 pps; output rate 0 bps, 0 pps
L3 Switched:
input: 0 pkts, 0 bytes - output: 0 pkts, 0 bytes
L3 in Switched:
ucast: 0 pkts, 0 bytes - mcast: 0 pkts, 0 bytes
L3 out Switched:
ucast: 0 pkts, 0 bytes - mcast: 0 pkts, 0 bytes