Closed ggiesen closed 1 year ago
I've managed to make a quick fix to this with the following patch:
--- a/ros.py 2023-06-28 16:27:20.625172826 +0000
+++ b/ros.py 2023-06-28 16:29:09.245630466 +0000
@@ -503,7 +503,7 @@
'packet_loss': max(row['packet-loss'] for row in results),
'rtt_min': min(rtt('min-rtt', results)),
'rtt_max': max(rtt('max-rtt', results)), # Last result has calculated avg
- 'rtt_avg': float(results[-1].get('avg-rtt', '-1ms').replace('ms', '')),
+ 'rtt_avg': float(re.sub(r'([0-9]+)ms(?:([0-9]+)+us)?', r'\1.\2', results[-1].get('avg-rtt', '-1ms'))),
'rtt_stddev': float(-1),
'results': []
}
@@ -511,7 +511,7 @@
for row in results:
ping_results['results'].append({
'ip_address': cast_ip(row['host']),
- 'rtt': float(row.get('time', '-1ms').replace('ms', '')),
+ 'rtt': float(re.sub(r'([0-9]+)ms(?:([0-9]+)+us)?', r'\1.\2', row.get('time', '-1ms'))),
})
return dict(success=ping_results)
--- a/utils.py 2023-06-28 16:29:56.460723748 +0000
+++ b/utils.py 2023-06-28 16:10:04.953124459 +0000
@@ -2,9 +2,11 @@
ip as cast_ip,
)
+import re
+
def rtt(key, iterable):
- return (float(row.get(key, '-1ms').replace('ms', '')) for row in iterable)
+ return (float(re.sub(r'([0-9]+)ms(?:([0-9]+)+us)?', r'\1.\2', row.get(key, '-1ms'))) for row in iterable)
def to_seconds(time_format):
It should work for both ROS6 (no µs) and ROS7 (includes µs)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Sorry for leaving this issue.
Description of Issue/Question
When attempting a ping using ROS 7.10, I receive a
ValueError: could not convert string to float: '27699us'
Setup
napalm-ros version
(Paste verbatim output from
pip freeze | grep napalm-ros
between quotes below)ROS version
(Paste verbatim output from
/system package print
between quotes below)librouteros version
(Paste verbatim output from
pip freeze | grep librouteros
between quotes below)python version
(paste output of python --version)
Steps to Reproduce the Issue
Error Traceback
(Paste the complete traceback of the exception between quotes below)