From f320b1507d457960b1e0e6f9c5d1d561a9275bf8 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 23 Jul 2018 12:41:10 -0400 Subject: [PATCH] Eos subnet overlap fix (#43023) (#43099) * Detect overlapping subnet & provide better errors (cherry picked from commit dba975470d0468ddaa8268d96f65f4cbf94434bf) --- lib/ansible/module_utils/network/eos/eos.py | 6 +++++- lib/ansible/plugins/terminal/eos.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index 22bf86f6ee..76903ab0ca 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -440,7 +440,11 @@ class Eapi: commands = ['configure session %s' % session, 'abort'] self.send_request(commands) err = response['error'] - self._module.fail_json(msg=err['message'], code=err['code']) + error_text = [] + for data in err['data']: + error_text.extend(data.get('errors', [])) + error_text = '\n'.join(error_text) or err['message'] + self._module.fail_json(msg=error_text, code=err['code']) commands = ['configure session %s' % session, 'show session-config diffs'] if commit: diff --git a/lib/ansible/plugins/terminal/eos.py b/lib/ansible/plugins/terminal/eos.py index 3eb3c15b03..5f6d48dff8 100644 --- a/lib/ansible/plugins/terminal/eos.py +++ b/lib/ansible/plugins/terminal/eos.py @@ -45,7 +45,8 @@ class TerminalModule(TerminalBase): re.compile(br"[^\r\n]+ not found", re.I), re.compile(br"'[^']' +returned error code: ?\d+"), re.compile(br"[^\r\n]\/bin\/(?:ba)?sh"), - re.compile(br"% More than \d+ OSPF instance", re.I) + re.compile(br"% More than \d+ OSPF instance", re.I), + re.compile(br"% Subnet [0-9a-f.:/]+ overlaps", re.I), ] def on_open_shell(self):