Netmiko giving some issues while using send_config_set
See original GitHub issueI 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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
@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.
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)
test_log.txt
@ktbyers , thanks for your response, please see the attached log for your reference.