Skip to content

Commit

Permalink
Handle napalm 4.x tests
Browse files Browse the repository at this point in the history
Napalm 4.x fixed/broke uptime value type in
napalm-automation/napalm#1651
Depending on napalm version, proper type is returned.
  • Loading branch information
luqasz committed Jul 29, 2022
1 parent f5ec2d4 commit df13096
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion napalm_ros/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import socket
import ssl
import paramiko
import pkg_resources

# Import third party libs
from librouteros import connect
Expand Down Expand Up @@ -351,8 +352,11 @@ def get_facts(self):
identity = tuple(self.api('/system/identity/print'))[0]
routerboard = tuple(self.api('/system/routerboard/print'))[0]
interfaces = tuple(self.api('/interface/print'))
to_type = float
if pkg_resources.get_distribution("napalm").parsed_version.major == 3:
to_type = int
return {
'uptime': to_seconds(resource['uptime']),
'uptime': to_type(to_seconds(resource['uptime'])),
'vendor': resource['platform'],
'model': resource['board-name'],
'hostname': identity['name'],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
url="https://github.com/napalm-automation-community/napalm-ros",
include_package_data=True,
install_requires=(
'napalm==3.*',
'napalm>=3.*',
'librouteros==3.*',
),
)

0 comments on commit df13096

Please sign in to comment.