adds exception handling to nxos_command for FailedConditionalError
This adds exception handling as per ansible/ansible#17638 to the nxos_command module.
This commit is contained in:
parent
a8ca526450
commit
25375f1057
1 changed files with 10 additions and 4 deletions
|
@ -148,10 +148,14 @@ failed_conditions:
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
"""
|
"""
|
||||||
|
import ansible.module_utils.nxos
|
||||||
|
|
||||||
from ansible.module_utils.basic import get_exception
|
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.netcli import AddCommandError
|
||||||
from ansible.module_utils.nxos import NetworkModule, NetworkError
|
|
||||||
|
|
||||||
VALID_KEYS = ['command', 'output', 'prompt', 'response']
|
VALID_KEYS = ['command', 'output', 'prompt', 'response']
|
||||||
|
|
||||||
|
@ -186,7 +190,6 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
module = NetworkModule(argument_spec=spec,
|
module = NetworkModule(argument_spec=spec,
|
||||||
connect_on_load=False,
|
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
commands = list(parse_commands(module))
|
commands = list(parse_commands(module))
|
||||||
|
@ -223,9 +226,12 @@ def main():
|
||||||
except FailedConditionsError:
|
except FailedConditionsError:
|
||||||
exc = get_exception()
|
exc = get_exception()
|
||||||
module.fail_json(msg=str(exc), failed_conditions=exc.failed_conditions)
|
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:
|
except NetworkError:
|
||||||
exc = get_exception()
|
exc = get_exception()
|
||||||
module.fail_json(msg=str(exc))
|
module.fail_json(msg=str(exc), **exc.kwargs)
|
||||||
|
|
||||||
result = dict(changed=False)
|
result = dict(changed=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue