mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-06-21 09:35:45 +02:00
* Prompt support for ROS 6.49+ (#62) * More precise version match (#62) * Add changelog fragment and lint (#62) * Update changelogs/fragments/161-workaround-prompt-with-space.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Vendor version package to support older ansible versions (#62) * Update plugins/module_utils/routeros.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/routeros.py Co-authored-by: Felix Fontein <felix@fontein.de> * move PSF-2.0.txt to LICENSES folder --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
4329928474
commit
c1a6ae8658
5 changed files with 428 additions and 0 deletions
|
@ -9,6 +9,7 @@ import json
|
|||
from ansible.module_utils.common.text.converters import to_native
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list, ComplexList
|
||||
from ansible_collections.community.routeros.plugins.module_utils.version import LooseVersion
|
||||
from ansible.module_utils.connection import Connection, ConnectionError
|
||||
|
||||
_DEVICE_CONFIGS = {}
|
||||
|
@ -103,6 +104,16 @@ def to_commands(module, commands):
|
|||
return transform(commands)
|
||||
|
||||
|
||||
def should_add_leading_space(module):
|
||||
"""Determines whether adding a leading space to the command is needed
|
||||
to workaround prompt bug in 6.49 <= ROS < 7.2"""
|
||||
capabilities = get_capabilities(module)
|
||||
network_os_version = capabilities.get('device_info', {}).get('network_os_version')
|
||||
if network_os_version is None:
|
||||
return False
|
||||
return LooseVersion('6.49') <= LooseVersion(network_os_version) < LooseVersion('7.2')
|
||||
|
||||
|
||||
def run_commands(module, commands, check_rc=True):
|
||||
responses = list()
|
||||
connection = get_connection(module)
|
||||
|
@ -117,6 +128,9 @@ def run_commands(module, commands, check_rc=True):
|
|||
prompt = None
|
||||
answer = None
|
||||
|
||||
if should_add_leading_space(module):
|
||||
command = " " + command
|
||||
|
||||
try:
|
||||
out = connection.get(command, prompt, answer)
|
||||
except ConnectionError as exc:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue