Eos subnet overlap fix (#43023)

* Detect overlapping subnet & provide better errors
pull/43051/head
Nathaniel Case 6 years ago committed by GitHub
parent e129616ba6
commit dba975470d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -153,7 +153,7 @@ class Cli:
try:
response = conn.edit_config(commands, commit, replace)
except ConnectionError as exc:
message = getattr(exc, 'err', exc)
message = getattr(exc, 'err', to_text(exc))
if "check mode is not supported without configuration session" in message:
self._module.warn("EOS can not check config without config session")
response = {'changed': True}
@ -341,7 +341,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:

@ -85,7 +85,12 @@ class HttpApi(HttpApiBase):
else:
commands.append(command)
try:
response = self.send_request(commands)
except Exception:
commands = ['configure session %s' % session, 'abort']
response = self.send_request(commands, output='text')
raise
commands = ['configure session %s' % session, 'show session-config diffs']
if commit:
@ -152,7 +157,13 @@ class HttpApi(HttpApiBase):
def handle_response(response):
if 'error' in response:
error = response['error']
raise ConnectionError(error['message'], code=error['code'])
error_text = []
for data in error['data']:
error_text.extend(data.get('errors', []))
error_text = '\n'.join(error_text) or error['message']
raise ConnectionError(error_text, code=error['code'])
results = []
for result in response['result']:

@ -46,7 +46,8 @@ class TerminalModule(TerminalBase):
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"Maximum number of pending sessions has been reached")
re.compile(br"% Subnet [0-9a-f.:/]+ overlaps", re.I),
re.compile(br"Maximum number of pending sessions has been reached"),
]
def on_open_shell(self):

Loading…
Cancel
Save