ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.63k stars 1.31k forks source link

Issue with Zyxel GS1900 #3299

Open DonKannalie opened 1 year ago

DonKannalie commented 1 year ago

netmiko 4.2.0 Netmiko is not using/cannot disable the pager for zyxel_os.? Doesn't continue after '--More--'.

Edit: I forget to add what I am actually doing. Even though it's pretty plain simple:

device = {
    'host': 'myhost', 
    'ip': 'xxx.xxx.xxx.xxx', 
    'device_type': 'zyxel_os', 
    'username': 'username', 
    'secret': 'secret',
    'password': 'password',
    'banner_timeout': 30, 
}

with ConnectHandler(**device) as net_connect:
    net_connect.enable()
    res = net_connect.send_command("show running-config")

Logging output:

DEBUG:paramiko.transport:userauth is OK INFO:paramiko.transport:Authentication (password) successful! DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes GS1900# GS1900# DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: b'\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: GS1900# DEBUG:netmiko: Parenthesis found in pattern.

pattern: (#|>)

This can be problemtic when used in read_until_pattern().

You should ensure that you use either non-capture groups i.e. '(?:' or that the parenthesis completely wrap the pattern '(pattern)' DEBUG:netmiko:Pattern found: (#|>) GS1900# DEBUG:netmiko:read_channel: DEBUG:netmiko:Clear buffer detects data in the channel DEBUG:netmiko:read_channel: DEBUG:netmiko:[find_prompt()]: prompt is GS1900# DEBUG:netmiko:In disable_paging DEBUG:netmiko:Command: terminal length 0

DEBUG:netmiko:write_channel: b'terminal length 0\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: terminal length 0 Unknown command GS1900# DEBUG:netmiko:Pattern found: (terminal\ length\ 0) terminal length 0 DEBUG:netmiko:terminal length 0 DEBUG:netmiko:Exiting disable_paging DEBUG:netmiko:read_channel: DEBUG:netmiko:Clear buffer detects data in the channel DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: b'\n' DEBUG:netmiko:read_channel: GS1900# DEBUG:netmiko:read_channel: DEBUG:netmiko:[find_prompt()]: prompt is GS1900# DEBUG:netmiko:write_channel: b'show running-config\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: show running-config

DEBUG:netmiko:Pattern found: (show\ running-config) show running-config DEBUG:netmiko:read_channel: [...] ## truncated; previous output repeats a few times DEBUG:netmiko:read_channel: ! System Description: ZyXEL GS1900-8 Switch ! Revision: B1 ! Serial Number: xxx ! MAC Address Range: xxx - xxx ! Boot Version: V2.0.2.1 | 05/21/2021 ! Firmware Version: V2.70(AAHH.5) | 02/08/2023 ! System Up Time: 26 days, 17 hours, 59 mins, 11 secs lag load-balance src-dst-mac lacp system-priority 32768 ! system location "xxx" system contact "xxx" ip address xxx.xxx.xxx.xxx mask xxx.xxx.xxx.xxx ip default-gateway xxx.xxx.xxx.xxx ip dns xxx.xxx.xxx.xxx1 xxx.xxx.xxx.xxx clock source sntp sntp host xxx.xxx.xxx.xxx port 123 username "xxx" secret 8 xxx vlan 2 name "vlan0002" vlan 3 name "vlan0003" vlan 4 --More-- DEBUG:netmiko:read_channel: [...] ## truncated; previous output repeats many times DEBUG:netmiko:write_channel: b'exit\n' ERROR:

Pattern not detected: 'GS1900\#' in output.

Things you might try to fix this:

  1. Explicitly set your pattern using the expect_string argument.
  2. Increase the read_timeout to a larger value.

You can also look at the Netmiko session_log or debug log for more information.

hgqcs commented 1 year ago

DEBUG:netmiko:write_channel: b'terminal length 0\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: terminal length 0 Unknown command GS1900# netmiko.zyxel.zyxel_ssh.ZyxelSSH.disable_paging is nothing to do, if you want disable paging(a disable paging command), you should rewrite disable_paging

ktbyers commented 11 months ago

@hgqcs @DonKannalie What is the command to disable paging on this Zyxel GS1900?

DonKannalie commented 11 months ago

You mean from the zyxel os settings itself? There is None as far as my research went. Also no paging on certain key input. It's a smart managed switch. The cli is kinda limited.

ktbyers commented 11 months ago

@DonKannalie Does this generally apply to Zyxel devices (i.e. no way to disable output paging) or is it specific to the GS1900 (basically I am wondering if the driver ever really worked).

DonKannalie commented 11 months ago

For higher tier devices I guess so, but I cannot confirm/deny, as I don't have one. It's stated on the Zyxel forum years ago though (https://community.zyxel.com/en/discussion/1740/disable-paging-in-cli).

ktbyers commented 11 months ago

Okay, Zyxel's are sort of broken then since Netmiko counts on their being a way to disable output paging...so you would probably have to build a for-loop and use write_channel()/read_channel() to handle this.

I created an issue recently to make a generic output pager, but someone would have to build that (as it doesn't exist in current Netmiko).

Historically, I would generally reject platforms that didn't have a reasonable way to disable output paging.

DonKannalie commented 11 months ago

Thanks. "Historically, I would generally reject platforms that didn't have a reasonable way to disable output paging." Understandable...

ktbyers commented 11 months ago

You definitely can do it, but you will just have to write some lower level of code to detect and handle the output paging--unfortunately :-(