Skip to content

Commit

Permalink
Merge branch 'hillstone' of https://github.com/Linn15/netmiko into hi…
Browse files Browse the repository at this point in the history
…llstone
  • Loading branch information
ktbyers committed Jan 13, 2023
2 parents 1db1ca5 + d940858 commit 9ab333c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions netmiko/hillstone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from netmiko.hillstone.hillstone import hillstoneSSH

__all__ = ["hillstoneSSH"]
46 changes: 46 additions & 0 deletions netmiko/hillstone/hillstone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import time
from netmiko.no_enable import NoEnable
from netmiko.cisco_base_connection import CiscoBaseConnection


class hillstoneBase(NoEnable,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="terminal length 0")
# Clear the read buffer
time.sleep(0.3 * self.global_delay_factor)
self.clear_buffer()

def config_mode(
self,
config_command: str = "configure",
pattern: str = "",
re_flags: int = 0,
) -> str:
"""Enter configuration mode."""
return super().config_mode(
config_command=config_command, pattern=pattern, re_flags=re_flags
)

def check_config_mode(
self, check_string: str = ")#", pattern: str = "#", force_regex: bool = False
) -> bool:
"""
Checks if the device is in configuration mode or not.
"""
return super().check_config_mode(check_string=check_string, pattern=pattern)

def save_config(
self, cmd: str = "save all", confirm: bool = True, confirm_response: str = "y"
) -> str:
"""Saves Config Using Copy Run Start"""
return super().save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
)


class hillstoneSSH(hillstoneBase):
pass
2 changes: 2 additions & 0 deletions netmiko/ssh_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
from netmiko.supermicro import SmciSwitchSmisSSH
from netmiko.supermicro import SmciSwitchSmisTelnet
from netmiko.zyxel import ZyxelSSH
from netmiko.hillstone import hillstoneSSH

if TYPE_CHECKING:
from netmiko.base_connection import BaseConnection
Expand Down Expand Up @@ -255,6 +256,7 @@
"zte_zxros": ZteZxrosSSH,
"yamaha": YamahaSSH,
"zyxel_os": ZyxelSSH,
"hillstone": hillstoneSSH,
}

FILE_TRANSFER_MAP = {
Expand Down
10 changes: 10 additions & 0 deletions tests/etc/commands.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,13 @@ audiocode_shell:
save_config_confirm: False
save_config_response: 'Configuration has been saved'
config_mode_command: "conf" # only use if needed
hillstone:
version: "show version"
basic: "show interface"
extended_output: "show configuration"
config:
- "clock zone china"
config_verification: "show configuration | inc clock"
save_config_cmd: 'save all'
save_config_confirm: True
save_config_response: 'Saving configuration is finished'
8 changes: 8 additions & 0 deletions tests/etc/responses.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,11 @@ audiocode_shell:
save_config: 'Configuration has been saved'
cmd_response_init: "Test_String1"
cmd_response_final: "Test_String2"
hillstone:
base_prompt: SG-6000
router_prompt : SG-6000#
enable_prompt: SG-6000#
interface_ip: 192.168.100.234
version_banner: "Hillstone Networks StoneOS software"
multiple_line_output: ""
save_config: 'Saving configuration is finished'
5 changes: 5 additions & 0 deletions tests/etc/test_devices.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,8 @@ audiocode_shell:
ip: 192.168.1.3
username: TestUser
password: TestPass
hillstone:
device_type: hillstone
ip: 192.168.100.234
username: hillstone
password: Hillstone

0 comments on commit 9ab333c

Please sign in to comment.