From df13096c2c7974fb1b34c4dbe8af01dfe5b0f084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kostka?= Date: Fri, 29 Jul 2022 20:00:11 +0200 Subject: [PATCH] Handle napalm 4.x tests Napalm 4.x fixed/broke uptime value type in https://github.com/napalm-automation/napalm/pull/1651 Depending on napalm version, proper type is returned. --- napalm_ros/ros.py | 6 +++++- setup.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/napalm_ros/ros.py b/napalm_ros/ros.py index 6a35d9e..21e72af 100644 --- a/napalm_ros/ros.py +++ b/napalm_ros/ros.py @@ -6,6 +6,7 @@ import socket import ssl import paramiko +import pkg_resources # Import third party libs from librouteros import connect @@ -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'], diff --git a/setup.py b/setup.py index 43142f1..08315a6 100644 --- a/setup.py +++ b/setup.py @@ -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.*', ), )