Skip to content

Commit d0d2a3e

Browse files
authored
Merge pull request #2148 from n-rodriguez/wip/fixes
Small fixes for nxos_ssh
2 parents e725559 + 3d65683 commit d0d2a3e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

napalm/nxos_ssh/nxos_ssh.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ def parse_intf_section(interface):
168168
mtu = int(speed_data["mtu"])
169169
speed_unit = speed_data["speed_unit"]
170170
speed_unit = speed_unit.rstrip(",")
171-
# This was alway in Kbit (in the data I saw)
172-
if speed_unit != "Kbit":
171+
if speed_unit not in ["Kbit", "Kbit/sec"]:
173172
msg = "Unexpected speed unit in show interfaces parsing:\n\n{}".format(
174173
interface
175174
)
@@ -484,7 +483,7 @@ def parse_uptime(uptime_str):
484483
Return the uptime in seconds as an integer
485484
"""
486485
# Initialize to zero
487-
(years, weeks, days, hours, minutes) = (0, 0, 0, 0, 0)
486+
(years, weeks, days, hours, minutes, seconds) = (0, 0, 0, 0, 0, 0)
488487

489488
uptime_str = uptime_str.strip()
490489
time_list = uptime_str.split(",")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Tests for uptime utils"""
2+
3+
from napalm.nxos_ssh import NXOSSSHDriver
4+
5+
6+
def test_parse_uptime():
7+
"""
8+
Test uptime parsing
9+
"""
10+
assert (
11+
NXOSSSHDriver.parse_uptime("0 day(s), 0 hour(s), 0 minute(s), 1 second(s)") == 1
12+
)
13+
assert (
14+
NXOSSSHDriver.parse_uptime("1 day(s), 0 hour(s), 0 minute(s), 0 second(s)")
15+
== 86400
16+
)
17+
assert (
18+
NXOSSSHDriver.parse_uptime("4 day(s), 15 hour(s), 48 minute(s), 52 second(s)")
19+
== 402532
20+
)

0 commit comments

Comments
 (0)