napalm-automation / napalm

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

Processing error in IOS get_environment #988

Open bewing opened 5 years ago

bewing commented 5 years ago

Description of Issue/Question

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

(Place an x between the square brackets where applicable)

Setup

napalm version

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

napalm.git@1c1cb4f6

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch  Software (cat4500es8-UNIVERSALK9-M), Version 03.08.04.E RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2017 by Cisco Systems, Inc.
Compiled Thu 06-Apr-17 08:19 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: 15.1(1r)SG5
ios01 uptime is 2 years, 4 weeks, 6 days, 21 hours, 33 minutes
Uptime for this control processor is 2 years, 4 weeks, 6 days, 21 hours, 35 minutes
System returned to ROM by reload
System restarted at 11:18:54 CDT Mon Apr 17 2017
System image file is "bootflash:cat4500es8-universalk9.SPA.03.08.04.E.152-4.E4.bin"
Jawa Revision 3, RadTrooper Revision 0x0.0x41, Conan Revision 0x1B9E

Last reload reason: Reload command

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 Information for 'WS-X45-SUP8-E'
    License Level: entservices   Type: Permanent
    Next reboot license Level: entservices

cisco WS-C4510R+E (P5040) processor (revision 2) with 4194304K bytes of physical memory.
Processor board ID 012346789
P5040 CPU at 2.2GHz, Supervisor 8-E
Last reset from Reload
2 Virtual Ethernet interfaces
288 Gigabit Ethernet interfaces
16 Ten Gigabit Ethernet interfaces
511K bytes of non-volatile configuration memory.

Configuration register is 0x2

Steps to Reproduce the Issue

In [4]: with IOSDriver("ios01", os.environ.get("NAPALM_USERNAME"), os.environ.get("NAPALM_PASSWORD")) as d:
   ...:     d.get_environment()

Error Traceback

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

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-4-c2041c90174b> in <module>
      1 with IOSDriver("ios01", os.environ.get("NAPALM_USERNAME"), os.environ.get("NAPALM_PASSWORD")) as d:
----> 2     d.get_environment()
      3

/mnt/c/Users/bewing/PycharmProjects/napalm/napalm/ios/ios.py in get_environment(self)
   2101             elif "I/O" in line or "io" in line:
   2102                 _, _, io_total_mem, io_used_mem, _ = line.split()[:5]
-> 2103         total_mem = int(proc_total_mem) + int(io_total_mem)
   2104         used_mem = int(proc_used_mem) + int(io_used_mem)
   2105         environment.setdefault("memory", {})

UnboundLocalError: local variable 'proc_total_mem' referenced before assignment
bewing commented 5 years ago

Device output:

ios01#show memory statistics
                     ^
% Invalid input detected at '^' marker.

ios01#show memory
System memory   : 3870192K total, 993346K used, 2876846K free, 324112K kernel reserved
Lowest(b)       : 2458778072

                Total(K)     Used(K)      Free(K)
Process         2924016      626325       2297692
Config          946176       367022       579154