Paramiko / Netmiko S SH Ошибка - 'paramiko.buffered_pipe.PipeTimeout' - PullRequest
0 голосов
/ 18 апреля 2020

скрипт netmiko

from netmiko import ConnectHandler

    iosv_l2 = {
        'device_type': 'cisco_ios',
        'ip': '192.168.122.2',
        'username': 'test',
        'password': '123',
    }

    net_connect = ConnectHandler(**iosv_l2)
    output = net_connect.send_command('show ip int brief')
    print (output)

    config_commands = ['int loop 0', 'ip address 1.1.1.1 255.255.255.0']
    output = net_connect.send_config_set(config_commands)
    print (output)

    for n in range (2,21):
        print ("Creating VLAN " + str(n))
        config_commands = ['vlan ' + str(n), 'name Python_VLAN ' + str(n)]
        output = net_connect.send_config_set(config_commands)
        print (output) 

Я получаю эту ошибку


    Interface              IP-Address      OK? Method Status                Protocol
    GigabitEthernet0/0     unassigned      YES unset  up                    up
    GigabitEthernet0/1     unassigned      YES unset  down                  down
    Vlan1                  192.168.122.2   YES manual up                    up
    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 534, 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 "ssh.py", line 15, in 
        output = net_connect.send_config_set(config_commands)
      File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 1607, 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 49, in config_mode
        return super(CiscoBaseConnection, self).config_mode(
      File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 1514, in config_mode
        if not self.check_config_mode():
      File "/usr/local/lib/python3.8/dist-packages/netmiko/cisco/cisco_ios.py", line 31, in check_config_mode
        return super(CiscoIosBase, self).check_config_mode(
      File "/usr/local/lib/python3.8/dist-packages/netmiko/cisco_base_connection.py", line 37, in check_config_mode
        return super(CiscoBaseConnection, self).check_config_mode(
      File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 1501, in check_config_mode
        output = self.read_until_pattern(pattern=pattern)
      File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 609, in read_until_pattern
        return self._read_channel_expect(*args, **kwargs)
      File "/usr/local/lib/python3.8/dist-packages/netmiko/base_connection.py", line 542, in _read_channel_expect
        raise NetMikoTimeoutException(
    netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.

Топология сети

Как исправить эту проблему .. .

...