napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

get_facts() errors if "show hosts" command returns nothing #200

Closed briantsaunders closed 6 years ago

briantsaunders commented 7 years ago

Description of Issue/Question

Issuing get_facts() on an IOS device that does not return any data on a "show hosts" command causes an error.

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)

$ pip freeze | grep napalm-ios
napalm-ios==0.7.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software [Denali], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.1a, RELEASE SOFTWARE (fc4)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2016 by Cisco Systems, Inc.
Compiled Thu 29-Sep-16 22:08 by mcpre

Cisco IOS-XE software, Copyright (c) 2005-2016 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.  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.78, RELEASE SOFTWARE (P)

CAT-3850X-G uptime is 5 weeks, 4 days, 22 hours, 17 minutes
Uptime for this control processor is 5 weeks, 4 days, 22 hours, 19 minutes
System returned to ROM by Power Failure at 15:56:18 UTC Thu Jun 22 2017
System restarted at 14:52:48 CST Fri Aug 11 2017
System image file is "flash:cat3k_caa-universalk9.16.03.01a.SPA.bin"
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.

Technology Package License Information:

-----------------------------------------------------------------
Technology-package                   Technology-package
Current             Type             Next reboot
------------------------------------------------------------------
ipservicesk9        Permanent        ipservicesk9

cisco WS-C3850-24U (MIPS) processor (revision N0) with 866081K/6147K bytes of memory.
Processor board ID FOC1912X0EL
3 Virtual Ethernet interfaces
28 Gigabit Ethernet interfaces
4 Ten Gigabit Ethernet interfaces
2048K bytes of non-volatile configuration memory.
4194304K bytes of physical memory.
250456K bytes of Crash Files at crashinfo:.
1609272K bytes of Flash at flash:.
0K bytes of  at webui:.

Base Ethernet MAC Address          : 40:a6:e8:ce:56:00
Motherboard Assembly Number        : 73-14984-08
Motherboard Serial Number          : FOC19121GDT
Model Revision Number              : N0
Motherboard Revision Number        : A0
Model Number                       : WS-C3850-24U
System Serial Number               : FOC1912X0EL

Switch Ports Model              SW Version        SW Image              Mode
------ ----- -----              ----------        ----------            ----
*    1 32    WS-C3850-24U       16.3.1            CAT3K_CAA-UNIVERSALK9 BUNDLE

Configuration register is 0x102

Steps to Reproduce the Issue

Attempted on Catalyst 3850 and ISR 4321 and same result experienced when "show hosts" does not return any data.

Error Traceback

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

>>> connect.get_facts()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/napalm_ios/ios.py", line 879, in get_facts
    if domain_name != 'Unknown' and hostname != 'Unknown':
UnboundLocalError: local variable 'domain_name' referenced before assignment
afourmy commented 7 years ago

should be fixed by https://github.com/napalm-automation/napalm-ios/pull/201

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/2a5c1c500130ecd32b848f958dcb3ad78979f1ab. Otherwise, please feel free to reopen at https://github.com/napalm-automation/napalm/issues.

Thanks for understanding!