Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routeros: Bug fix: Exception catching #27

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/27-routeros-exception-catching
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- routeros module_utils - created a ``try``/``except`` block on the function ``get_capabilities`` (https://github.com/ansible-collections/community.network/pull/27).
9 changes: 6 additions & 3 deletions plugins/module_utils/network/routeros/routeros.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ def get_capabilities(module):
if hasattr(module, '_routeros_capabilities'):
return module._routeros_capabilities

capabilities = Connection(module._socket_path).get_capabilities()
module._routeros_capabilities = json.loads(capabilities)
return module._routeros_capabilities
try:
capabilities = Connection(module._socket_path).get_capabilities()
module._routeros_capabilities = json.loads(capabilities)
return module._routeros_capabilities
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
renatoalmeidaoliveira marked this conversation as resolved.
Show resolved Hide resolved


def get_defaults_flag(module):
Expand Down