Skip to content

Commit

Permalink
Merge pull request #1121 from rahkumar651991/telnet_password_fix
Browse files Browse the repository at this point in the history
Fix for evo device as Password prompt comes directly during telnet
  • Loading branch information
rahkumar651991 authored Jul 12, 2021
2 parents 5123c54 + 3621340 commit f6ba493
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lib/jnpr/junos/transport/tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,19 @@ def _ev_tty_nologin():
# assume we're in a hung state, i.e. we don't see
# a login prompt for whatever reason
self.state = self._ST_TTY_NOLOGIN
if self.console_has_banner:
# if console connection has a banner or warning,
# use this hack
sleep(5)
self.write("\n")
else:
# @@@ this is still a hack - used by default
self.write("<close-session/>")
# For console based telnet connection a new-line is required.
# Code modified to check with a newline for telnet based connections.
# Keeping below code as a comment for future enhancement.
# if self.console_has_banner:
# # if console connection has a banner or warning,
# # use this hack
# sleep(5)
# self.write("\n")
sleep(5)
self.write("\n")
else:
# @@@ this is still a hack - used by default
self.write("<close-session/>")

def _ev_shell():
if self.state == self._ST_INIT:
Expand Down
4 changes: 3 additions & 1 deletion lib/jnpr/junos/transport/tty_telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def _tty_open(self):
sleep(self.RETRY_BACKOFF)
else:
raise RuntimeError("open_fail: port not ready")
self.write("\n")
# the below line was added for console based telnet connection as it needs newline to work.
# it causes issue in EVO devices. Keeping it as a comment for future enhancement.
# self.write("\n")

def _tty_close(self):
self._tn.close()
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/transport/test_tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def test_tty_no_login(self, mock_sleep):
self.terminal.read_prompt.return_value = (None, "testing")
self.terminal.write = MagicMock()
self.assertRaises(RuntimeError, self.terminal._login_state_machine)
self.terminal.write.assert_called_with("\n")
self.terminal.read_prompt.return_value = (None, "testing")
self.terminal.write = MagicMock()
self.assertRaises(RuntimeError, self.terminal._login_state_machine)
self.terminal.write.assert_called_with("<close-session/>")

@patch("jnpr.junos.transport.tty.sleep")
Expand Down

0 comments on commit f6ba493

Please sign in to comment.