Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/dannywade/netmiko into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
dannywade committed Oct 17, 2023
2 parents fa0de55 + 2b7c36d commit f1d5fcb
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 2 deletions.
3 changes: 3 additions & 0 deletions PLATFORMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Huawei SmartAX
- IP Infusion OcNOS
- Juniper ScreenOS
- Maipu
- MikroTik RouterOS
- MikroTik SwitchOS
- NetApp cDOT
Expand Down Expand Up @@ -83,6 +84,7 @@
- Coriant
- Dell OS6
- Dell EMC Isilon
- Digi TransPort Routers
- Eltex
- Enterasys
- Endace
Expand Down Expand Up @@ -162,6 +164,7 @@
- dell_powerconnect
- dell_sonic
- dlink_ds
- digi_transport
- eltex
- eltex_esr
- endace
Expand Down
3 changes: 3 additions & 0 deletions netmiko/digi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from netmiko.digi.digi_transport import DigiTransportSSH

__all__ = ["DigiTransportSSH"]
27 changes: 27 additions & 0 deletions netmiko/digi/digi_transport.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions netmiko/hp/hp_comware.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def set_base_prompt(
pattern=pattern,
)

# Strip off any leading RBM_. characters for firewall HA
prompt = re.sub(r"^RBM_.", "", prompt, flags=re.M)

# Strip off leading character
prompt = prompt[1:]
prompt = prompt.strip()
Expand Down
4 changes: 4 additions & 0 deletions netmiko/maipu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from netmiko.maipu.maipu import MaipuSSH
from netmiko.maipu.maipu import MaipuTelnet

__all__ = ["MaipuSSH", "MaipuTelnet"]
35 changes: 35 additions & 0 deletions netmiko/maipu/maipu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import time

from netmiko.cisco_base_connection import CiscoBaseConnection


class MaipuBase(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()
self.enable()
self.disable_paging(command="more off")
# 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:
"""Saves Config Using Copy Run Start"""
return super().save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
)


class MaipuSSH(MaipuBase):
"""MAIPU SSH driver"""

pass


class MaipuTelnet(MaipuBase):
"""MAIPU telnet driver"""

pass
9 changes: 8 additions & 1 deletion netmiko/ssh_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -81,6 +82,7 @@
from netmiko.fiberstore import FiberstoreFsosSSH
from netmiko.flexvnf import FlexvnfSSH
from netmiko.fortinet import FortinetSSH
from netmiko.hillstone import HillstoneStoneosSSH
from netmiko.hp import HPProcurveSSH, HPProcurveTelnet, HPComwareSSH, HPComwareTelnet
from netmiko.huawei import HuaweiSSH, HuaweiVrpv8SSH, HuaweiTelnet
from netmiko.huawei import HuaweiSmartAXSSH
Expand All @@ -89,6 +91,8 @@
from netmiko.juniper import JuniperFileTransfer
from netmiko.keymile import KeymileSSH, KeymileNOSSSH
from netmiko.linux import LinuxSSH, LinuxFileTransfer
from netmiko.maipu import MaipuSSH
from netmiko.maipu import MaipuTelnet
from netmiko.mikrotik import MikrotikRouterOsSSH, MikrotikRouterOsFileTransfer
from netmiko.mikrotik import MikrotikSwitchOsSSH
from netmiko.mellanox import MellanoxMlnxosSSH
Expand Down Expand Up @@ -133,7 +137,7 @@
from netmiko.supermicro import SmciSwitchSmisSSH
from netmiko.supermicro import SmciSwitchSmisTelnet
from netmiko.zyxel import ZyxelSSH
from netmiko.hillstone import HillstoneStoneosSSH


if TYPE_CHECKING:
from netmiko.base_connection import BaseConnection
Expand Down Expand Up @@ -198,6 +202,7 @@
"dell_powerconnect": DellPowerConnectSSH,
"dell_isilon": DellIsilonSSH,
"dlink_ds": DlinkDSSSH,
"digi_transport": DigiTransportSSH,
"endace": EndaceSSH,
"eltex": EltexSSH,
"eltex_esr": EltexEsrSSH,
Expand Down Expand Up @@ -274,6 +279,7 @@
"zte_zxros": ZteZxrosSSH,
"yamaha": YamahaSSH,
"zyxel_os": ZyxelSSH,
"maipu": MaipuSSH,
}

FILE_TRANSFER_MAP = {
Expand Down Expand Up @@ -351,6 +357,7 @@
CLASS_MAPPER["tplink_jetstream_telnet"] = TPLinkJetStreamTelnet
CLASS_MAPPER["yamaha_telnet"] = YamahaTelnet
CLASS_MAPPER["zte_zxros_telnet"] = ZteZxrosTelnet
CLASS_MAPPER["maipu_telnet"] = MaipuTelnet

# Add serial drivers
CLASS_MAPPER["cisco_ios_serial"] = CiscoIosSerial
Expand Down
4 changes: 3 additions & 1 deletion netmiko/vyos/vyos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ def save_config(
self, cmd: str = "save", confirm: bool = False, confirm_response: str = ""
) -> str:
"""Saves Config."""
output = super().save_config(
output = self.config_mode()
output += super().save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
)
output += self.exit_config_mode()
if "Done" not in output:
raise ValueError(f"Save failed with following errors:\n\n{output}")
return output
32 changes: 32 additions & 0 deletions tests/etc/commands.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,37 @@ 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"
extended_output: "show running-config"
config:
- "logging buffer count 4096" # base command
- "no logging console"
- "logging source default console deny" # something you can verify has changed
config_verification: "show running-config | include logging"
save_config_cmd: 'write'
save_config_confirm: False
save_config_response: 'OK'

maipu_telnet:
version: "show version"
basic: "show ip interface brief"
extended_output: "show running-config"
config:
- "logging buffer count 4096" # base command
- "no logging console"
- "logging source default console deny" # something you can verify has changed
config_verification: "show running-config | include logging"
save_config_cmd: 'write'
save_config_confirm: False
save_config_response: 'OK'

hillstone_stoneos:
version: "show version"
basic: "show interface"
Expand All @@ -571,3 +602,4 @@ fiberstore_fsos:
- 'no logging console'
- 'logging buffered severity 3'
config_verification: "show run"

25 changes: 25 additions & 0 deletions tests/etc/responses.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,31 @@ 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>
enable_prompt: maipu_sw#
interface_ip: 11.11.11.11
version_banner: "Version Information"
multiple_line_output: ""
save_config: 'OK'

maipu_telnet:
base_prompt: maipu_sw
router_prompt : maipu_sw>
enable_prompt: maipu_sw#
interface_ip: 11.11.11.11
version_banner: "Version Information"
multiple_line_output: ""
save_config: 'OK'

hillstone:
base_prompt: SG-6000
router_prompt : SG-6000#
Expand Down
20 changes: 20 additions & 0 deletions tests/etc/test_devices.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,26 @@ 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
username: hxl
password: test123
secret: a

maipu_telnet:
device_type: maipu_telnet
ip: 129.255.27.1
username: hxl
password: test123
secret: a

hillstone:
device_type: hillstone_stoneos
ip: 192.168.100.234
Expand Down

0 comments on commit f1d5fcb

Please sign in to comment.