napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.26k stars 555 forks source link

Disabling Paging and Setting Terminal Width fails on IOS when user privilege is 0 #1166

Open msartuche opened 4 years ago

msartuche commented 4 years ago

IOS Device doesn't disable paging or set the terminal width properly when user privilege is 0

  1. If you login with a user that has a privilege level 0 napalm doesn't verify that paging is truly disabled, this looks more like a possible netmiko bug than napalm but discovered it using napalm since netmiko isn't making sure the terminal length and terminal width commands are sent without any errors.
    • Could look at adding a method to verify that the settings are in place and if not, then use the disable_paging() and set_terminal_width(command="terminal width 511") netmiko methods AFTER the enable() method or just send them after the enable() method. I made modifications to the base.py file and was able to get around this issue on the boxes I'm working on.

      Example of what the terminal settings output should look like.

      test881#show terminal | inc ength
      Length: 0 lines, Width: 512 columns
  2. I enabled the following netmiko optional arguments to see what was happening:
    • verbose: True
    • session_log_record_writes: True
  3. Looking at the output I can see that during the setup, netmiko establishes a connection without issue, then immediately performs a session preparation which disables paging and sets terminal width which both fail

    Failure example output:

    
    test881>
    test881>terminal length 0
    terminal length 0
                   ^
    % Invalid input detected at '^' marker.

test881>terminal width 511 terminal width 511 ^ % Invalid input detected at '^' marker.

test881>

test881>enable enable Password: ****

test881#

### Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an ``x`` between the square brackets where applicable)

- [X] Yes
- [] No

### Setup

### napalm version
(Paste verbatim output from `pip freeze | grep napalm` between quotes below)

C:\Users\msartuche>python -m pip freeze | grep napalm napalm==2.5.0


### Network operating system version
(Paste verbatim output from `show version` - or equivalent - between quotes below)

Cisco IOS Software, C800 Software (C800-UNIVERSALK9-M), Version 15.4(3)M10, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 08-Aug-18 06:30 by prod_rel_team

ROM: System Bootstrap, Version 15.4(1r)T1, RELEASE SOFTWARE (fc1)

test881 uptime is 3 days, 6 hours, 52 minutes System returned to ROM by reload at 01:14:50 EDT Mon Apr 6 2020 System restarted at 01:17:24 EDT Mon Apr 6 2020 System image file is "flash:c800-universalk9-mz.SPA.154-3.M10.bin" Last reload type: Normal Reload Last reload reason: Embedded Event Manager action

This product contains cryptographic features and is subject to United States and local country laws governing import, export, transfer and use. Delivery of Cisco cryptographic products does not imply third-party authority to import, export, distribute or use encryption. Importers, exporters, distributors and users are responsible for compliance with U.S. and local country laws. By using this product you agree to comply with applicable laws and regulations. If you are unable to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at: http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to export@cisco.com.

Cisco C881-K9 (revision 1.0) with 488524K/35763K bytes of memory. Processor board ID FJC2046L0DN 5 FastEthernet interfaces 1 Virtual Private Network (VPN) Module DRAM configuration is 32 bits wide 255K bytes of non-volatile configuration memory. 250880K bytes of ATA System CompactFlash (Read/Write)

License Info:

License UDI:


Device# PID SN

*1 C881-K9 FJC2046L0DN

License Information for 'c800' License Level: advipservices Type: Permanent Next reboot license Level: advipservices

Configuration register is 0x102


### Steps to Reproduce the Issue

### Error Traceback
(Paste the complete traceback of the exception between quotes below)

2020-04-09 07:42:17,656 - nornir.core.task - ERROR - start() - Host 'test881': task 'napalm_get' failed with traceback: Traceback (most recent call last): File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm\ios\ios.py", line 204, in _send_command output = self.device.send_command(command) File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 1337, in send_command search_pattern OSError: Search pattern never detected in send_command_expect: test881#

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\nornir\core\task.py", line 85, in start r = self.task(self, self.params) File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\nornir\plugins\tasks\networking\napalm_get.py", line 61, in napalm_get result[g] = method(options) File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm\ios\ios.py", line 3367, in get_config output = self._send_command(command) File "C:\Users\msartuche\AppData\Local\Programs\Python\Python37\lib\site-packages\napalm\ios\ios.py", line 207, in _send_command raise ConnectionClosedException(str(e)) napalm.base.exceptions.ConnectionClosedException: Search pattern never detected in send_command_expect: test881#

ktbyers commented 4 years ago

We should bump this as a Netmiko issue. The fix will be to raise an exception if this happens.

In other words, output paging has to always be disabled and if we can't at some point, then Netmiko will stop and raise an Exception.

msartuche commented 4 years ago

I can open an issue on the Netmiko github if you’d like.

ktbyers commented 4 years ago

Sounds good.