summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sprygada <privateip@users.noreply.github.com>2016-09-20 16:30:09 -0400
committerGitHub <noreply@github.com>2016-09-20 16:30:09 -0400
commit765a76885b031d45f216a379fee94fa0b5f2776d (patch)
tree67f189aa2e4114eadc6a0fb1dbe40345b53e18f3
parentf0c9cc909bf1a2161a37b944339713b95e84bb0c (diff)
downloadansible-765a76885b031d45f216a379fee94fa0b5f2776d.tar.gz
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
-rw-r--r--lib/ansible/module_utils/eos.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py
index 81d06720a4..e17ea18e34 100644
--- a/lib/ansible/module_utils/eos.py
+++ b/lib/ansible/module_utils/eos.py
@@ -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