Add Parsing of the routeros version for capsman metrics

This commit is contained in:
mjkantti
2024-01-20 10:46:28 +09:00
parent 7cb89a65d6
commit 23b55b266c
3 changed files with 35 additions and 1 deletions

View File

@@ -324,6 +324,19 @@ def parse_ros_version(string):
version, channel = re.findall(r'([\d\.]+).*?([\w]+)', string)[0]
return packaging.version.parse(version), channel
def is_wifi_version(string):
"""Try to check if the version is Wifi version of RouterOS (> 7.13).
If anything goes wrong, return None.
Returns a boolean"""
try:
cur_version, _ = parse_ros_version(string)
if cur_version >= packaging.version.parse('7.13'):
return True
except Exception as err:
print(f'could not get current RouterOS version, because: {str(err)}')
return False
def check_for_updates(cur_version):
"""Try to check if there is a newer version available.
If anything goes wrong, it returns the same version.