question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Netmiko giving some issues while using send_config_set

See original GitHub issue

I am having a simple code of sending a config to the router.

Setup : Network Automation tool ---------------- Router 1

Configuration :

from netmiko import ConnectHandler

iosvl2 = {
    'device_type' : 'cisco_ios',
    'ip':'192.168.122.10',
    'username':'network',
    'password':'rhinos',
}

connect=ConnectHandler(**iosvl2)
output=connect.send_command("show ip interface brief")
print(output)

config_command=['interface lo0','ip address 1.1.1.1 255.255.255.255']
output=connect.send_config_set(config_command)
print(output)

Below is my output `root@NetworkAutomation-1:~# python3 netmiko1.py Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.122.65 YES manual up up FastEthernet0/1 unassigned YES unset administratively down down FastEthernet1/0 unassigned YES unset administratively down down FastEthernet1/1 unassigned YES unset administratively down down FastEthernet2/0 unassigned YES unset administratively down down FastEthernet2/1 unassigned YES unset administratively down down FastEthernet3/0 unassigned YES unset administratively down down FastEthernet3/1 unassigned YES unset administratively down down Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/paramiko/channel.py”, line 699, in recv out = self.in_buffer.read(nbytes, self.timeout) File “/usr/local/lib/python3.8/dist-packages/paramiko/buffered_pipe.py”, line 164, in read raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 550, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File “/usr/local/lib/python3.8/dist-packages/paramiko/channel.py”, line 701, in recv raise socket.timeout() socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “netmiko1.py”, line 16, in <module> output=connect.send_config_set(config_command) File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 1735, in send_config_set output += self.config_mode(*cfg_mode_args) File “/usr/local/lib/python3.8/dist-packages/netmiko/cisco_base_connection.py”, line 40, in config_mode return super().config_mode(config_command=config_command, pattern=pattern) File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 1619, in config_mode if not self.check_config_mode(): File “/usr/local/lib/python3.8/dist-packages/netmiko/cisco/cisco_ios.py”, line 29, in check_config_mode return super().check_config_mode(check_string=check_string, pattern=pattern) File “/usr/local/lib/python3.8/dist-packages/netmiko/cisco_base_connection.py”, line 30, in check_config_mode return super().check_config_mode(check_string=check_string, pattern=pattern) File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 1606, in check_config_mode output = self.read_until_pattern(pattern=pattern) File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 627, in read_until_pattern return self._read_channel_expect(*args, **kwargs) File “/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py”, line 560, in _read_channel_expect raise NetmikoTimeoutException( netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available. root@NetworkAutomation-1:~# `

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
narayananklcommented, Jul 4, 2020

@ktbyers , thanks for your guidance, the log helped me to identify the issue.

Issue was related to privilege mode.

adding below the two statemests helped me to run my first basic script successful.

  1. net_connect.enable()
  2. ‘secret’: ‘test123’ +++++++++++++++++++++++++++++++++++++++++++

from netmiko import ConnectHandler import logging logging.basicConfig(filename=‘test.log’, level=logging.DEBUG) logger = logging.getLogger(“netmiko”)

ios_l2 = {‘device_type’: ‘cisco_ios’, ‘ip’: ‘192.168.122.200’, ‘username’: ‘test’, ‘password’: ‘test123’, ‘secret’: ‘test123’}

net_connect = ConnectHandler(**ios_l2) output = net_connect.send_command(‘show ip int brief’) print(output) net_connect.enable() config_commands = [‘int lo 200’] output = net_connect.send_config_set(config_commands) print(output)

0reactions
narayananklcommented, Jul 4, 2020

test_log.txt

@ktbyers , thanks for your response, please see the attached log for your reference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Send config over with netmiko to switch - Cisco Community
Solved: Hello, I can not send a global configuration command to a switch, I get the typical "% Invalid input detected at '^'...
Read more >
python 3.x - I keep geting this error related with Netmiko when ...
I keep geting this error related with Netmiko when sending send_config_set(), but send_comand() works? · python-3.x · automation · cisco · netmiko.
Read more >
Interacting with IOS XE and IOS XR using Netmiko
Netmiko is a multi-vendor SSH Python library which makes connecting to network devices via SSH really easy and straightforward. The library ...
Read more >
Netmiko ASA Object Group : r/networking - Reddit
1 issue I have with an ASA is creating an Network… ... Hi, when i do this with NetMiko i have never tried...
Read more >
SSH Configuration with Netmiko - YouTube
SSH Configuration with Netmiko ... In this video, you'll learn how to configure a Secure Shell (SSH) connection using Netmiko.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found