fixes issue where config sessions where left behind (#17673)
When using the Cli transport, if the session hung on a command and the socket timed out, the config session would be left behind. This change will allow the shell to try to get control back and remove the config session, assuming the channel is still open. fixes ansible/ansible-modules-core#4945
This commit is contained in:
parent
f0c9cc909b
commit
765a76885b
1 changed files with 6 additions and 1 deletions
|
@ -29,7 +29,7 @@
|
|||
import re
|
||||
import time
|
||||
|
||||
from ansible.module_utils.basic import json
|
||||
from ansible.module_utils.basic import json, get_exception
|
||||
from ansible.module_utils.network import ModuleStub, NetworkError, NetworkModule
|
||||
from ansible.module_utils.network import add_argument, register_transport, to_list
|
||||
from ansible.module_utils.netcli import Command
|
||||
|
@ -81,6 +81,11 @@ class EosConfigMixin(object):
|
|||
else:
|
||||
self.execute(['no configure session %s' % session])
|
||||
except NetworkError:
|
||||
exc = get_exception()
|
||||
if 'timeout trying to send command' in exc.message:
|
||||
# try to get control back and get out of config mode
|
||||
if isinstance(self, Cli):
|
||||
self.execute(['\x03', 'end'])
|
||||
self.abort_config(session)
|
||||
diff = None
|
||||
raise
|
||||
|
|
Loading…
Reference in a new issue