Skip to content

Commit

Permalink
Supermicro Driver (#2231)
Browse files Browse the repository at this point in the history
Co-authored-by: sandyw777 <[email protected]>
Co-authored-by: puffc <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2021
1 parent 353db2d commit 5854897
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 2 deletions.
1 change: 1 addition & 0 deletions PLATFORMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- Pluribus
- Ruckus ICX/FastIron
- Ruijie Networks
- Supermicro SMIS
- TPLink JetStream
- Ubiquiti EdgeSwitch
- Vyatta VyOS
Expand Down
6 changes: 6 additions & 0 deletions netmiko/ssh_autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@
"priority": 99,
"dispatch": "_autodetect_std",
},
"supermicro_smis": {
"cmd": "show system info",
"search_patterns": [r"Super Micro Computer"],
"priority": 99,
"dispatch": "_autodetect_std",
},
}

# Sort SSH_MAPPER_BASE such that the most common commands are first
Expand Down
8 changes: 6 additions & 2 deletions netmiko/ssh_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
from netmiko.yamaha import YamahaTelnet
from netmiko.zte import ZteZxrosSSH
from netmiko.zte import ZteZxrosTelnet
from netmiko.supermicro import SmciSwitchSmisSSH
from netmiko.supermicro import SmciSwitchSmisTelnet

GenericSSH = TerminalServerSSH
GenericTelnet = TerminalServerTelnet
Expand Down Expand Up @@ -204,6 +206,7 @@
"ruijie_os": RuijieOSSSH,
"sixwind_os": SixwindOSSSH,
"sophos_sfos": SophosSfosSSH,
"supermicro_smis": SmciSwitchSmisSSH,
"tplink_jetstream": TPLinkJetStreamSSH,
"ubiquiti_edge": UbiquitiEdgeSSH,
"ubiquiti_edgerouter": UbiquitiEdgeRouterSSH,
Expand Down Expand Up @@ -271,16 +274,17 @@
CLASS_MAPPER["huawei_olt_telnet"] = HuaweiSmartAXSSH
CLASS_MAPPER["ipinfusion_ocnos_telnet"] = IpInfusionOcNOSTelnet
CLASS_MAPPER["juniper_junos_telnet"] = JuniperTelnet
CLASS_MAPPER["paloalto_panos_telnet"] = PaloAltoPanosTelnet
CLASS_MAPPER["nokia_sros_telnet"] = NokiaSrosTelnet
CLASS_MAPPER["oneaccess_oneos_telnet"] = OneaccessOneOSTelnet
CLASS_MAPPER["paloalto_panos_telnet"] = PaloAltoPanosTelnet
CLASS_MAPPER["rad_etx_telnet"] = RadETXTelnet
CLASS_MAPPER["raisecom_telnet"] = RaisecomRoapTelnet
CLASS_MAPPER["ruckus_fastiron_telnet"] = RuckusFastironTelnet
CLASS_MAPPER["ruijie_os_telnet"] = RuijieOSTelnet
CLASS_MAPPER["supermicro_smis_telnet"] = SmciSwitchSmisTelnet
CLASS_MAPPER["tplink_jetstream_telnet"] = TPLinkJetStreamTelnet
CLASS_MAPPER["yamaha_telnet"] = YamahaTelnet
CLASS_MAPPER["zte_zxros_telnet"] = ZteZxrosTelnet
CLASS_MAPPER["nokia_sros_telnet"] = NokiaSrosTelnet

# Add serial drivers
CLASS_MAPPER["cisco_ios_serial"] = CiscoIosSerial
Expand Down
3 changes: 3 additions & 0 deletions netmiko/supermicro/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from netmiko.supermicro.smci_smis import SmciSwitchSmisTelnet, SmciSwitchSmisSSH

__all__ = ["SmciSwitchSmisSSH", "SmciSwitchSmisTelnet"]
44 changes: 44 additions & 0 deletions netmiko/supermicro/smci_smis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from netmiko.cisco_base_connection import CiscoBaseConnection
import time


class SmciSwitchSmisBase(CiscoBaseConnection):
def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read(pattern=r"[>#]")
self.set_base_prompt()
self.config_mode()
self.disable_paging(command="set cli pagination off")
self.set_terminal_width(command="terminal width 511")
self.exit_config_mode()
# Clear the read buffer
time.sleep(0.3 * self.global_delay_factor)
self.clear_buffer()

def check_enable_mode(self, check_string="#"):
"""Check if in enable mode. Return boolean."""
return super().check_enable_mode(check_string=check_string)

def enable(self, *args, **kwargs):
"""Supermicro switch does not support enable-mode command"""
return ""

def exit_enable_mode(self, *args, **kwargs):
"""Supermicro switch does not support enable-mode command"""
return ""

def save_config(
self, cmd="write startup-config", confirm=False, confirm_response=""
):
"""Save config"""
return super().save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
)


class SmciSwitchSmisSSH(SmciSwitchSmisBase):
pass


class SmciSwitchSmisTelnet(SmciSwitchSmisBase):
pass
13 changes: 13 additions & 0 deletions tests/etc/commands.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,19 @@ centec_os:
save_config_cmd: 'write'
save_config_response: 'OK'

supermicro_nos:
version: "show version"
basic: "show ip interface"
extended_output: "show version"
config:
- "logging buffered 110"
- "logging buffered 110"
config_verification: "show run"
save_config_cmd: "write startup-config"
save_config_confirm: False
save_config_response: '[OK]'
support_commit: False

sophos_sfos:
version: "system diagnostics show version-info"
basic: "system diagnostics utilities route lookup 172.16.16.16"
Expand Down
11 changes: 11 additions & 0 deletions tests/etc/responses.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ centec_os:
version_banner: "Centec Networks"
multiple_line_output: ""

supermicro_nos:
base_prompt: SMIS
router_prompt: SMIS>
enable_prompt: SMIS#
interface_ip: 192.168.10.15
version_banner: "Firmware Version"
multiple_line_output: ""
save_config: '[OK]'
cmd_response_init: "logging buffered 110"
cmd_response_final: "logging buffered 110"

sophos_sfos:
base_prompt: "console"
router_prompt: "console>"
Expand Down
6 changes: 6 additions & 0 deletions tests/etc/test_devices.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ centec_os:
password: centec
secret: centec

supermicro_nos:
device_type: supermicro_nos
ip: 192.168.10.15
username: ADMIN
password: ADMIN

sophos_sfos:
device_type: sophos_sfos
ip: 172.16.16.16
Expand Down
11 changes: 11 additions & 0 deletions tests/test_supermicro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

RETURN_CODE=0

# Exit on the first test failure and set RETURN_CODE = 1
echo "Starting tests...good luck:" \
&& py.test -v test_netmiko_show.py --test_device supermicro_nos \
&& py.test -v test_netmiko_config.py --test_device supermicro_nos \
|| RETURN_CODE=1

exit $RETURN_CODE

0 comments on commit 5854897

Please sign in to comment.