-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Nokia isam #3725
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
base: develop
Are you sure you want to change the base?
Nokia isam #3725
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import time | ||
import re | ||
from typing import Any | ||
|
||
from netmiko.base_connection import BaseConnection | ||
from netmiko.no_enable import NoEnable | ||
|
||
|
||
class NokiaIsamSSH(BaseConnection, NoEnable): | ||
|
||
def session_preparation(self) -> None: | ||
self._test_channel_read() | ||
self.set_base_prompt() | ||
commands = [ | ||
"environment inhibit-alarms", | ||
"environment screen-length 0", | ||
] | ||
for command in commands: | ||
self.disable_paging(command=command, cmd_verify=True, pattern=r"#") | ||
time.sleep(0.3 * self.global_delay_factor) | ||
self.clear_buffer() | ||
|
||
def set_base_prompt(self, *args: Any, **kwargs: Any) -> str: | ||
"""Remove the > when navigating into the different config level.""" | ||
cur_base_prompt = super().set_base_prompt(*args, **kwargs) | ||
match = re.search(r"\*?(.*?)(>.*)*#", cur_base_prompt) | ||
if match: | ||
# strip off >... from base_prompt; strip off leading * | ||
self.base_prompt: str = match.group(1) | ||
|
||
return self.base_prompt | ||
|
||
def cleanup(self, command: str = "logout") -> None: | ||
"""Gracefully exit the SSH session.""" | ||
try: | ||
if self.check_config_mode(): | ||
self.exit_config_mode() | ||
except Exception: | ||
pass | ||
# Always try to send final command | ||
if self.session_log: | ||
self.session_log.fin = True | ||
self.write_channel(command + self.RETURN) | ||
|
||
def check_config_mode( | ||
self, | ||
check_string: str = "configure#", | ||
pattern: str = "", | ||
force_regex: bool = False, | ||
) -> bool: | ||
"""Use equivalent enable method.""" | ||
return super().check_config_mode(check_string=check_string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this right? It seems inconsistent with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default promp is name># and when you go into config mode it becomes name>configure# There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what happens when to the prompt when you traverse down the configuration tree? I am having a lot of trouble finding documentation on this platform, but it looks to me like it does something like:
Note, I definitely could be wrong given the difficult obtaining documentation on this platform. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Noppes Any update on my question here? |
||
|
||
def config_mode( | ||
self, config_command: str = "configure", pattern: str = "", re_flags: int = 0 | ||
) -> str: | ||
return super().config_mode( | ||
config_command=config_command, pattern=pattern, re_flags=re_flags | ||
) | ||
|
||
def exit_config_mode(self, exit_config: str = "exit", pattern: str = "") -> str: | ||
return super().exit_config_mode(exit_config=exit_config) | ||
|
||
def save_config( | ||
self, cmd: str = "admin save", confirm: bool = False, confirm_response: str = "" | ||
) -> str: | ||
return self._send_command_str( | ||
command_string=cmd, | ||
strip_prompt=False, | ||
strip_command=False, | ||
) |
Uh oh!
There was an error while loading. Please reload this page.