summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sprygada <psprygada@ansible.com>2016-09-19 12:32:37 -0400
committerPeter Sprygada <psprygada@ansible.com>2016-09-19 12:32:37 -0400
commit2e357e262c566b39ebf13b1908b7d15fa22a086e (patch)
treed293f638f496e858f3a79b1bd223224748f914bd
parent318c115e9b9b9afafbb0fa1305886b5edcec0684 (diff)
downloadansible-modules-core-2e357e262c566b39ebf13b1908b7d15fa22a086e.tar.gz
adds exception handling to nxos_command for FailedConditionalError
This adds exception handling as per ansible/ansible#17638 to the nxos_command module.
-rw-r--r--network/nxos/nxos_command.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/network/nxos/nxos_command.py b/network/nxos/nxos_command.py
index bcd7566d..9dc01a91 100644
--- a/network/nxos/nxos_command.py
+++ b/network/nxos/nxos_command.py
@@ -148,10 +148,14 @@ failed_conditions:
type: list
sample: ['...', '...']
"""
+import ansible.module_utils.nxos
+
from ansible.module_utils.basic import get_exception
-from ansible.module_utils.netcli import CommandRunner, FailedConditionsError
+from ansible.module_utils.network import NetworkModule, NetworkError
+from ansible.module_utils.netcli import CommandRunner
+from ansible.module_utils.netcli import FailedConditionsError
+from ansible.module_utils.netcli import FailedConditionalError
from ansible.module_utils.netcli import AddCommandError
-from ansible.module_utils.nxos import NetworkModule, NetworkError
VALID_KEYS = ['command', 'output', 'prompt', 'response']
@@ -186,7 +190,6 @@ def main():
)
module = NetworkModule(argument_spec=spec,
- connect_on_load=False,
supports_check_mode=True)
commands = list(parse_commands(module))
@@ -223,9 +226,12 @@ def main():
except FailedConditionsError:
exc = get_exception()
module.fail_json(msg=str(exc), failed_conditions=exc.failed_conditions)
+ except FailedConditionalError:
+ exc = get_exception()
+ module.fail_json(msg=str(exc), failed_conditional=exc.failed_conditional)
except NetworkError:
exc = get_exception()
- module.fail_json(msg=str(exc))
+ module.fail_json(msg=str(exc), **exc.kwargs)
result = dict(changed=False)