napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

"ValueError: Unable to find prompt" on commit_config() operation #197

Closed briantsaunders closed 6 years ago

briantsaunders commented 7 years ago

Description of Issue/Question

Attempting to perform a commit_config() operation on a Cisco Catalyst 3850 device. I modify the global_delay_factor to 120 and still receive the error. When I manually enter the "configure replace candidate.txt force revert trigger error" on the device it takes greater than 20 seconds for the prompt to return. I noticed in the _commit_hostname_handler function in the ios.py code that the default only waits 12 seconds. Not sure if this is related or not.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

Setup

napalm-ios version

(Paste verbatim output from pip freeze | grep napalm-ios between quotes below)

napalm-ios==0.7.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06E RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2016 by Cisco Systems, Inc.
Compiled Sat 17-Dec-16 00:22 by prod_rel_team

Cisco IOS-XE software, Copyright (c) 2005-2015 by cisco Systems, Inc.
All rights reserved.  Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0.  The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0.
(http://www.gnu.org/licenses/gpl-2.0.html) For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.

ROM: IOS-XE ROMMON
BOOTLDR: CAT3K_CAA Boot Loader (CAT3K_CAA-HBOOT-M) Version 3.58, RELEASE SOFTWARE (P)

agg-cat3850-01 uptime is 1 week, 5 days, 23 hours, 57 minutes
Uptime for this control processor is 1 week, 6 days, 0 minutes
System returned to ROM by Power Failure
System restarted at 16:00:21 UTC Tue Sep 5 2017
System image file is "flash:packages.conf"
Last reload reason: Power Failure

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.

License Level: Ipservices
License Type: Permanent
Next reload license Level: Ipservices

cisco WS-C3850-48P (MIPS) processor with 4194304K bytes of physical memory.
Processor board ID FCW2121F08S
13 Virtual Ethernet interfaces
52 Gigabit Ethernet interfaces
4 Ten Gigabit Ethernet interfaces
2048K bytes of non-volatile configuration memory.
4194304K bytes of physical memory.
252000K bytes of Crash Files at crashinfo:.
1611414K bytes of Flash at flash:.
0K bytes of Dummy USB Flash at usbflash0:.
0K bytes of  at webui:.

Base Ethernet MAC Address          : 00:08:32:d5:74:00
Motherboard Assembly Number        : 73-15800-08
Motherboard Serial Number          : FOC21196A79
Model Revision Number              : AB0
Motherboard Revision Number        : A0
Model Number                       : WS-C3850-48P
System Serial Number               : FCW2121F08S

Switch Ports Model              SW Version        SW Image              Mode
------ ----- -----              ----------        ----------            ----
*    1 56    WS-C3850-48P       03.06.06E         cat3k_caa-universalk9 INSTALL

Configuration register is 0x102

Steps to Reproduce the Issue

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/napalm_ios/ios.py", line 393, in commit_config
    output = self._commit_hostname_handler(cmd)
  File "/Library/Python/2.7/site-packages/napalm_ios/ios.py", line 367, in _commit_hostname_handler
    if current_prompt == self.device.find_prompt():
  File "/Library/Python/2.7/site-packages/netmiko/base_connection.py", line 691, in find_prompt
    raise ValueError("Unable to find prompt: {}".format(prompt))
ValueError: Unable to find prompt: 
ktbyers commented 7 years ago

Better solution needs created for the hostname handler or more time allocated...too many failures just due to delay of loading the configuration.

fherbet commented 7 years ago

Have same issue when i push NAT config on any IOS devices... device lags when it has NAT applied and then i get :

TASK [napalm_install_config] *** fatal: [170501795]: FAILED! => {"changed": false, "failed": true, "msg": "cannot install config: Unable to find prompt: "}

even though config is properly applied...

ktbyers commented 7 years ago

@fherbet You might turn on logging to get more details on your issue:

https://github.com/ktbyers/netmiko/blob/develop/COMMON_ISSUES.md#enable-netmiko-logging-of-all-reads-and-writes-of-the-communications-channel

Are you doing a replace or a merge operation?

Note, the above error is a pretty generic Netmiko error so it may nor not be the same cause as the above issue.

ktbyers commented 7 years ago

Proposed fix is here.

https://github.com/napalm-automation/napalm-ios/pull/207

@briantsaunders It would be interesting to know if the new solution works for your Catalyst 3850. You should not need to set the global_delay_factor here.

briantsaunders commented 7 years ago

@ktbyers sure, i can test it out. how do I get the fix loaded into my environment?

ktbyers commented 7 years ago

@briantsaunders You should be able to do something like the following:

# Create a new git clone
git clone https://github.com/napalm-automation/napalm-ios
cd napalm-ios
# Make a new branch based upon develop branch
git checkout -b ktbyers-improve_hostname_handler develop
# Pull all my changes into that branch
git pull https://github.com/ktbyers/napalm-ios.git improve_hostname_handler

# From napalm-ios directory (use this new branch as the active code to use)
# Make sure okay in the virtual environment you are in (or rollback to previous napalm-ios when done)
pip install -e .
briantsaunders commented 7 years ago

@ktbyers Just tested it on the 3850 I had previous issues with, no errors this time around upon commit_config().

>>> from napalm import get_network_driver
>>> driver = get_network_driver('ios')
>>> session = driver('10.253.182.6', 'admin', 'xxxxxx')
>>> session.open()
>>> import os
>>> filePath = os.path.join('candidate.txt')
>>> print filePath
candidate.txt
>>> session.load_replace_candidate(filePath)
>>> session.compare_config()
u'interface GigabitEthernet1/0/3\n +description This is a test\n-ip scp server enable'
>>> session.commit_config()
>>> session.get_facts()
{u'os_version': u'IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06E RELEASE SOFTWARE (fc1)', u'uptime': 2518920, u'interface_list': [u'Vlan1', u'Vlan10', u'Vlan20', u'Vlan30', u'Vlan40', u'Vlan50', u'Vlan60', u'Vlan70', u'Vlan80', u'Vlan90', u'Vlan100', u'Vlan110', u'Vlan120', u'GigabitEthernet0/0', u'GigabitEthernet1/0/1', u'GigabitEthernet1/0/2', u'GigabitEthernet1/0/3', u'GigabitEthernet1/0/4', u'GigabitEthernet1/0/5', u'GigabitEthernet1/0/6', u'GigabitEthernet1/0/7', u'GigabitEthernet1/0/8', u'GigabitEthernet1/0/9', u'GigabitEthernet1/0/10', u'GigabitEthernet1/0/11', u'GigabitEthernet1/0/12', u'GigabitEthernet1/0/13', u'GigabitEthernet1/0/14', u'GigabitEthernet1/0/15', u'GigabitEthernet1/0/16', u'GigabitEthernet1/0/17', u'GigabitEthernet1/0/18', u'GigabitEthernet1/0/19', u'GigabitEthernet1/0/20', u'GigabitEthernet1/0/21', u'GigabitEthernet1/0/22', u'GigabitEthernet1/0/23', u'GigabitEthernet1/0/24', u'GigabitEthernet1/0/25', u'GigabitEthernet1/0/26', u'GigabitEthernet1/0/27', u'GigabitEthernet1/0/28', u'GigabitEthernet1/0/29', u'GigabitEthernet1/0/30', u'GigabitEthernet1/0/31', u'GigabitEthernet1/0/32', u'GigabitEthernet1/0/33', u'GigabitEthernet1/0/34', u'GigabitEthernet1/0/35', u'GigabitEthernet1/0/36', u'GigabitEthernet1/0/37', u'GigabitEthernet1/0/38', u'GigabitEthernet1/0/39', u'GigabitEthernet1/0/40', u'GigabitEthernet1/0/41', u'GigabitEthernet1/0/42', u'GigabitEthernet1/0/43', u'GigabitEthernet1/0/44', u'GigabitEthernet1/0/45', u'GigabitEthernet1/0/46', u'GigabitEthernet1/0/47', u'GigabitEthernet1/0/48', u'GigabitEthernet1/1/1', u'GigabitEthernet1/1/2', u'GigabitEthernet1/1/3', u'GigabitEthernet1/1/4', u'Te1/1/1', u'Te1/1/2', u'Te1/1/3', u'Te1/1/4', u'Loopback0'], u'vendor': u'Cisco', u'serial_number': u'FCW2121F08S', u'model': u'WS-C3850-48P', u'hostname': u'agg-cat3850-01', u'fqdn': u'agg-cat3850-01.sandbox.local'}
>>> session.close()
>>>
ktbyers commented 7 years ago

@briantsaunders Nice...thanks.

carlgevans commented 7 years ago

@ktbyers I had the same issue and this update resolved it on an 887VA with IOS 15.4(3)M8. Thank you :-)

mirceaulinic commented 6 years ago

Hi @briantsaunders - we are currently in the process of reunification, please check https://napalm-automation.net/reunification/. Going forward, we'd like to ask you to submit Pull Requests and Issue to the main repository: https://github.com/napalm-automation/napalm. I believe this has been already fixed via https://github.com/napalm-automation/napalm-ios/commit/13fc6c4ceb2c57e8df25e34773fd7f6b5f2be5ba. Otherwise, please feel free to reopen at https://github.com/napalm-automation/napalm/issues.

Thanks for understanding!

LongBeachHXC commented 6 years ago

Hey Team,

I was experiencing this same issue on an IOS-XE switch version 3.07.05. I upgraded my netmiko, napalm_base, and napalm_ios modules to most recent and this fixed the 'unable to find prompt' issue.

Thank you all!