From bf7a492c84ae81d865c0c17aa88d7c9256a50c62 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 17 Oct 2023 13:18:35 -0700 Subject: [PATCH] Add Digi TransPort Router Support (#3310) Co-authored-by: tbotnz --- PLATFORMS.md | 3 +++ netmiko/digi/__init__.py | 3 +++ netmiko/digi/digi_transport.py | 27 +++++++++++++++++++++++++++ netmiko/ssh_dispatcher.py | 2 ++ tests/etc/commands.yml.example | 6 ++++++ tests/etc/responses.yml.example | 7 +++++++ tests/etc/test_devices.yml.example | 6 ++++++ 7 files changed, 54 insertions(+) create mode 100644 netmiko/digi/__init__.py create mode 100644 netmiko/digi/digi_transport.py diff --git a/PLATFORMS.md b/PLATFORMS.md index ef6dd9080..6f54ad0ac 100644 --- a/PLATFORMS.md +++ b/PLATFORMS.md @@ -47,6 +47,7 @@ - Huawei SmartAX - IP Infusion OcNOS - Juniper ScreenOS +- Maipu - MikroTik RouterOS - MikroTik SwitchOS - NetApp cDOT @@ -83,6 +84,7 @@ - Coriant - Dell OS6 - Dell EMC Isilon +- Digi TransPort Routers - Eltex - Enterasys - Endace @@ -162,6 +164,7 @@ - dell_powerconnect - dell_sonic - dlink_ds +- digi_transport - eltex - eltex_esr - endace diff --git a/netmiko/digi/__init__.py b/netmiko/digi/__init__.py new file mode 100644 index 000000000..cc4236d41 --- /dev/null +++ b/netmiko/digi/__init__.py @@ -0,0 +1,3 @@ +from netmiko.digi.digi_transport import DigiTransportSSH + +__all__ = ["DigiTransportSSH"] diff --git a/netmiko/digi/digi_transport.py b/netmiko/digi/digi_transport.py new file mode 100644 index 000000000..0aa832bf8 --- /dev/null +++ b/netmiko/digi/digi_transport.py @@ -0,0 +1,27 @@ +"""Digi TransPort Routers""" +from typing import Any +from netmiko.no_enable import NoEnable +from netmiko.no_config import NoConfig +from netmiko.cisco_base_connection import CiscoSSHConnection + + +class DigiTransportBase(NoEnable, NoConfig, CiscoSSHConnection): + 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) + + def save_config( + self, + cmd: str = "config 0 save", + confirm: bool = False, + confirm_response: str = "", + ) -> str: + output = self._send_command_str( + command_string=cmd, expect_string="Please wait..." + ) + return output + + +class DigiTransportSSH(DigiTransportBase): + pass diff --git a/netmiko/ssh_dispatcher.py b/netmiko/ssh_dispatcher.py index 94bfe0dcd..31ba526a8 100755 --- a/netmiko/ssh_dispatcher.py +++ b/netmiko/ssh_dispatcher.py @@ -57,6 +57,7 @@ from netmiko.dell import DellPowerConnectSSH from netmiko.dell import DellPowerConnectTelnet from netmiko.dell import DellIsilonSSH +from netmiko.digi import DigiTransportSSH from netmiko.dlink import DlinkDSTelnet, DlinkDSSSH from netmiko.eltex import EltexSSH, EltexEsrSSH from netmiko.endace import EndaceSSH @@ -201,6 +202,7 @@ "dell_powerconnect": DellPowerConnectSSH, "dell_isilon": DellIsilonSSH, "dlink_ds": DlinkDSSSH, + "digi_transport": DigiTransportSSH, "endace": EndaceSSH, "eltex": EltexSSH, "eltex_esr": EltexEsrSSH, diff --git a/tests/etc/commands.yml.example b/tests/etc/commands.yml.example index 5a6cf11bd..cce5934be 100644 --- a/tests/etc/commands.yml.example +++ b/tests/etc/commands.yml.example @@ -550,6 +550,11 @@ audiocode_shell: save_config_response: 'Configuration has been saved' config_mode_command: "conf" # only use if needed +digi_transport: + version: "type version" + basic: "type config.da0" + extended_output: "type version all" + maipu: version: "show version" basic: "show ip interface brief" @@ -597,3 +602,4 @@ fiberstore_fsos: - 'no logging console' - 'logging buffered severity 3' config_verification: "show run" + diff --git a/tests/etc/responses.yml.example b/tests/etc/responses.yml.example index 7edaf7f77..6c9503c04 100644 --- a/tests/etc/responses.yml.example +++ b/tests/etc/responses.yml.example @@ -397,6 +397,13 @@ audiocode_shell: cmd_response_init: "Test_String1" cmd_response_final: "Test_String2" +digi_transport: + base_prompt: "digi>" + router_prompt: "digi>" + enable_prompt: "digi#" + interface_ip: 192.168.1.33 + version_banner: "Ci Version" + maipu: base_prompt: maipu_sw router_prompt : maipu_sw> diff --git a/tests/etc/test_devices.yml.example b/tests/etc/test_devices.yml.example index 9ad5a3790..5d3b34ad8 100644 --- a/tests/etc/test_devices.yml.example +++ b/tests/etc/test_devices.yml.example @@ -290,6 +290,12 @@ audiocode_shell: username: TestUser password: TestPass +digi_transport: + device_type: digi_transport + ip: 192.168.1.33 + username: bob + password: bob + maipu: device_type: maipu ip: 129.255.27.1