Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_environment not working on IOS-XE using the IOS driver #1052

Open
1 task done
tcaiazza opened this issue Sep 18, 2019 · 0 comments
Open
1 task done

get_environment not working on IOS-XE using the IOS driver #1052

tcaiazza opened this issue Sep 18, 2019 · 0 comments

Comments

@tcaiazza
Copy link
Contributor

Description of Issue/Question

When I try to use the get_environment() on an ios-xe device of mine I get the following stack trace

/home/tim/code/napalm/napalm/ios/ios.py in get_environment(self)
   2098         if "Invalid input detected at" not in output:
   2099             for line in output.splitlines():
-> 2100                 if "Processor" in line:
   2101                     _, _, proc_total_mem, proc_used_mem, _ = line.split()[:5]
   2102                 elif "I/O" in line or "io" in line:

UnboundLocalError: local variable 'proc_total_mem' referenced before assignment

The ios driver is looking to run the command show memory statistics which isn't valid on an ios-xe device, the command is just show memory

Note: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

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

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

napalm version

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

napalm==2.4.0

Network operating system version

(Paste verbatim output from show version - or equivalent - 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)

core1 uptime is 3 weeks, 2 days, 7 hours, 12 minutes
Uptime for this control processor is 3 weeks, 2 days, 7 hours, 15 minutes
System returned to ROM by Power Failure
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 FCW2103F010
6 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          : 
Motherboard Assembly Number        : 
Motherboard Serial Number          :
Model Revision Number              : AB0
Motherboard Revision Number        : A0
Model Number                       : WS-C3850-48P
System Serial Number               :


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

Connect to a device running ios-xe and run the function get_environment()

Error Traceback

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

/home/tim/code/napalm/napalm/ios/ios.py in get_environment(self)
   2098         if "Invalid input detected at" not in output:
   2099             for line in output.splitlines():
-> 2100                 if "Processor" in line:
   2101                     _, _, proc_total_mem, proc_used_mem, _ = line.split()[:5]
   2102                 elif "I/O" in line or "io" in line:

UnboundLocalError: local variable 'proc_total_mem' referenced before assignment
tcaiazza added a commit to tcaiazza/napalm that referenced this issue Sep 18, 2019
* fixes issue napalm-automation#1052
* add tests for get_environment on ios-xe devices
tcaiazza added a commit to tcaiazza/napalm that referenced this issue Sep 18, 2019
* fixes issue napalm-automation#1052
* add tests for get_environment on ios-xe devices
mirceaulinic pushed a commit that referenced this issue Oct 4, 2019
* fixes issue #1052
* add tests for get_environment on ios-xe devices
mirceaulinic added a commit that referenced this issue Oct 10, 2019
* namespace fix for napalm cli (#950)

* Fix broken get_bgp_neighbors when 6PE configured on eos (#945)

* fix _RE_BGP_PREFIX and NEIGHBOR_FILTER for 6PE into eos

* add testcase for 6PE version

* Renamed testcase mocked file for regexp syntax change

* If parent_table None call exception (#939)

Hi, i have this situation when ipv6 is turned off:
$ napalm --user oxi --password gdfw23 --vendor nxos  10.143.36.8 call get_interfaces_ip
2019-03-07 15:08:10,226 - napalm - ERROR - method - Failed: 'NoneType' object has no attribute 'get'

================= Traceback =================

Traceback (most recent call last):
  File "/opt/py3.6/bin/napalm", line 10, in <module>
    sys.exit(main())
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 309, in main
    run_tests(args)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 292, in run_tests
    call_getter(device, args.method, **method_kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 31, in wrapper
    r = func(*args, **kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 256, in call_getter
    r = func(**kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 1091, in get_interfaces_ip
    ipv6_command, "TABLE_intf", "ROW_intf"
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 721, in _get_command_table
    return self._get_reply_table(json_output, table_name, row_name)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 717, in _get_reply_table
    return self._get_table_rows(result, table_name, row_name)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 706, in _get_table_rows
    _table = parent_table.get(table_name)
AttributeError: 'NoneType' object has no attribute 'get'

* Remove extensive argument from junos_iface_table (#929)

Fixes #928

* Add GitHub issue template, as we used to have before (#961)

When we used to maintain separare NAPALM drivers, we had an issue template
looking like this:
napalm-automation/napalm-junos@110fec4#diff-faa36bc26a21ed93c8de974753b71507.

I was looking today through the issues we currently have open, and
I found some of them a bit chaotic, and hard to understand the context
/ environment the user runs. Additionally, some, e.g., #960, is really
hard to follow, and I've included a note to invite the user to check the
HitGub markdown manual.

* NXOS_SSH get_route_to (updated) (#914)

* Add MTU support to get_interface (#940)

* Feature/ios get bgp config (#897)

* support n9k ipv6 ints for interfaces_ip getter (#969)

* support catalyst vss for mac_address getter (#968)

* support getting auto-negotiated speed on junos (#967)

* [IOS] Raise exception if BGP neighbor info requested and BGP not running (#970)

* Implement nxos_ssh get_environment (#973)

* Switch Docker image to Python 3 and reduce the number of layers and size (#980)

* Better handling of connection closing upon exceptions in __enter__ (#994)

* Fix incorrect get_interfaces_ip parsing on n9k with IPv6 addresses (#997)

* Modernize docs for FreeBSD installation (#993)

* Fix nxos and nxos_ssh hostname change handling (#999)

* Update link location in the docs (#1002)

* Hostname fixes for NXOS and IOS (#1007)

* Clean up the documentation contribution section (#1004)

* <exception>.message is no longer a thing in Python3 (#1016)

* Added option to show run all (#1029)

* Update ISSUE_TEMPLATE

Removing the space between the brackets, as it seems like it's confusing the users.

* junos add optional arg for DB config selection (#1035)

* fix junos issue #1028 (#1032)

* fix junos issue #1028

* junos add test case for get_network_instances

* Incorrectly taken serial number in NXOS. (#1025)

* The serial number is taken incorrectly, in particular,
the "Processor Board ID" is displayed,
and you need a Chassis -> serialnum:

* Additional safety net for the lack of a serial number in the output.

* black test

* mov function _get_table_rows, _get_reply_table and _get_command_table
from class  NXOSDriver to NXOSDriverBase, because used in NXOSSSHDriver.

* Added verification and conversion from string to json

* Implemented  lock_disable for EOS based on Junos. (#1042)

To fix(?) issue #1041 - #1041
On branch eos-lock-disable-flag
Changes to be committed:
    modified:   napalm/eos/eos.py

* #1025 Work around NXAPI double quoting (#1048)

* #1025 Work around NXAPI double quoting

The NXAPI on the Nexus 9000 platform seems to be double-quoting the name of inventory items.

Amend the check for the inventory item name to take this into account.

* the output of the N9000 has extra quotes:

show inventory | json
{"TABLE_inv": {"ROW_inv": [{"name": "\"Chassis\"",
"desc": "\"Nexus9000 C92160YC-X chassis\"",.......

* #1046 Use new dictionary key to fetch OS version (#1047)

Some Cisco Nexus equipment doesn’t have `sys_ver_str`, but has `rr_sys_ver` instead. Use this as a backup.

* Add get_environment support for NXOS driver (#1054)

* napalm.nxos.traceroute - VRF traces and handle AS in hops (#989)

* Adding traceroute from a specific VRF

* Combination of source and vrf command

* On some devices running BGP, an AS number will appear after the IP address of the hop

* E261 at least two spaces before inline comment [pep8]

* Fix extra line in show ip int brief on IOS (#986)

* keep nxos consistent with ios for rollback of failed merge (#860)

* IOS: add support for VRF for get_arp_table func (#937)

Simply takes into account the vrf function arg and exec
the expected ios command.

* ios get_bgp_neighbors vrf and safi aware (#768)

* get_bgp_neighbors vrf support

* afi string contains afi modifier

* mocked data, minor changes

* afi string with afi modifier

* supported afis

* mocked data

* comments

* typo

* show arp vrf ios test

* black reformated

* Check if temperature sensor on Cisco device is not supported (#1055)

* Check if temperature sensor on Cisco device is not supported

Some older Cisco devices like models from the 2960 platform have no temperature sensor built-in. In that case the get_environment function will throw on exception. That case will now be handeled.

* Correct if check

* Fixes get_environment memory collection on ios-xe devices (#1053)

* fixes issue #1052
* add tests for get_environment on ios-xe devices

* Pin PyEZ to 2.2.1 (#1061)

* get_route_to implementation for IOS (#750)

* 1st functional config

* bgp protocol attributes added

* linting, minor changes

* test_get_route_to mocked_data

* linting errors fix

* comments, minor changes in bgp procesing

* bgp processing separated

* bgp support 7200 old

* new bgp processing

* mocked data global routing table

* comments, _get_vrfs update

* mocked data c7200

* bug in regex

* connected, next-hop regex changed,..

* community + ext.community, comments

* linting

* RE_RDB1 regex fixed

* asr_pe test

* typo

* typo

* typo in mocked data - vrf Test -> TEST

* longer parameter added (PR735)

* rollback to pass test_method_signatures ...

* bgp_time_conversion duplicity fixed

* community regex fixed

* code optimization

* module constant, variables renaming

* black reformated

* sh arp vrf test

* When asPathType is Internal (IBGP), as_path is empty and the remote-as is the local_as (#1064)

* Pin Netmiko to version 2.4.2 (#1066)

* Release 2.5.0 (#1063)
ExaneServerTeam pushed a commit to ExaneServerTeam/napalm that referenced this issue Mar 6, 2020
neelimapp pushed a commit to neelimapp/napalm that referenced this issue Mar 20, 2020
bharath-ravindranath pushed a commit to bharath-ravindranath/napalm that referenced this issue Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants