-
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
Merged
Merged
Nokia isam #3725
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b762019
nokia isam driver
Noppes 33603f0
Merge branch 'develop' into nokia_isam
Noppes d63b51c
error fix
Noppes 681fa12
nokia isam cleanup improvement
Noppes f88faba
Merge branch 'develop' into nokia_isam
ktbyers 1a32dba
nokia isam check_config_mode improvement
Noppes 097d9e5
Merge branch 'develop' into nokia_isam
ktbyers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| 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, pattern=pattern, force_regex=force_regex | ||
| ) | ||
|
|
||
| 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, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.