From f2b84ace8ab83d16a840049b4252020dcbc67b17 Mon Sep 17 00:00:00 2001 From: Jeroen Bosch Date: Fri, 29 Nov 2024 14:47:53 +0100 Subject: [PATCH 1/2] Adding support for corvil --- netmiko/corvil/__init__.py | 5 ++++ netmiko/corvil/corvilcne_ssh.py | 45 +++++++++++++++++++++++++++++++++ netmiko/ssh_dispatcher.py | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 netmiko/corvil/__init__.py create mode 100644 netmiko/corvil/corvilcne_ssh.py diff --git a/netmiko/corvil/__init__.py b/netmiko/corvil/__init__.py new file mode 100644 index 000000000..2bee71e21 --- /dev/null +++ b/netmiko/corvil/__init__.py @@ -0,0 +1,5 @@ +from netmiko.corvil.corvilcne_ssh import CorvilCNESSH + +__all__ = [ + "CorvilCNESSH" +] diff --git a/netmiko/corvil/corvilcne_ssh.py b/netmiko/corvil/corvilcne_ssh.py new file mode 100644 index 000000000..118978d61 --- /dev/null +++ b/netmiko/corvil/corvilcne_ssh.py @@ -0,0 +1,45 @@ +""" +Corvil CNE support. + +For use with Corvil CNE devices. + +""" +from typing import Any +from netmiko.cisco_base_connection import CiscoSSHConnection + + +class CorvilCNESSH(CiscoSSHConnection): + """Corvil CNE support""" + + def __init__(self, **kwargs: Any) -> None: + if kwargs.get("default_enter") is None: + kwargs["default_enter"] = "\r" + return super().__init__(**kwargs) + + def session_preparation(self) -> None: + self.ansi_escape_codes = True + self._test_channel_read(pattern="$") + self.disable_paging(command="terminal length 0") + + def check_config_mode( + self, + check_string: str = "(config) $", + pattern: str = r"[$]", + force_regex: bool = False, + ) -> bool: + """ + Checks if the device is in configuration mode or not. + + Corvil uses "(config) $" as config prompt + """ + return super().check_config_mode(check_string=check_string, pattern=pattern) + + def config_mode( + self, + config_command: str = "config", + pattern: str = "", + re_flags: int = 0, + ) -> str: + return super().config_mode( + config_command=config_command, pattern=pattern, re_flags=re_flags + ) diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 70be1f5b2..13d778493 100755 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -52,6 +52,7 @@ from netmiko.citrix import NetscalerSSH from netmiko.cloudgenix import CloudGenixIonSSH from netmiko.coriant import CoriantSSH +from netmiko.corvil import CorvilCNESSH from netmiko.dell import DellDNOS6SSH from netmiko.dell import DellDNOS6Telnet from netmiko.dell import DellForce10SSH @@ -202,6 +203,7 @@ "cisco_xr": CiscoXrSSH, "cloudgenix_ion": CloudGenixIonSSH, "coriant": CoriantSSH, + "corvil_cne": CorvilCNESSH, "dell_dnos9": DellForce10SSH, "dell_force10": DellForce10SSH, "dell_os6": DellDNOS6SSH, From 64feaa1fc5d1fab353743a962c85d51fefd735b4 Mon Sep 17 00:00:00 2001 From: Jeroen Bosch Date: Fri, 29 Nov 2024 16:34:29 +0100 Subject: [PATCH 2/2] Adding support for gigamon --- netmiko/gigamon/__init__.py | 5 ++++ netmiko/gigamon/gigamonvue_ssh.py | 45 +++++++++++++++++++++++++++++++ netmiko/ssh_dispatcher.py | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 netmiko/gigamon/__init__.py create mode 100644 netmiko/gigamon/gigamonvue_ssh.py diff --git a/netmiko/gigamon/__init__.py b/netmiko/gigamon/__init__.py new file mode 100644 index 000000000..57e342180 --- /dev/null +++ b/netmiko/gigamon/__init__.py @@ -0,0 +1,5 @@ +from netmiko.gigamon.gigamonvue_ssh import GigamonVUESSH + +__all__ = [ + "GigamonVUESSH" +] diff --git a/netmiko/gigamon/gigamonvue_ssh.py b/netmiko/gigamon/gigamonvue_ssh.py new file mode 100644 index 000000000..361522186 --- /dev/null +++ b/netmiko/gigamon/gigamonvue_ssh.py @@ -0,0 +1,45 @@ +""" +Gigamon GigaVUE support. + +For use with Gigamon GigaVUE devices. + +""" +from typing import Any +from netmiko.cisco_base_connection import CiscoSSHConnection + + +class GigamonVUESSH(CiscoSSHConnection): + """Gigamon GigaVUE support""" + + def __init__(self, **kwargs: Any) -> None: + if kwargs.get("default_enter") is None: + kwargs["default_enter"] = "\r" + return super().__init__(**kwargs) + + def session_preparation(self) -> None: + self.ansi_escape_codes = True + self.set_base_prompt() + self.disable_paging(command="no cli session paging enable") + + def check_config_mode( + self, + check_string: str = "(config) #", + pattern: str = r"[>#]", + force_regex: bool = False, + ) -> bool: + """ + Checks if the device is in configuration mode or not. + + Perle uses "() (config) #" as config prompt + """ + return super().check_config_mode(check_string=check_string, pattern=pattern) + + def config_mode( + self, + config_command: str = "configure terminal", + pattern: str = "", + re_flags: int = 0, + ) -> str: + return super().config_mode( + config_command=config_command, pattern=pattern, re_flags=re_flags + ) diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 13d778493..76922f3c9 100755 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -86,6 +86,7 @@ from netmiko.fiberstore import FiberstoreFsosSSH from netmiko.flexvnf import FlexvnfSSH from netmiko.fortinet import FortinetSSH +from netmiko.gigamon import GigamonVUESSH from netmiko.garderos import GarderosGrsSSH from netmiko.hillstone import HillstoneStoneosSSH from netmiko.hp import HPProcurveSSH, HPProcurveTelnet, HPComwareSSH, HPComwareTelnet @@ -240,6 +241,7 @@ "garderos_grs": GarderosGrsSSH, "generic": GenericSSH, "generic_termserver": TerminalServerSSH, + "gigamon_gigavue": GigamonVUESSH, "hillstone_stoneos": HillstoneStoneosSSH, "hp_comware": HPComwareSSH, "hp_procurve": HPProcurveSSH,