Skip to content

Commit 0196e97

Browse files
committed
Add SROS enable mode support
1 parent a9767a3 commit 0196e97

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

netmiko/alcatel/alcatel_sros_ssh.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,33 @@ def set_base_prompt(self, *args, **kwargs):
2525
self.base_prompt = match.group(1)
2626
return self.base_prompt
2727

28-
def enable(self, *args, **kwargs):
28+
def enable(self, cmd='enable-admin', pattern='ssword', re_flags=re.IGNORECASE):
29+
"""Enter enable mode."""
30+
return super(AlcatelSrosSSH, self).enable(cmd=cmd, pattern=pattern, re_flags=re_flags)
31+
32+
def check_enable_mode(self, check_string='CLI Already in admin mode'):
33+
"""Check whether we are in enable-admin mode.
34+
SROS requires us to do this:
35+
*A:HOSTNAME# enable-admin
36+
MINOR: CLI Already in admin mode.
37+
*A:HOSTNAME#
38+
*A:HOSTNAME# enable-admin
39+
Password:
40+
MINOR: CLI Invalid password.
41+
*A:HOSTNAME#
42+
"""
43+
output = self.send_command_timing('enable-admin')
44+
if re.search(r"ssword", output):
45+
# Just hit enter as we don't actually want to enter enable here
46+
self.write_channel(self.normalize_cmd(self.RETURN))
47+
self.read_until_prompt()
48+
return False
49+
elif check_string in output:
50+
return True
51+
raise ValueError("Unexpected response in check_enable_mode() method")
52+
53+
def exit_enable_mode(self, exit_command=''):
54+
"""No corresponding exit of enable mode on SROS."""
2955
pass
3056

3157
def config_mode(self, config_command='configure', pattern='#'):

0 commit comments

Comments
 (0)