Skip to content

Commit

Permalink
Merge pull request #2148 from n-rodriguez/wip/fixes
Browse files Browse the repository at this point in the history
Small fixes for nxos_ssh
  • Loading branch information
bewing authored Oct 15, 2024
2 parents e725559 + 3d65683 commit d0d2a3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 2 additions & 3 deletions napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def parse_intf_section(interface):
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":
if speed_unit not in ["Kbit", "Kbit/sec"]:
msg = "Unexpected speed unit in show interfaces parsing:\n\n{}".format(
interface
)
Expand Down Expand Up @@ -484,7 +483,7 @@ def parse_uptime(uptime_str):
Return the uptime in seconds as an integer
"""
# Initialize to zero
(years, weeks, days, hours, minutes) = (0, 0, 0, 0, 0)
(years, weeks, days, hours, minutes, seconds) = (0, 0, 0, 0, 0, 0)

uptime_str = uptime_str.strip()
time_list = uptime_str.split(",")
Expand Down
20 changes: 20 additions & 0 deletions test/nxos_ssh/test_static_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Tests for uptime utils"""

from napalm.nxos_ssh import NXOSSSHDriver


def test_parse_uptime():
"""
Test uptime parsing
"""
assert (
NXOSSSHDriver.parse_uptime("0 day(s), 0 hour(s), 0 minute(s), 1 second(s)") == 1
)
assert (
NXOSSSHDriver.parse_uptime("1 day(s), 0 hour(s), 0 minute(s), 0 second(s)")
== 86400
)
assert (
NXOSSSHDriver.parse_uptime("4 day(s), 15 hour(s), 48 minute(s), 52 second(s)")
== 402532
)

0 comments on commit d0d2a3e

Please sign in to comment.