1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix VyOS cli prompt issues (#56389)

Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
This commit is contained in:
Nilashish Chakraborty 2019-05-14 19:17:00 +05:30 committed by GitHub
parent 88be323bcd
commit 30ccc8e1bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -81,10 +81,9 @@ class ActionModule(ActionNetworkModule):
conn = Connection(socket_path) conn = Connection(socket_path)
out = conn.get_prompt() 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) display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit discard') conn.send_command('exit discard')
out = conn.get_prompt()
result = super(ActionModule, self).run(task_vars=task_vars) result = super(ActionModule, self).run(task_vars=task_vars)
return result return result

View file

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