catches exception in nxos_command and returns failed message (#22151)

Catches exception in Conditional check and returns appropriated failed
message
pull/22155/head
Peter Sprygada 8 years ago committed by Nathaniel Case
parent d9d2e6deb6
commit c26cac2a53

@ -161,7 +161,7 @@ from ansible.module_utils.nxos import run_commands
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import string_types
from ansible.module_utils.netcli import Conditional
from ansible.module_utils.netcli import Conditional, FailedConditionalError
from ansible.module_utils.network_common import ComplexList
from ansible.module_utils.nxos import nxos_argument_spec, check_args
@ -241,11 +241,15 @@ def main():
responses = run_commands(module, commands)
for item in list(conditionals):
if item(responses):
if match == 'any':
conditionals = list()
break
conditionals.remove(item)
try:
if item(responses):
if match == 'any':
conditionals = list()
break
conditionals.remove(item)
except FailedConditionalError:
exc = get_exception()
module.fail_json(msg=str(exc))
if not conditionals:
break

Loading…
Cancel
Save