Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adva driver fixes #3595

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update adva_aos_fsp_150_f2.py
  • Loading branch information
Gatorjosh14 authored Feb 21, 2025
commit 4bf48ea4b3317a424eea83b69fd5bb0e3650713b
36 changes: 30 additions & 6 deletions netmiko/adva/adva_aos_fsp_150_f2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AdvaAosFsp150F2SSH(NoEnable, NoConfig, CiscoSSHConnection):
Unrecognized command
"""

def __init__(self, **kwargs: Any) -> None:
def __init__(self, **kwargs: Any) -> None:
"""
\n for default enter causes some issues with the Adva so setting to \r.
"""
Expand All @@ -56,15 +56,39 @@ def session_preparation(self) -> None:

def set_base_prompt(
self,
pri_prompt_terminator: str = r"(^.+?)-->$",
pri_prompt_terminator: str = r"-->",
alt_prompt_terminator: str = "",
delay_factor: float = 1.0,
pattern: Optional[str] = None,
) -> str:
if pattern is None:
if pri_prompt_terminator and alt_prompt_terminator:
pri_term = re.escape(pri_prompt_terminator)
alt_term = re.escape(alt_prompt_terminator)
pattern = rf"({pri_term}|{alt_term})"
elif pri_prompt_terminator:
pattern = re.escape(pri_prompt_terminator)
elif alt_prompt_terminator:
pattern = re.escape(alt_prompt_terminator)

prompt = self.find_prompt()
match = re.search(pri_prompt_terminator, prompt)
if not match:
if pattern:
prompt = self.find_prompt(delay_factor=delay_factor, pattern=pattern)
else:
prompt = self.find_prompt(delay_factor=delay_factor)

if not prompt[-3:] in (pri_prompt_terminator, alt_prompt_terminator):
raise ValueError(f"Router prompt not found: {repr(prompt)}")
self.base_prompt = match[1]

# If all we have is the 'terminator' just use that :-(
if len(prompt) == 1:
self.base_prompt = prompt
else:
# Strip off trailing terminator
self.base_prompt = prompt[-3:]
return self.base_prompt

def cleanup(self, command: str = "logout") -> None:
"""Gracefully exit the SSH session."""
return super().cleanup(
command=command
)
Loading