mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 05:11:25 -07:00
Make prompt inspection explicit for IOS (#54324)
* Be explicit with prompt inspection Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Use regex to evaluate prompt for sub-level config sessions Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Add new line at the end of file Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
This commit is contained in:
parent
70f315b7a4
commit
ee08b009dd
1 changed files with 4 additions and 4 deletions
|
@ -19,6 +19,7 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
@ -85,10 +86,9 @@ class ActionModule(ActionNetworkModule):
|
||||||
conn = Connection(socket_path)
|
conn = Connection(socket_path)
|
||||||
try:
|
try:
|
||||||
out = conn.get_prompt()
|
out = conn.get_prompt()
|
||||||
while to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
|
if re.search(r'config.*\)#', to_text(out, errors='surrogate_then_replace').strip()):
|
||||||
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
|
display.vvvv('wrong context, sending end to device', self._play_context.remote_addr)
|
||||||
conn.send_command('exit')
|
conn.send_command('end')
|
||||||
out = conn.get_prompt()
|
|
||||||
except ConnectionError as exc:
|
except ConnectionError as exc:
|
||||||
return {'failed': True, 'msg': to_text(exc)}
|
return {'failed': True, 'msg': to_text(exc)}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue