Fix VyOS cli prompt issues (#56389)

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
(cherry picked from commit 30ccc8e1bd)

Add changelog for vyos prompt issue fix
This commit is contained in:
Nilashish Chakraborty 2019-05-14 19:17:00 +05:30 committed by Toshio Kuratomi
parent 0cfc338cfe
commit 058653487c
3 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Fix vyos cli prompt inspection (https://github.com/ansible/ansible/pull/55589)

View file

@ -81,10 +81,9 @@ class ActionModule(ActionNetworkModule):
conn = Connection(socket_path)
out = conn.get_prompt()
while to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
if 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('abort')
out = conn.get_prompt()
conn.send_command('exit discard')
result = super(ActionModule, self).run(task_vars=task_vars)
return result

View file

@ -109,6 +109,8 @@ class Cliconf(CliconfBase):
self.discard_changes()
else:
self.send_command('exit')
if to_text(self._connection.get_prompt(), errors='surrogate_or_strict').strip().endswith('#'):
self.discard_changes()
if diff_config:
resp['diff'] = diff_config