mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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)
|
||||
__metaclass__ = type
|
||||
|
||||
import re
|
||||
import sys
|
||||
import copy
|
||||
|
||||
|
@ -85,10 +86,9 @@ class ActionModule(ActionNetworkModule):
|
|||
conn = Connection(socket_path)
|
||||
try:
|
||||
out = conn.get_prompt()
|
||||
while to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
|
||||
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
|
||||
conn.send_command('exit')
|
||||
out = conn.get_prompt()
|
||||
if re.search(r'config.*\)#', to_text(out, errors='surrogate_then_replace').strip()):
|
||||
display.vvvv('wrong context, sending end to device', self._play_context.remote_addr)
|
||||
conn.send_command('end')
|
||||
except ConnectionError as exc:
|
||||
return {'failed': True, 'msg': to_text(exc)}
|
||||
|
||||
|
|
Loading…
Reference in a new issue