Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with using netmiko for SONIC Nokia switch #3517

Open
sindhujit1 opened this issue Oct 28, 2024 · 5 comments
Open

Issue with using netmiko for SONIC Nokia switch #3517

sindhujit1 opened this issue Oct 28, 2024 · 5 comments

Comments

@sindhujit1
Copy link

Description of Issue/Question

We are facing an issue connecting to SONIC vendor using netmiko. We have used netmiko in the past for nexus 9ks, cat 9ks, aristas, and it worked. Is SONIC not supported ?

Setup

Netmiko version

netadc3.8) [svc.netadc@hvidlnetwa03 netadc3]$ pip freeze | grep netmiko
netmiko==3.4.0

Netmiko device_type (if relevant to the issue)

We tried different device types. 

f5_linux
ovs_linux
nlinux

Nothing worked.

Error Traceback

(Paste the complete traceback of the exception between quotes below)

['Authentication to device failed.\n\nCommon causes of this problem are:\n1. Invalid username and password\n2. Incorrect SSH-key file\n3. Connecting to the wrong device\n\nDevice settings: <device_type> x.x.x.x:22\n\n\nAuthentication timeout.']

Relevant Python code

ssh = netmiko.ConnectHandler(device_type="<device_type>",host=sonic_ip_input,username=username,password=password,
session_timeout=180,conn_timeout=60,timeout=300,auth_timeout=30)
ssh.disable_paging()
response_prompt = ssh.send_command_timing('sudo config snmp community add '+snmpv3_val+' RO')
logging.warning('response_prompt'+response_prompt)
@ktbyers
Copy link
Owner

ktbyers commented Oct 30, 2024

There is a dell_sonic device_type. Can you try that and see if it works?

If that fails, can you show what the the standard SSH login process looks like when you do it manually (i.e. copy-and-paste the SSH login interaction). You can change/mask any username and passwords.

@sindhujit1
Copy link
Author

sindhujit1 commented Nov 4, 2024

Tried that. It failed as well.

ssh = netmiko.ConnectHandler(device_type="dell_sonic",host=sonic_ip_input,username=username,password=password,
session_timeout=180,conn_timeout=60,timeout=300,auth_timeout=30)

This is how the login looks:

Linux <device_name> 5.10.0-23-2-arm64 #1 SMP Debian 5.10.179-3 (2023-07-27) aarch64
You are on
  ____   ___  _   _ _  ____
 / ___| / _ \| \ | (_)/ ___|
 \___ \| | | |  \| | | |
  ___) | |_| | |\  | | |___
 |____/ \___/|_| \_|_|\____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help:    https://sonic-net.github.io/SONiC/

Last login: Mon Nov  4 17:23:26 2024 from 10.71.19.69
admin@<device_name>:~$

@ktbyers
Copy link
Owner

ktbyers commented Nov 5, 2024

I would probably try to capture the log file to see if it provides you any additional information as to why authentication is failing:

https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel

@sindhujit1
Copy link
Author

sindhujit1 commented Nov 12, 2024

Here is the script:

import netmiko,sys,linecache
import logging
logging.basicConfig(filename='test.log', level=logging.DEBUG)
logger = logging.getLogger("netmiko")
import time

def test():
	try:
		now = time.strftime("%d/%m/%Y").replace("/", "_")
		ssh = netmiko.ConnectHandler(device_type="dell_sonic",host='x.x.x.x',username="admin",password="xxxxx",session_timeout=180,conn_timeout=60,timeout=300,auth_timeout=30)
		response_prompt = ssh.send_command('show version')
		print(response_prompt,"response_prompt")

	except Exception as e:
		exc_type, exc_obj, tb = sys.exc_info()
		f1 = tb.tb_frame
		lineno = tb.tb_lineno
		filename = f1.f_code.co_filename
		linecache.checkcache(filename)
		line = linecache.getline(filename, lineno, f1.f_globals)
		print('Unknown exception occurred on ' + ' ' + str(e) + ". Error On file " + filename + " Line Number " + str(lineno))
		print(str(e))

	ssh.disconnect()
	print('Connection closed.')

test()

Here's the output on the console for the script:

C:\Users\xxxx\OneDrive - xxx\Documents>python netmiko_sonic.py
^
% Error: Invalid input detected at "^" marker. response_prompt
Connection closed.

Attached is the netmiko log file:

test.log

@sindhujit1
Copy link
Author

Any update on this @ktbyers ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants