diff --git a/PLATFORMS.md b/PLATFORMS.md index 3ccd72c19..207f19b0a 100644 --- a/PLATFORMS.md +++ b/PLATFORMS.md @@ -113,6 +113,7 @@ - Fortinet - Garderos GRS - Genexis Saturn SOLT33 (telnet only) +- Hirschmann HiOS - Lancom LCOS SX4 - Moxa EDS - MRV Communications OptiSwitch @@ -233,6 +234,7 @@ - generic_termserver - h3c_comware - hillstone_stoneos +- hirschmann_hios - hp_comware - hp_procurve - huawei diff --git a/netmiko/hirschmann/__init__.py b/netmiko/hirschmann/__init__.py new file mode 100644 index 000000000..a4df0f6f3 --- /dev/null +++ b/netmiko/hirschmann/__init__.py @@ -0,0 +1,3 @@ +from netmiko.hirschmann.hirschmann_hios import HirschmannHiOSSSH + +__all__ = ["HirschmannHiOSSSH"] diff --git a/netmiko/hirschmann/hirschmann_hios.py b/netmiko/hirschmann/hirschmann_hios.py new file mode 100644 index 000000000..9783c8f4c --- /dev/null +++ b/netmiko/hirschmann/hirschmann_hios.py @@ -0,0 +1,29 @@ +""" +Tested with Hirschmann BRS20 (Bobcat Rail Switch) running HiOS. +""" + +from netmiko.cisco_base_connection import CiscoBaseConnection + + +class HirschmannHiOSBase(CiscoBaseConnection): + """Base class for Hirschmann HiOS devices.""" + + def session_preparation(self) -> None: + """Prepare the session after the connection has been established.""" + self._test_channel_read(pattern=r"[>#]") + self.set_base_prompt() + self.disable_paging(command="cli numlines 0") + + def save_config( + self, cmd: str = "save", confirm: bool = False, confirm_response: str = "" + ) -> str: + """Save the configuration.""" + return super().save_config( + cmd=cmd, confirm=confirm, confirm_response=confirm_response + ) + + +class HirschmannHiOSSSH(HirschmannHiOSBase): + """Hirschmann HiOS SSH driver.""" + + pass diff --git a/netmiko/snmp_autodetect.py b/netmiko/snmp_autodetect.py index ec42bed3c..dbfab006a 100644 --- a/netmiko/snmp_autodetect.py +++ b/netmiko/snmp_autodetect.py @@ -133,6 +133,11 @@ "expr": re.compile(r".*RouterOS.*", re.IGNORECASE), "priority": 60, }, + "hirschmann_hios": { + "oid": ".1.3.6.1.2.1.1.1.0", + "expr": re.compile(r".*Hirschmann BOBCAT.*"), + "priority": 60, + }, } # Ensure all SNMP device types are supported by Netmiko diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py index ec51b84aa..b369819bb 100644 --- a/netmiko/ssh_autodetect.py +++ b/netmiko/ssh_autodetect.py @@ -207,6 +207,13 @@ "priority": 99, "dispatch": "_autodetect_std", }, + "hirschmann_hios": { + "cmd": "", + "search_patterns": [r"Release HiOS-"], + "re_flags": 0, + "priority": 99, + "dispatch": "_autodetect_login_banner", + }, "hp_comware": { "cmd": "display version", "search_patterns": ["HPE Comware", "HP Comware"], @@ -574,6 +581,35 @@ def _autodetect_remote_version( return 0 return 0 + def _autodetect_login_banner( + self, + search_patterns: Optional[List[str]] = None, + re_flags: int = re.IGNORECASE, + priority: int = 99, + **kwargs: Any + ) -> int: + """ + Method to try auto-detect the device type, by matching a regular expression on the + login banner. + + Parameters + ---------- + search_patterns : list + A list of regular expression to look for in the login banner (default: None). + re_flags: re.flags, optional + Any flags from the python re module to modify the regular expression + (default: re.IGNORECASE). + priority: int, optional + The confidence the match is right between 0 and 99 (default: 99). + """ + if not search_patterns: + return 0 + for pattern in search_patterns: + match = re.search(pattern, self.initial_buffer, flags=re_flags) + if match: + return priority + return 0 + def _autodetect_std( self, cmd: str = "", diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 294ed5db6..458920d48 100644 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -106,6 +106,7 @@ from netmiko.garderos import GarderosGrsSSH from netmiko.genexis import GenexisSOLT33Telnet from netmiko.hillstone import HillstoneStoneosSSH +from netmiko.hirschmann.hirschmann_hios import HirschmannHiOSSSH from netmiko.hp import HPProcurveSSH, HPProcurveTelnet, HPComwareSSH, HPComwareTelnet from netmiko.huawei import HuaweiSSH, HuaweiVrpv8SSH, HuaweiTelnet from netmiko.huawei import HuaweiSmartAXSSH, HuaweiSmartAXSSHMMI @@ -279,6 +280,7 @@ "generic_termserver": TerminalServerSSH, "h3c_comware": HPComwareSSH, "hillstone_stoneos": HillstoneStoneosSSH, + "hirschmann_hios": HirschmannHiOSSSH, "hp_comware": HPComwareSSH, "hp_procurve": HPProcurveSSH, "huawei": HuaweiSSH,