ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.61k stars 1.31k forks source link

Timed-out reading channel, data n ot available. #212

Closed TonyWoo closed 8 years ago

TonyWoo commented 8 years ago

We use the netmiko with our Cisco C1900 router. We found it works some time, but not always, when I open enable() it show time timed-out sometime. Please see below detailed error message.

Anyone can help me? Thanks in advance.

Traceback (most recent call last): File "C:\Users\130375382\Desktop\python-network-tool (1)\console\server_connec t.py", line 58, in copy_current_config self.net_connect.enable() File "C:\Python27\lib\site-packages\netmiko\ssh_connection.py", line 15, in en able return super(SSHConnection, self).enable(cmd=cmd, pattern=pattern, re_flags= re_flags) File "C:\Python27\lib\site-packages\netmiko\base_connection.py", line 513, in enable if not self.check_enable_mode(): File "C:\Python27\lib\site-packages\netmiko\ssh_connection.py", line 11, in ch eck_enable_mode return super(SSHConnection, self).check_enable_mode(check_string=check_strin g) File "C:\Python27\lib\site-packages\netmiko\base_connection.py", line 507, in check_enable_mode output = self.read_until_prompt() File "C:\Python27\lib\site-packages\netmiko\base_connection.py", line 354, in read_until_prompt return self.read_until_pattern() File "C:\Python27\lib\site-packages\netmiko\base_connection.py", line 368, in read_until_pattern raise NetMikoTimeoutException("Timed-out reading channel, data not available .") netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data n ot available.

TonyWoo commented 8 years ago

It also show "failed to enter the configuration mode" some time. we're very confused, why it work some time, but then doesn't work? Really need your help:)

ktbyers commented 8 years ago

@TonyWoo Use the latest code (clone from master branch in GitHub).

Turn on debugging in this method:

    def read_until_pattern(self, pattern='', re_flags=0):
        """Read channel until pattern detected. Return ALL data available."""
        debug = True          # enable debugging here.
        output = ''
        if not pattern:
            pattern = self.base_prompt
        pattern = re.escape(pattern)
        if debug:
            print("Pattern is: {}".format(pattern))
        while True:
            try:
                output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore')
                if re.search(pattern, output, flags=re_flags):
                    if debug:
                        print("Pattern found: {} {}".format(pattern, output))
                    return output
            except socket.timeout:
                raise NetMikoTimeoutException("Timed-out reading channel, data not available.")

See if that gives us some more clues.

TonyWoo commented 8 years ago

@ktbyers Thanks for your response. I just downloaded the latest code and set the debug = true, pleas see below error message. Thanks.

File "C:\Users\130375382\Desktop\python-network-tool\console\server_connect.py ", line 58, in copy_current_config self.net_connect.enable() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\ssh_connection.py ", line 15, in enable return super(SSHConnection, self).enable(cmd=cmd, pattern=pattern, re_flags= re_flags) File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 546, in enable output += self.read_until_prompt() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 374, in read_until_prompt return self.read_until_pattern() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 393, in read_until_pattern raise NetMikoTimeoutException("Timed-out reading channel, data not available .") netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data n ot available. ['int gi0/0', 'no shutdown', 'description Testting', 'ip address 192.168.10.1 25 5.255.255.0', 'hostname try'] enter enable mode

Pattern is: tess3 Pattern found: tess3 % Password: timeout expired! Password: % Bad secrets

tess3> Pattern is: tess3 Traceback (most recent call last): File "C:\Users\130375382\Desktop\python-network-tool\console\server_connect.py ", line 165, in configure_router self.router_window.configure_router(self.net_connect) File "C:\Users\130375382\Desktop\python-network-tool\console\Router.py", line 53, in configure_router net_connect_obj.enable() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\ssh_connection.py ", line 15, in enable return super(SSHConnection, self).enable(cmd=cmd, pattern=pattern, re_flags= re_flags) File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 546, in enable output += self.read_until_prompt() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 374, in read_until_prompt return self.read_until_pattern() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 393, in read_until_pattern raise NetMikoTimeoutException("Timed-out reading channel, data not available .") netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data n ot available. ['int gi0/0', 'no shutdown', 'description Testting', 'ip address 192.168.10.1 25 5.255.255.0', 'hostname try'] enter enable mode

Pattern is: tess3 Traceback (most recent call last): File "C:\Users\130375382\Desktop\python-network-tool\console\server_connect.py ", line 165, in configure_router self.router_window.configure_router(self.net_connect) File "C:\Users\130375382\Desktop\python-network-tool\console\Router.py", line 53, in configure_router net_connect_obj.enable() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\ssh_connection.py ", line 15, in enable return super(SSHConnection, self).enable(cmd=cmd, pattern=pattern, re_flags= re_flags) File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 542, in enable if not self.check_enable_mode(): File "C:\Users\130375382\Desktop\python-network-tool\netmiko\ssh_connection.py ", line 11, in check_enable_mode return super(SSHConnection, self).check_enable_mode(check_string=check_strin g) File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 536, in check_enable_mode output = self.read_until_prompt() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 374, in read_until_prompt return self.read_until_pattern() File "C:\Users\130375382\Desktop\python-network-tool\netmiko\base_connection.p y", line 393, in read_until_pattern raise NetMikoTimeoutException("Timed-out reading channel, data not available .") netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data n ot available.

samirsss commented 8 years ago

i've seen a similar issue with Brocade NOS devices and looks like its due to changes between 0.3.4 and 0.4.3.

We'll have to change line 186 from time.sleep(.1) to time.sleep(.5) for this to work and give enough delay to recognize that the device is ready.

Way to bypass this is to add a special_login_handler in your device class.

def special_login_handler(self, delay_factor=.5): ''' Adding a delay after login. :param delay_factor: :return: ''' delay_factor = self.select_delay_factor(delay_factor) time.sleep(delay_factor)

ktbyers commented 8 years ago

@samirsss I don't think the above will fix the issue he is referencing since he is referring to an issue going into enable() not on login. Have you opened an issue on your above Brocade problem?

@TonyWoo Are you still having this issue?

samirsss commented 8 years ago

@ktbyers we're in the process of testing this change and will be opening an issue soon. I've tried this fix for brocade nos devices and it seems to be working.

lundybernard commented 8 years ago

I am having the same issue, attempting to configure a Cisco IOS router. I will take some time to pull the latest version, and enable debugging in read_until_pattern, as suggested above. Please let me know if there is anything else I can do to help.

stack trace:

test_configure_device (test_ccp.CCPFunctionalTests) ... Traceback (most recent call last):
  File "/home/lbernard/projects/cisco_config_pusher/ccp/core.py", line 55, in push_configuration
    output = self.connection.send_config_set(self.configuration)
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/base_connection.py", line 641, in send_config_set
    output += self.exit_config_mode()
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/ssh_connection.py", line 48, in exit_config_mode
    pattern=pattern)
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/base_connection.py", line 580, in exit_config_mode
    if self.check_config_mode():
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/ssh_connection.py", line 30, in check_config_mode
    pattern=pattern)
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/base_connection.py", line 564, in check_config_mode
    output = self.read_until_pattern(pattern=pattern)
  File "/home/lbernard/miniconda3/envs/py27/lib/python2.7/site-packages/netmiko/base_connection.py", line 393, in read_until_pattern
    raise NetMikoTimeoutException("Timed-out reading channel, data not available.")
NetMikoTimeoutException: Timed-out reading channel, data not available.
ktbyers commented 8 years ago

@lundybernard Are you changing the hostname as part of this change?

lundybernard commented 8 years ago

We are not changing the host name, but we are making a ton of configuration changes, including changes to login credentials. My test device has already been configured, so, I would not expect any of the changes to be destructive. Here is the yaml file we are using to build the list of config commands:

default:
    - username netmaster privilege 15 secret <secret>
    - enable secret <secret>
    - ip access-list standard SNMP-PI
    - remark Prime-Infrastructure
    - permit <ip> 0.0.0.0 log
    - permit <ip> 0.0.0.0 log
    - snmp-server community <secret> RW SNMP-PI
    - ip access-list standard SNMP-SW
    - remark SolarWinds Subnets
    - permit <ip> 0.0.0.255 log
    - permit <ip> 0.0.0.255 log
    - permit <ip> 0.0.0.255 log
    - permit <ip> 0.0.0.255 log
    - permit <ip> 0.0.0.255 log
    - permit <ip> 0.0.0.255 log
    - snmp-server community <secret> RW SNMP-SW
    - ip tacacs source-interface Loopback0
    - tacacs server <server>
    - address ipv4 <ip>
    - key <secret>
    - tacacs server <server>
    - address ipv4 <ip>
    - key <secret>
    - aaa new-model
    - aaa group server tacacs+ ISE
    - server name <server>
    - server name <server>
    - 'aaa authentication password-prompt Local-Password:'
    - 'aaa authentication username-prompt Local-Username:'
    - aaa authentication login default group ISE local
    - aaa authentication enable default group ISE enable
    - aaa authorization exec default group tacacs if-authenticated
    - aaa authorization commands 15 default group ISE none
    - aaa accounting exec default start-stop group ISE
    - aaa accounting commands 15 default start-stop group ISE
    - aaa authentication fail-message ^
    - line vty 0 15
    - login authentication default
    - authorization exec default
    - accounting commands 15 default
    - transport input all
    - line con 0
    - login authentication default
    - accounting commands 15 default
    - Service password-encryption
    - kron policy-list WrMem
    - cli write memory
    - kron occurrence DAILY-WrMem at  08:00  recurring
    - policy-list WrMem
    - no tacacs-server host <ip> key 7 <key>
    - no tacacs-server host <ip> key 7 <key>
    - no tacacs-server host <ip> key 7 <key>
    - no tacacs-server key 7 <key>
    - no aaa authorization commands 15 default group tacacs+ none
ktbyers commented 8 years ago

For this many changes you probably want should look at using the NAPALM-ios driver. It is built on Netmiko.

Does the above fail on any particular command?

Kirk

On Tue, Jul 19, 2016 at 7:48 AM, Lundy Bernard notifications@github.com wrote:

We are not changing the host name, but we are making a ton of configuration changes, including changes to login credentials. My test device has already been configured, so, I would not expect any of the changes to be destructive. Here is the yaml file we are using to build the list of config commands:

default:

  • username netmaster privilege 15 secret
  • enable secret
  • ip access-list standard SNMP-PI
  • remark Prime-Infrastructure
  • permit 0.0.0.0 log
  • permit 0.0.0.0 log
  • snmp-server community RW SNMP-PI
  • ip access-list standard SNMP-SW
  • remark SolarWinds Subnets
  • permit 0.0.0.255 log
  • permit 0.0.0.255 log
  • permit 0.0.0.255 log
  • permit 0.0.0.255 log
  • permit 0.0.0.255 log
  • permit 0.0.0.255 log
  • snmp-server community RW SNMP-SW
  • ip tacacs source-interface Loopback0
  • tacacs server
  • address ipv4
  • key
  • tacacs server
  • address ipv4
  • key
  • aaa new-model
  • aaa group server tacacs+ ISE
  • server name
  • server name
  • 'aaa authentication password-prompt Local-Password:'
  • 'aaa authentication username-prompt Local-Username:'
  • aaa authentication login default group ISE local
  • aaa authentication enable default group ISE enable
  • aaa authorization exec default group tacacs if-authenticated
  • aaa authorization commands 15 default group ISE none
  • aaa accounting exec default start-stop group ISE
  • aaa accounting commands 15 default start-stop group ISE
  • aaa authentication fail-message ^
  • line vty 0 15
  • login authentication default
  • authorization exec default
  • accounting commands 15 default
  • transport input all
  • line con 0
  • login authentication default
  • accounting commands 15 default
  • Service password-encryption
  • kron policy-list WrMem
  • cli write memory
  • kron occurrence DAILY-WrMem at 08:00 recurring
  • policy-list WrMem
  • no tacacs-server host key 7
  • no tacacs-server host key 7
  • no tacacs-server host key 7
  • no tacacs-server key 7
  • no aaa authorization commands 15 default group tacacs+ none

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ktbyers/netmiko/issues/212#issuecomment-233656648, or mute the thread https://github.com/notifications/unsubscribe-auth/AA26hNfCaCQ7RpsS0PaeOzp-U6WBLqbYks5qXOOygaJpZM4IiMzs .

Kirk Byers CCIE #6243 emeritus ktbyers@twb-tech.com http://pynet.twb-tech.com http://pynet.twb-tech.com/blog (415) 264-6270 Simplify your network management through automation

lundybernard commented 8 years ago

I managed to find the point at which it fails 'aaa accounting commands 15 default start-stop group ISE' is the last command that works, we suspect that we will need to write memory, then re-log to proceed.

ktbyers commented 8 years ago

What does it look like in the CLI when you execute this command?

I just want to see if there is an unexpected CLI behavior that Netmiko is not handling.

samuelbaruffi commented 8 years ago

Hello @ktbyers

Thank you for always assisting on issues for Netmiko.

I'm facing a similar issue.

I have a very simple script trying to copy the config of a Cisco SG300 device. My code (I have verbose enabled on Netmiko):

if Device_Model_List[i] == "Cisco":

            #create profile for Juniper for NetMiko
            provision_router_object = {
            'device_type': 'cisco_ios',
            'ip': Public_IP_List[i],
            'username': User_List[i], 
            'password': Password_List[i],
            'port': SSH_Port_List[i],
            'global_delay_factor': 1,
            'verbose': true,
            }

            print(provision_router_object)
            provision_router = ConnectHandler(**provision_router_object)    
            output = provision_router.send_command("show running-config")
            file_name = Name_List[i] + '-' + str(date)
            path = "/Users/sam/Documents/Backup_Router/" + Customer_List[i] + "/" + Customer_Site[i] + "/"
            print(path)
            os.makedirs(os.path.dirname(path), exist_ok=True)

            with open(os.path.join(path,file_name),"w") as file_:
                file_.write(output)   

And here's the verbose + error I am getting:

SSH connection established to 184.68.129.6:2210
Interactive SSH session established

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/paramiko/channel.py", line 613, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/usr/local/lib/python3.5/site-packages/paramiko/buffered_pipe.py", line 160, 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.5/site-packages/netmiko/base_connection.py", line 387, in read_until_pattern
    output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore')
  File "/usr/local/lib/python3.5/site-packages/paramiko/channel.py", line 615, in recv
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sam/Documents/git/OPS/ops/python/router_backup/Backup_Test.py", line 56, in <module>
    provision_router = ConnectHandler(**provision_router_object)  
  File "/usr/local/lib/python3.5/site-packages/netmiko/ssh_dispatcher.py", line 84, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 69, in __init__
    self.session_preparation()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 83, in session_preparation
    self.disable_paging()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 212, in disable_paging
    output = self.read_until_prompt()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 374, in read_until_prompt
    return self.read_until_pattern()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 393, in read_until_pattern
    raise NetMikoTimeoutException("Timed-out reading channel, data not available.")
netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.

I'm running the latest version of Netmiko and Paramiko. It is working perfect with Juniper devices.

UPDATE: I have tried my script using a truly Cisco IOS and it works with no problem. So I believe the issue is the compatibility with the Cisco SG line. I have also tried to make Paramiko works with this Cisco SG device but it hangs on the connection and never times out. Hope this info will help.

Would you have any idea on whawt to try next?

Thanks you so much.

Sam.

lundybernard commented 8 years ago

Found the solution for my issue, hope it helps someone else. Problem command is: aaa authentication fail-message ^ documentation

proper command (in my yaml file)

    - |
        aaa authentication fail-message ^
        +-------------------------------------------------------------+
        |      All Connection attempts are recorded.                  |
        |-------------------------------------------------------------|
        |  If you are authorized and having trouble connecting please |
        |  contact (###)###-####.                                     |
        +-------------------------------------------------------------+
        ^

In this formar pyyaml will parse the command, and netmiko will be able to set it properly.

ghmj2417 commented 8 years ago

@ktbyers

@lundybernard Are you changing the hostname as part of this change?

I encountered this same error when doing what you just asked. I am using Netmiko for auto deployment of my Cisco routers and I change the hostname of the router. I am assuming the hostname is part of finding your prompt? Workaround is to create a new SSH session. I'm guessing you would label this as an enhancement and not really a bug?

ktbyers commented 8 years ago

@ghmj2417 Can you provide a little more context on what you are doing?

You are using send_config_set() and trying to change the hostname?

ghmj2417 commented 8 years ago

@ktbyers Of course, First, I am creating a ssh_conn and using scp_handler to transfer a deployment config to a router. This configuration has a bunch of config on it that includes modifying the hostname of the router. I transfer the config to the router, and then issue a send_config_set([copy xxx running-config]) to merge the deployment config with the running-config. At that point, a new hostname is now on the router. I then need to issue some additional commands. When I attempt to do so I receive this error. I assume it has to do with changing the hostname. It took me awhile to figure out but my workaround is to create a new SSH session and everything works.

ktbyers commented 8 years ago

@ghmj2417 FYI, napalm-ios driver which is based on Netmiko handles the above. Here is what I did there:

    def _commit_hostname_handler(self, cmd):
        """Special handler for hostname change on commit operation."""
        try:
            current_prompt = self.device.find_prompt()
            # Wait 12 seconds for output to come back (.2 * 60)
            output = self.device.send_command_expect(cmd, delay_factor=.2, max_loops=60)
        except IOError:
            # Check if hostname change
            if current_prompt == self.device.find_prompt():
                raise
            else:
                self.device.set_base_prompt()
                output = ''
        return output
ghmj2417 commented 8 years ago

@ktbyers Nice, that's awesome! Well done!

I would probably need to issue a PR on napalm-ios. We would need to add a key_file option into napalm-ios so I can use a private key for authentication (yup, I am that guy). Possibly specify it in optional_args, do a get in init, and then in open(self) pass it to ConnectHandler. That's probably not the most glamorous implementation for key_file but it should work.

ktbyers commented 8 years ago

@ghmj2417 Okay, added an issue in napalm-ios to add support for keys. It should be there. I probably try to do it on the napalm hackathon in September.

ktbyers commented 8 years ago

I don't think there are any other actions to take on this issue...so closing it.

Eoin-Irwin commented 7 years ago

I seem to also be getting the same error, however its on a cisco 2960 switch

` Device: Cisco IOS

Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 1596, in globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3\helpers\pydev\pydevd.py", line 974, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:/Users/irwin/PycharmProjects/lldp_tool/lldp_tool/protocols/lldp.py", line 495, in main() File "C:/Users/irwin/PycharmProjects/lldp_tool/lldp_tool/protocols/lldp.py", line 209, in get_lldp connection.enable() File "C:\Users\irwin\Anaconda2\lib\site-packages\netmiko\cisco_base_connection.py", line 15, in enable return super(CiscoBaseConnection, self).enable(cmd=cmd, pattern=pattern, re_flags=re_flags) File "C:\Users\irwin\Anaconda2\lib\site-packages\netmiko\base_connection.py", line 737, in enable output += self.read_until_prompt() File "C:\Users\irwin\Anaconda2\lib\site-packages\netmiko\base_connection.py", line 192, in read_until_prompt return self._read_channel_expect(*args, **kwargs) File "C:\Users\irwin\Anaconda2\lib\site-packages\netmiko\base_connection.py", line 149, in _read_channel_expect raise NetMikoTimeoutException("Timed-out reading channel, data not available.")

netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.

When I try and run the enable command I am getting the above error.  

    connection.find_prompt()
        connection.enable()
        switch_commands = ['conf t', 'hostname cisco_switch_spare', 'int range fa0/1-24', 'shutdown']
        switch_output = connection.send_config_set(switch_commands)
        print(switch_output)

        connection.find_prompt() is showing the following
        u'Switch> `     
ktbyers commented 7 years ago

Are you passing in a secret to ConnectHandler()?

In other words, have declared what the enable secret is?

Eoin-Irwin commented 7 years ago

Ahhh that's most likely my issue! I'll test that out tomorrow when I get access to the switches, thanks Kirk

Eoin-Irwin commented 7 years ago

`The secret argument did the trick. However when I try to configure the switch, the configurations work sometimes, but I still get the error in my python console which says;

"Timed-out reading channel, data not available"

Then when I re-run the program about 3/4 times it will work more consistently. Any ideas?

I am also doing a show lldp neighbors, show ip int brief and show vlan brief. Before I decided to make config changes these show commands worked perfect, I would gladly change a time.sleep/global_delay if it meant this would work on a more consistent basis.

            connection.find_prompt()
            connection.enable()
            switch_commands = ['hostname cisco_switch_spare', 'username cisco_switch_spare password secretpass',
                               'enable secret untested', 'no cdp run', 'int range fa0/1-23',
                               'switchport access vlan 437', 'shutdown']
            switch_output = connection.send_config_set(switch_commands)
            time.sleep(3)
            pprint(switch_output) `
ktbyers commented 7 years ago

@Eoin-Irwin Changing the hostname is problematic as it changes the prompt. I would probably do that separately (in some way).

Once you have removed the hostname, I would increase the delay factor.

# Try delay_factor =2 and if that doesn't work 4
switch_output = connection.send_config_set(switch_commands, delay_factor=2)
Eoin-Irwin commented 7 years ago

@ktbyers Neither of them worked!

EDIT: It works now, I just had to increase the delay time to 5. Instead, I've removed commands and put in delay_factor=4.

Thanks for all the help Kirk!

ktbyers commented 7 years ago

@Eoin-Irwin It could be that the interface range is slow command is slow?

Eoin-Irwin commented 7 years ago

It made a considerable difference without the interface range command

ktbyers commented 7 years ago

Yes, I thought that might cause delay...I still might need to make some improvements here.

hardcorecoder27 commented 7 years ago

@ktbyers Am just a beginner in using netmiko. Can you explain in simple words what is the use of read_channel and write_channel? Is read_channel a functionality to display output of show commands?? Is write channel a functionality send config commands? I have been browsing for sample programs relted to the same functions. Couldn't find any.

ktbyers commented 7 years ago

@hardcorecoder27 read_channel() and write_channel() are low level methods that let you directly control the channel (whether SSH or telnet). There is really nothing between these and the channel i.e. what you put out using write_channel() will get sent to the device.

Note, this implies certain things. For example, you will need to add a `\n' to indicate you hit enter. You will also need to introduce a delay between when you write and when you read (as your script will be faster than the router).

In general, you should be using send_command() for show commands and send_config_set() for config changes and not write_channel, read_channel. You can use them, but it should be more the exception than standard practice.

ktbyers commented 7 years ago

Please do not comment any more on this issue (open a new issue instead).

This issue already contains numerous separate items so adding to it will just cause confusion.