Skip to content

Commit

Permalink
Updates to Adtran fallback authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Oct 26, 2023
1 parent 0d6d146 commit fad3c63
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions netmiko/adtran/adtran.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def enable(
self,
cmd: str = "enable",
pattern: str = "ssword",
enable_pattern: Optional[str] = "Falling back",
enable_pattern: Optional[str] = None,
check_state: bool = True,
re_flags: int = re.IGNORECASE,
) -> str:
Expand Down Expand Up @@ -57,15 +57,21 @@ def enable(
# Send the "secret" in response to password pattern
if re.search(pattern, output):
self.write_channel(self.normalize_cmd(self.secret))
output += self.read_until_prompt_or_pattern(
pattern=str(enable_pattern), re_flags=re_flags

# Handle the fallback to local authentication case
fallback_pattern = r"Falling back"
new_output = self.read_until_prompt_or_pattern(
pattern=fallback_pattern, re_flags=re_flags
)
output += new_output

if "Falling back" in new_output:
self.write_channel(self.normalize_cmd(self.secret))
output += self.read_until_prompt()

# Search for terminating pattern if defined
if enable_pattern and re.search(enable_pattern, output):
# Added 2nd attempt in case of fallback to local Authentication
self.write_channel(self.normalize_cmd(self.secret))
output += self.read_until_prompt()
if enable_pattern and not re.search(enable_pattern, output):
output += self.read_until_pattern(pattern=enable_pattern)
else:
if not self.check_enable_mode():
raise ValueError(msg)
Expand Down

0 comments on commit fad3c63

Please sign in to comment.