From 55caa9020a59d9c89aedc966b7bf53abc08245e0 Mon Sep 17 00:00:00 2001 From: Serat Yoleri <33866876+yoleri@users.noreply.github.com> Date: Mon, 14 Sep 2020 20:21:38 +0200 Subject: [PATCH 1/2] fix: update regex for newer junos prompt [ error ] Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 769, in _app_authenticate index, match = self._waitfor(prompt_list) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 986, in _waitfor result = self._domatch(re_list, False) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/ssh2.py", line 422, in _domatch if not self._fill_buffer(): File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/ssh2.py", line 393, in _fill_buffer raise TimeoutException(error) Exscript.protocols.exception.TimeoutException: Timeout while waiting for response from device During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/usr/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "", line 74, in conn.login(account) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 675, in login self.authenticate(account, flush=False) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 701, in authenticate self.app_authenticate(app_account, flush=flush) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 870, in app_authenticate self._app_authenticate(account, password, flush, bailout) File "/usr/local/lib/python3.5/dist-packages/Exscript/protocols/protocol.py", line 774, in _app_authenticate raise TimeoutException(msg) Exscript.protocols.exception.TimeoutException: Buffer: '' [ cause ] The shell prompt has changed in newer JunOS versions [ prompt ] 14.1R7.4: root@dev1% 18.4R3.3: root@dev1:~ # [ fix ] Add support for new prompt --- Exscript/protocols/drivers/junos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exscript/protocols/drivers/junos.py b/Exscript/protocols/drivers/junos.py index bcadda09..ea58f4af 100644 --- a/Exscript/protocols/drivers/junos.py +++ b/Exscript/protocols/drivers/junos.py @@ -55,7 +55,7 @@ _re_re = r'(?:' + _mb + r'|' + _ps + r')' _edit = r'(?:\[edit[^\]\r\n]*\])' _prefix = r'(?:[\r\n]+' + _re_re + r'?' + _edit + r'?)' -_prompt = r'[\r\n]+[\w\-\.]+@[\-\w+\.:]+[%>#] $' +_prompt = r'[\r\n]+[\w\-\.]+@[\-\w+\.:]+[~]?[\s%>#]+$' _prompt_re = [re.compile(_prefix + r'?' + _prompt)] _error_re = [re.compile(r'^(unknown|invalid|error|syntax error)', re.I)] _junos_re = re.compile(r'\bjunos\b', re.I) From 5a9539fd2c7d7197f4e3cd0f2ff9315fcc42591a Mon Sep 17 00:00:00 2001 From: Serat Yoleri <33866876+yoleri@users.noreply.github.com> Date: Mon, 14 Sep 2020 20:44:06 +0200 Subject: [PATCH 2/2] improved prompt matching for JunOS --- tests/Exscript/protocols/banners/junos.4 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/Exscript/protocols/banners/junos.4 diff --git a/tests/Exscript/protocols/banners/junos.4 b/tests/Exscript/protocols/banners/junos.4 new file mode 100644 index 00000000..dba38bf1 --- /dev/null +++ b/tests/Exscript/protocols/banners/junos.4 @@ -0,0 +1,4 @@ +Password: +Last login: Mon Sep 14 17:57:32 2020 from (x.x.x.x) +--- JUNOS 18.4R3.3 Kernel 64-bit JNPR-11.0-20191211.fa5e90e_buil +root@testhost:~ #