-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Hi there,
I just reset about 15x CRS326-24G-2S+RM, to configure them. There seem to be two cases, that aren't handled.
1.: You will be promted to ignore/reset the default config. You can see the output here: mer.vin
2.: You will be asked to set a new password. As it must not be the old one, I just skip it via "CTRL-C".
I was able to bypass this automatically, by editing the "special_login_handler":
def special_login_handler(self, delay_factor: float = 1.0) -> None:
"""Handles special case scenarios for logins that might be encountered.
Special cases:
Mikrotik might prompt to read software licenses before displaying the initial prompt.
Mikrotik might also prompt for acknowledging no software key message if unlicensed.
Mikrotik might preset a "default config" screen.
Mikrotik might ask for a new password.
"""
no_license_message = 'Please press "Enter" to continue!'
license_prompt = "Do you want to see the software license"
new_password_promt = "new password>"
default_config_prompt = 'remove this default configuration type "r"'
combined_pattern = (
rf"(?:{self.prompt_pattern}|{no_license_message}|{license_prompt}|{new_password_promt}|{default_config_prompt})"
)
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)
for i in range(1,15):
if no_license_message in data:
# Handle "no license" message
self.write_channel(self.RETURN)
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)
elif license_prompt in data:
# Handle software license prompt
self.write_channel("n")
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)
elif default_config_prompt in data:
# Handle default config notice
self.write_channel("\n")
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)
elif new_password_promt in data:
# Handle new password request
self.write_channel('\x03')
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)
else: # must have matched the default promt
break
I put all those checks in a loop. So no matter in which order they occur, they should always be handled.
If no special case matches any more, we break out of that functions and are free to proceed.
Maybe those cases can be handled upstream. :)
Best regards
Steffen
Metadata
Metadata
Assignees
Labels
No labels