mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-06-21 09:35:45 +02:00
Allow to differ on API paths based on RouterOS version (1/2) (#209)
* Allow to provide definition for path based on API version.
* The paths added in 343c4883c0
are RouterOS 7+.
This commit is contained in:
parent
1ed4690240
commit
4b0995135c
7 changed files with 3158 additions and 2710 deletions
|
@ -97,6 +97,7 @@ def _ros_api_connect(module, username, password, host, port, use_tls, force_no_c
|
|||
|
||||
|
||||
def create_api(module):
|
||||
"""Create an API object."""
|
||||
return _ros_api_connect(
|
||||
module,
|
||||
module.params['username'],
|
||||
|
@ -111,3 +112,9 @@ def create_api(module):
|
|||
module.params['encoding'],
|
||||
module.params['timeout'],
|
||||
)
|
||||
|
||||
|
||||
def get_api_version(api):
|
||||
"""Given an API object, query the system's version."""
|
||||
system_info = list(api.path().join('system', 'resource'))[0]
|
||||
return system_info['version'].split(' ', 1)[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue