Nokia SROS driver issues
Trasmontinho opened this issue ยท 6 comments
Describe the bug
Issues using the Nokia SROS Driver. It seems that the prompt is never detected but I'm not sure
To Reproduce
Steps to reproduce the behavior:
Execute the script below for a nokia sros device.
For you information my equipement prompt is like *B:DEV02-XY2# or *A:DEV02-XY2# (depending in which CPM card you are)
The script
from scrapli import Scrapli
import logging
logging.basicConfig(filename="scrapli.log",level=logging.DEBUG)
logger = logging.getLogger("scrapli")
my_device = {
"host": "DEV02-XY2",
"auth_username": "login",
"auth_password": "password",
"auth_strict_key": False,
"ssh_config_file": True,
"platform": "nokia_sros",
}
conn = Scrapli(**my_device)
conn.open()
print(conn.get_prompt())
output=conn.send_command("show version")
print(output.result)
Environment:
Nokia SROS, version TiMOS-C-16.0.R4, 7750 SR-7s
Expected behavior
I should be able to get the prompt and also the output of the nokia device version
Stack Trace
File "test_scrapli.py", line 28, in <module>
conn.open()
File "/usr/local/lib/python3.7/site-packages/scrapli/driver/base/sync_driver.py", line 88, in open
auth_private_key_passphrase=self.auth_private_key_passphrase,
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 279, in decorate
kwargs=kwargs,
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 336, in _multiprocessing_timeout
self._handle_timeout()
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 312, in _handle_timeout
raise ScrapliTimeout(self.message)
scrapli.exceptions.ScrapliTimeout: timed out during in channel ssh authentication
Logs Trace
DEBUG:scrapli:Scrapli factory initialized
INFO:scrapli:Driver '<class 'scrapli.driver.network.sync_driver.NetworkDriver'>' selected from scrapli community platforms, with the following platform arguments: '{'privilege_levels': {'exec': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7ffbe2583050>, 'configuration': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7ffbe25832f0>, 'configuration_with_path': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7ffbe2583ad0>}, 'default_desired_privilege_level': 'exec', 'failed_when_contains': ['MINOR:', 'MAJOR:'], 'textfsm_platform': '', 'genie_platform': '', 'on_open': <function default_sync_on_open at 0x7ffbe24ec710>, 'on_close': <function default_sync_on_close at 0x7ffbe24ecb00>}'
DEBUG:scrapli.driver:attempting to resolve 'ssh_config_file' file
DEBUG:scrapli.driver:using '/etc/ssh/ssh_config' as resolved 'ssh_config_file' file'
DEBUG:scrapli.driver:load core transport requested
DEBUG:scrapli.driver:core transport 'paramiko' loaded successfully
DEBUG:scrapli.driver:generating combined network comms prompt pattern
DEBUG:scrapli.driver:setting 'comms_prompt_pattern' value to '(^(?!\(ex\)|\(ro\)|\(gl\)|\(pr\))\[.*\]\n[abcd]:[\w]+@[\w]+#\s?$)|(^(?:!|\*)?\(ex\)\[/?\]\n\*?[abcd]:[\w]+@[\w]+#\s?$)|(^(?:!|\*)?\(ex\)\[\S{2,}\]\n\*?[abcd]:[\w]+@[\w]+#\s?$)'
INFO:scrapli.driver:opening connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.transport:opening transport connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.socket:opening socket connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.socket:opened socket connection to 'DEV02-XY2' on port '22' successfully
DEBUG:paramiko.transport:starting thread (client mode): 0xe1212fd0
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.7.2
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_3.5p1
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_3.5p1)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes256-ctr', 'aes192-ctr', 'aes128-ctr', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc@lysator.liu.se'] server encrypt:['aes256-ctr', 'aes192-ctr', 'aes128-ctr', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc@lysator.liu.se'] client mac:['hmac-sha2-512', 'hmac-sha2-256', 'hmac-sha1', 'hmac-sha1-96', 'hmac-md5', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-md5-96'] server mac:['hmac-sha2-512', 'hmac-sha2-256', 'hmac-sha1', 'hmac-sha1-96', 'hmac-md5', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-md5-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: diffie-hellman-group-exchange-sha1
DEBUG:paramiko.transport:HostKey agreed: ssh-rsa
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:Got server p (2048 bits)
DEBUG:paramiko.transport:kex engine KexGex specified hash_algo <built-in function openssl_sha1>
DEBUG:paramiko.transport:Switch to new keys ...
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
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' opened successfully
DEBUG:scrapli.channel:write: '\n'
DEBUG:scrapli.channel:read: b'*B:DEV02-XY2# \n*B:DEV02-XY2# '
CRITICAL:scrapli.channel:channel operation timed out, closing transport
DEBUG:scrapli.transport:closing transport connection to 'DEV02-XY2' on port '22'
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
DEBUG:scrapli.socket:closing socket connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.socket:closed socket connection to 'DEV02-XY2' on port '22' successfully
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' closed successfully
CRITICAL:scrapli.transport:encountered EOF reading from transport; typically means the device closed the connection
ERROR:paramiko.transport:Socket exception: Bad file descriptor (9)
DEBUG:scrapli:Scrapli factory initialized
INFO:scrapli:Driver '<class 'scrapli.driver.network.sync_driver.NetworkDriver'>' selected from scrapli community platforms, with the following platform arguments: '{'privilege_levels': {'exec': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7fa989282d00>, 'configuration': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7fa989282980>, 'configuration_with_path': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7fa989282440>}, 'default_desired_privilege_level': 'exec', 'failed_when_contains': ['MINOR:', 'MAJOR:'], 'textfsm_platform': '', 'genie_platform': '', 'on_open': <function default_sync_on_open at 0x7fa9891ea710>, 'on_close': <function default_sync_on_close at 0x7fa9891eab00>}'
DEBUG:scrapli.driver:attempting to resolve 'ssh_config_file' file
DEBUG:scrapli.driver:using '/etc/ssh/ssh_config' as resolved 'ssh_config_file' file'
DEBUG:scrapli.driver:load core transport requested
DEBUG:scrapli.driver:core transport 'system' loaded successfully
DEBUG:scrapli.transport:created transport 'open_cmd': '['ssh', 'DEV02-XY2', '-p', '22', '-o', 'ConnectTimeout=15', '-o', 'ServerAliveInterval=30', '-l', 'login', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-F', '/etc/ssh/ssh_config']'
DEBUG:scrapli.driver:generating combined network comms prompt pattern
DEBUG:scrapli.driver:setting 'comms_prompt_pattern' value to '(^(?!\(ex\)|\(ro\)|\(gl\)|\(pr\))\[.*\]\n[abcd]:[\w]+@[\w]+#\s?$)|(^(?:!|\*)?\(ex\)\[/?\]\n\*?[abcd]:[\w]+@[\w]+#\s?$)|(^(?:!|\*)?\(ex\)\[\S{2,}\]\n\*?[abcd]:[\w]+@[\w]+#\s?$)'
INFO:scrapli.driver:opening connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.transport:opening transport connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' opened successfully
DEBUG:scrapli.channel:attempting in channel ssh authentication
DEBUG:scrapli.channel:read: b"Warning: Permanently added 'dev02-xy2,1.1.1.1' (RSA) to the list of known hosts.\n"
DEBUG:scrapli.channel:read: b'\n ******************************************************************************\n *** WARNING MYLITTLECOMPANY ***\n ******************************************************************************\n *** You must have prior authorization to access this system. ***\n *** ******************************************************************************\n'
DEBUG:scrapli.channel:read: b"login@dev02-xy2's password: "
DEBUG:scrapli.channel:write: REDACTED
DEBUG:scrapli.channel:write: '\n'
DEBUG:scrapli.channel:read: b'\n'
DEBUG:scrapli.channel:read: b'*B:DEV02-XY2# '
CRITICAL:scrapli.channel:channel operation timed out, closing transport
DEBUG:scrapli.transport:closing transport connection to 'DEV02-XY2' on port '22'
CRITICAL:scrapli.transport:encountered EOF reading from transport; typically means the device closed the connection
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' closed successfully
Screenshots
No screenshots
OS (please complete the following information):
- OS:
Linux res-outil66 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
- scrapli version : 2021.7.30
- scrapli_community version : 2021.7.30
- version of any optional extras :
- paramiko : 2.7.2
- ssh2-python : 0.26.0
- textfsm : 1.1.0
- genie : 20.9
Additional context
I am 99% sure (maybe? ๐ ) that you just need to use the "classic" variant:
my_device = {
"host": "DEV02-XY2",
"auth_username": "login",
"auth_password": "password",
"auth_strict_key": False,
"ssh_config_file": True,
"platform": "nokia_sros",
"variant": "classic"
}
I dont know enough about Nokia stuff to have details about what/why you have one vs the other, but looks like that prompt gets matched by the classic prompt patterns here
Oh ! I haven't seen this specific parameter ๐
I give a try right and get back to you.
Sam
Well I've tried it and still the same issue the comms_prompt_pattern
has changed effectively by the way.
below the traceback :
Traceback (most recent call last):
File "test_scrapli.py", line 29, in <module>
print(conn.get_prompt())
File "/usr/local/lib/python3.7/site-packages/scrapli/driver/base/sync_driver.py", line 88, in open
auth_private_key_passphrase=self.auth_private_key_passphrase,
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 279, in decorate
kwargs=kwargs,
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 336, in _multiprocessing_timeout
self._handle_timeout()
File "/usr/local/lib/python3.7/site-packages/scrapli/decorators.py", line 312, in _handle_timeout
raise ScrapliTimeout(self.message)
scrapli.exceptions.ScrapliTimeout: timed out during in channel ssh authentication
and the logs :
DEBUG:scrapli:Scrapli factory initialized
INFO:scrapli:Driver '<class 'scrapli.driver.network.sync_driver.NetworkDriver'>' selected from scrapli community platforms, with the following platform arguments: '{'privilege_levels': {'exec': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7f7c7aaf0c90>, 'configuration': <scrapli.driver.network.base_driver.PrivilegeLevel object at 0x7f7c7aaf0f30>}, 'default_desired_privilege_level': 'exec', 'failed_when_contains': ['Error:'], 'textfsm_platform': '', 'genie_platform': '', 'on_open': <function classic_default_sync_on_open at 0x7f7c7aa59b90>, 'on_close': <function default_sync_on_close at 0x7f7c7aa59c20>}'
DEBUG:scrapli.driver:attempting to resolve 'ssh_config_file' file
DEBUG:scrapli.driver:using '/etc/ssh/ssh_config' as resolved 'ssh_config_file' file'
DEBUG:scrapli.driver:load core transport requested
DEBUG:scrapli.driver:core transport 'system' loaded successfully
DEBUG:scrapli.transport:created transport 'open_cmd': '['ssh', 'DEV02-XY2', '-p', '22', '-o', 'ConnectTimeout=15', '-o', 'ServerAliveInterval=30', '-l', 'login', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-F', '/etc/ssh/ssh_config']'
DEBUG:scrapli.driver:generating combined network comms prompt pattern
DEBUG:scrapli.driver:setting 'comms_prompt_pattern' value to '(^\*?[abcd]:[\w]+#\s?$)|(^\*?[abcd]:[\w]+>config#\s?$)'
INFO:scrapli.driver:opening connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.transport:opening transport connection to 'DEV02-XY2' on port '22'
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' opened successfully
DEBUG:scrapli.channel:attempting in channel ssh authentication
DEBUG:scrapli.channel:read: b"Warning: Permanently added 'dev02-xy2,1.1.1.1' (RSA) to the list of known hosts.\n"
DEBUG:scrapli.channel:read: b'\n ******************************************************************************\n *** WARNING - MYLITTLECOMPANY ***'
DEBUG:scrapli.channel:read: b"\n ******************************************************************************\n *** You must have prior authorization to access this system. ***\n *** ******************************************************************************\nlogin@dev02-xy2's password: "
DEBUG:scrapli.channel:write: REDACTED
DEBUG:scrapli.channel:write: '\n'
DEBUG:scrapli.channel:read: b'\n'
DEBUG:scrapli.channel:read: b'*B:DEV02-XY2# '
CRITICAL:scrapli.channel:channel operation timed out, closing transport
DEBUG:scrapli.transport:closing transport connection to 'DEV02-XY2' on port '22'
CRITICAL:scrapli.transport:encountered EOF reading from transport; typically means the device closed the connection
DEBUG:scrapli.transport:transport connection to 'DEV02-XY2' on port '22' closed successfully
Ah, seems that the classic pattern on master/pypi version doesn't match the pattern. Thankfully @juliencorsini was awesome enough to catch and fix this already here -- you'll just need to run with develop branch until the next release: pip install -e git+https://github.com/scrapli/scrapli_community.git@develop#egg=scrapli_community
Sorry didn't realize that was still in develop still. Next pypi release is scheduled for 2022.01.30.
Holler if that doesn't fix things for ya!
ah ok ! I've looked directlty in the closed issues and didn't catched it ๐ ^^ thanks for your time ! @carlmontanari
NP, I'll close this but feel free to reopen if that doesn't get ya sorted!