Closed vishnu9094 closed 4 years ago
Does the account you are logging in with have permissions to change the configuration (i.e. privilege level 15)?
If not, you need to add a secret
argument to your ConnectHandler dictionary and call the enable()
method
It has privileged 15, i have tried them.
Okay, I will need to see the output of your log file when this error happens:
@vishnu9094 Any update on providing the log file output?
Hi, I have the same issue and logs are as foloowing.
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 10, in
@narayanankl I don't see the log file (the only thing above is the exception stack trace):
I need the following:
@ktbyers , thanks for your response, please see the attached log for your reference.
@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)
I am having a simple code of sending a config to the router.
Setup : Network Automation tool ---------------- Router 1
Configuration :
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
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:~#
`