-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e6c4d5
commit a06778a
Showing
3 changed files
with
51 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
from netmiko.fs.fs_os import FSOSSSH, FSOSTelnet | ||
|
||
__all__ = ["FSOSSSH", "FSOSTelnet"] |
This file contains 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,39 @@ | ||
"""FS Support""" | ||
import time | ||
from typing import Any | ||
|
||
from netmiko.cisco_base_connection import CiscoBaseConnection | ||
|
||
|
||
class FSOSBase(CiscoBaseConnection): | ||
def session_preparation(self) -> None: | ||
"""Prepare the session after the connection has been established.""" | ||
self._test_channel_read(pattern=r"[>#]") | ||
self.set_base_prompt() | ||
"""FS OS requires enable mode to set terminal width""" | ||
self.enable() | ||
self.set_terminal_width(command="terminal width 256", pattern="terminal") | ||
self.disable_paging(command="terminal length 0") | ||
# Clear the read buffer | ||
time.sleep(0.3 * self.global_delay_factor) | ||
self.clear_buffer() | ||
|
||
def save_config( | ||
self, cmd: str = "write", confirm: bool = False, confirm_response: str = "" | ||
) -> str: | ||
"""Save config: write""" | ||
return super().save_config( | ||
cmd=cmd, confirm=confirm, confirm_response=confirm_response | ||
) | ||
|
||
|
||
class FSOSSSH(FSOSBase): | ||
|
||
pass | ||
|
||
|
||
class FSOSTelnet(FSOSBase): | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
default_enter = kwargs.get("default_enter") | ||
kwargs["default_enter"] = "\r\n" if default_enter is None else default_enter | ||
super().__init__(*args, **kwargs) |
This file contains 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