Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion netmiko/lancom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from netmiko.lancom.lancom_lcossx4 import LancomLCOSSX4SSH
from netmiko.lancom.lancom_lcossx5 import LancomLCOSSX5SSH

__all__ = ["LancomLCOSSX4SSH"]
__all__ = ["LancomLCOSSX4SSH", "LancomLCOSSX5SSH"]
87 changes: 87 additions & 0 deletions netmiko/lancom/lancom_lcossx5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from netmiko.cisco_base_connection import CiscoSSHConnection


class LancomLCOSSX5SSH(CiscoSSHConnection):
def session_preparation(self) -> None:
"""
Prepare the session after the connection has been established.

The connection will enter `Privileged EXEC` by default, as the `EXEC` mode
offers inconsistent command options
"""
self._test_channel_read()
self.enable(enable_pattern=r"#")
super().set_base_prompt()
super().disable_paging()
self.clear_buffer()

def check_config_mode(
self,
check_string: str = "(Config)#",
pattern: str = "#",
force_regex: bool = False,
) -> bool:
"""
Checks if the device is in configuration mode or not.

:param check_string: Identification of configuration mode from the device
:type check_string: str

:param pattern: Pattern to terminate reading of channel
:type pattern: str

:param force_regex: Use regular expression pattern to find check_string in output
:type force_regex: bool

:return: True if in configuration mode, False if not
"""
return super().check_config_mode(
check_string=check_string, pattern=pattern, force_regex=force_regex
)

def exit_enable_mode(self, exit_command: str = "end") -> str:
"""Exits enable (privileged exec) mode."""
return super().exit_enable_mode(exit_command=exit_command)

def cleanup(self, command: str = "logout") -> None:
"""
Cleanup / Gracefully exit the SSH session

:param command: LANCOM LCOS SX 5.x uses logout to exit the session
:type command: str
"""
# LANCOM does not allow running "Exec" commands in configuration mode
if self.check_config_mode():
command = "do " + command
return super().cleanup(command)

def save_config(
self,
cmd: str = "write memory confirm",
confirm: bool = False,
confirm_response: str = "y",
) -> str:
"""
Save the running Config.

:param cmd: The command to send to the device to save the configuration
:type cmd: str

:param confirm: Whether to confirm the save or not
:type confirm: bool

:param confirm_response: The response to send to the device to confirm the save
:type confirm_response: str

:param output_pattern: The pattern to match the output of the save command
:type output_pattern: str
"""

# LANCOM does not allow running "Exec" commands in configuration mode
if self.check_config_mode():
cmd = "do " + cmd
return super().save_config(
cmd=cmd,
confirm=confirm,
confirm_response=confirm_response,
)
3 changes: 2 additions & 1 deletion netmiko/ssh_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
from netmiko.juniper import JuniperSSH, JuniperTelnet, JuniperScreenOsSSH
from netmiko.juniper import JuniperFileTransfer
from netmiko.keymile import KeymileSSH, KeymileNOSSSH
from netmiko.lancom import LancomLCOSSX4SSH
from netmiko.lancom import LancomLCOSSX4SSH, LancomLCOSSX5SSH
from netmiko.linux import LinuxSSH, LinuxFileTransfer
from netmiko.maipu import MaipuSSH
from netmiko.maipu import MaipuTelnet
Expand Down Expand Up @@ -294,6 +294,7 @@
"keymile": KeymileSSH,
"keymile_nos": KeymileNOSSSH,
"lancom_lcossx4": LancomLCOSSX4SSH,
"lancom_lcossx5": LancomLCOSSX5SSH,
"linux": LinuxSSH,
"mikrotik_routeros": MikrotikRouterOsSSH,
"mikrotik_switchos": MikrotikSwitchOsSSH,
Expand Down