GithubHelp home page GithubHelp logo

napalm-ios's Introduction

PyPI Build Status Coverage Status

napalm-ios

napalm-ios's People

Contributors

afourmy avatar benmaddison avatar dbarrosop avatar diogoandre avatar ebeahan avatar fooelisa avatar ggabriele avatar itdependsnetworks avatar jedelman8 avatar kaage avatar kbirkela avatar kbirkeland avatar ktbyers avatar lokespotify avatar mirceaulinic avatar mzbenami avatar ogenstad avatar shuichiro-makigaki avatar sjtarik avatar targuan avatar the-loeki avatar ubajze avatar ubaumann avatar xionox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

napalm-ios's Issues

get_lldp_neighbors_detail causes IndexError

>>>Test get lldp neighbors
Traceback (most recent call last):
  File "test_ios.py", line 31, in <module>
    device_int = device.get_lldp_neighbors_detail()
  File "/home/kbyers/applied_python/local/lib/python2.7/site-packages/napalm_ios/ios.py", line 435, in get_lldp_neighbors_detail
    lldp_fields = [pad_list_entries(field, number_entries) for field in lldp_fields]
  File "/home/kbyers/applied_python/local/lib/python2.7/site-packages/napalm_ios/ios.py", line 402, in pad_list_entries
    my_list[i] = u"N/A"
IndexError: list assignment index out of range
pynet-rtr1#show lldp neighbors detail 
------------------------------------------------
Chassis id: 0018.fe1e.b020
Port id: 15
Port Description: 15
System Name: twb-sf-hpsw1

System Description: 
ProCurve J9019A Switch 2510-24, revision Q.10.01, ROM Q.10.02 (/sw/code/build/harp(harp))

Time remaining: 115 seconds
System Capabilities: B
Enabled Capabilities: B
Management Addresses:
    Other: 00 18 FF 1E FF 20 00
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised


Total entries displayed: 1

Napalm to Extreme Network devices

Hello everybody,

Brief introduction:
I've been studing Ansible and Salt for about a week and I found Napalm library two days ago on the internet. I tested Napalm with juniper and cisco (works well, amazing). However, we have almost 90 Extreme Networks switches in our network and they are old devices and with certain limitations, telnet is one of them. I also have a mgtm vlan via telnet to manage them.

So, is it possible to use napalm for this devices via telnet?

Regards.

get_arp_table() bug with static arp entries

Description of Issue/Question

While working with the pytest framework I noticed a bug. Will just ignore this for now and remove the static entry.

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

  • Yes
  • No

Setup

napalm-ios version

napalm-ios==0.4.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)

Steps to Reproduce the Issue

conf term
 arp 10.0.0.1 0010.2345.1cda ARPA

The getter is running:

NS2903-ASW-01#show arp | exclude Incomplete
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  10.0.0.1                -   0010.2345.1cda  ARPA
Internet  172.29.50.1             6   84b8.0276.ac0e  ARPA   Vlan20
Internet  172.29.50.2           219   0019.0725.344a  ARPA   Vlan20
Internet  172.29.50.3             -   0024.f7dd.7741  ARPA   Vlan20
Internet  172.29.50.10           34   6805.ca12.71c2  ARPA   Vlan20
Internet  172.29.52.33           59   84b8.0276.ac0e  ARPA   Vlan41
Internet  172.29.52.34            -   0024.f7dd.7743  ARPA   Vlan41
Internet  172.29.52.40            1   a099.9b1c.dfa7  ARPA   Vlan41
Internet  192.168.81.34           -   0024.f7dd.7743  ARPA   Vlan41

NS2903-ASW-01#

Error Traceback

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

>>> device.open()
>>> a = device.get_arp_table()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/patrick/.virtualenvs/napalm/lib/python2.7/site-packages/napalm_ios/ios.py", line 1177, in get_arp_table
    raise ValueError("Unexpected output from: {}".format(line.split()))
ValueError: Unexpected output from: [u'Internet', u'10.0.0.1', u'-', u'0010.2345.1cda', u'ARPA']
>>>

unit test failure on templates

@dbarrosop @mirceaulinic

I am testing the existing unit tests on napalm-ios and this fails:

DriverTemplateNotImplemented: Config template dir does not exist: /home/gituser/VENV/napalm/local/lib/python2.7/site-packages/napalm_ios-0.2.1-py2.7.egg/napalm_ios/templates.
Please create it and add driver-specific templates.

Is this test expected to fail on napalm_ios (from what I see it is expected to fail)?

Document the following banner behavior on IOS/IOS-XE

I did some tests on this.

It looks like the banner requires the EXT character (ASCII 3). This looks like a cntl-C in the file, but as a single character.

banner motd ^C
my banner test
^C

I wrote it as follows:

>>> ext_char = chr(3)
>>> with open("my_config.conf", "a") as f:
...   f.write("banner motd {}\n".format(ext_char))
...   f.write("my banner test\n")
...   f.write("{}\n".format(ext_char))
... 
>>> quit()

This appended an existing file and then I moved it to where I wanted in the file.

kcelenza [8:50 PM]

in vim insert, you can also type `<ctrl>+ V` release only the V, then type `C`

get_lldp_neighbors fail if capabilities not present

Description of Issue/Question

get_lldp_neighbors failed if device line does not have capabilities. maybe we should implement the case in textfsm and handle it?

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

  • [x ] Yes
  • No

Setup

napalm-ios version

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

napalm-ios==0.4.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSALK9-M), Version 03.03.02.XO RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2014 by Cisco Systems, Inc.
Compiled Tue 19-Aug-14 02:17 by prod_rel_team



Cisco IOS-XE software, Copyright (c) 2005-2013 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: 15.1(1r)SG2

Steps to Reproduce the Issue

Connect a security camera, dell server or any simple device that does not exchange capabilities. Then call get_lldp_neighbors()

Error Traceback

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

  File "/devs/lib/python2.7/site-packages/napalm_ios/ios.py", line 415, in get_lldp_neighbors
    device_id, local_int_brief, hold_time, capability, remote_port = lldp_entry.split()
ValueError: need more than 4 values to unpack

Proposal: change compare_config on merge operation

Cisco IOS has the following:

show archive config incremental-diffs flash:/merge_config.txt

It compares against the running config. This looks like a better solution than what we currently have (which is just to echo the config commands in merge file).

I have a working proof-of-concept of this.

Here is what I observed for behavior:

Test merge file that had:

logging buffered 12000
no logging console

Where this matched what was in current config:

What Cisco IOS returns:

!List of Commands:
end
!No changes were found

What napalm-ios would return:

null string

Test merge file:

logging buffered 10000
no logging console

logging buffer size is different than current config

What Cisco IOS returns:

!List of Commands:
logging buffered 10000
end

What napalm-ios would return:

+logging buffered 10000

Test merge file:

logging buffered 12000
no logging console

router bgp 42
 no neighbor 10.220.88.38
 neighbor 10.220.88.39 remote-as 45
 neighbor 10.220.88.40 remote-as 46

What router current config is:

pynet-rtr1#show run | inc logging
logging buffered 12000
no logging console
pynet-rtr1#show run | section bgp
router bgp 42
 bgp router-id 10.220.88.20
 bgp log-neighbor-changes
 neighbor 10.220.88.38 remote-as 44

What Cisco IOS shows:

!List of Commands:
router bgp 42
 no neighbor 10.220.88.38
 neighbor 10.220.88.39 remote-as 45
 neighbor 10.220.88.40 remote-as 46
end

What napalm-ios would show:

+router bgp 42
- no neighbor 10.220.88.38
+ neighbor 10.220.88.39 remote-as 45
+ neighbor 10.220.88.40 remote-as 46

Note, the '-' prefixing is handled in napalm-ios and is relatively stupid i.e. if the command line starts with a 'no ' it will be prefixed with a minus sign.

recv_ready error for both replace and merge even though change is commited

Traceback (most recent call last):
File "gistfile.py", line 46, in
main()
File "gistfile.py", line 42, in main
device.commit_config()
File "/usr/lib/python2.7/site-packages/napalm_ios/ios.py", line 209, in commit_config
output = self._commit_hostname_handler(cmd)
File "/usr/lib/python2.7/site-packages/napalm_ios/ios.py", line 181, in _commit_hostname_handler
if current_prompt == self.device.find_prompt():
File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 276, in find_prompt
if self.wait_for_recv_ready():
File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 236, in wait_for_recv_ready
raise NetMikoTimeoutException("Timed out waiting for recv_ready")
netmiko.ssh_exception.NetMikoTimeoutException: Timed out waiting for recv_ready

Add handling for exec prompt timestamp

If a cisco ios device is configured with the following:

line vty 0 4
  exec prompt timestamp

it will prepend

Load for five secs: 13%/1%; one minute: 12%; five minutes: 13%
Time source is NTP, 14:09:24.976 EDT Wed Oct 19 2016

to commands. Some commands get an extra empty newline which causes the get function to exit early.

This throws off some of the get commands parsing which are not expecting an extra 2-3 lines

get_facts traceback on IOS-XE device

When trying to do a get_facts on an IOS-XE device, I am getting a traceback.

>>> import napalm
>>> driver = napalm.get_network_driver('ios')
>>> device = driver(hostname='router1', username='ccurtis', password='Password1')
>>> device.open()
>>> device.get_facts()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/napalm_ios/ios.py", line 513, in get_facts
    _, os_version = line.split("Cisco IOS Software, ")
ValueError: need more than 1 value to unpack
>>> 

It is due to the fact that I am running Denali code (16.3.1a) on this device for MPLS support. This is what I did to fix it, but you can probably patch it in a more graceful manner as opposed to ignoring an exception.

if re.search(r"Cisco IOS Software", line):
    try:
        _, os_version = line.split("Cisco IOS Software, ")
    except:
        pass
    try:
        _, os_version = line.split("Cisco IOS Software ")
    except:
        pass
    os_version = os_version.strip()

show version output:

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)    

fauhousing3850-01 uptime is 5 days, 4 hours, 13 minutes
Uptime for this control processor is 5 days, 4 hours, 15 minutes
System returned to ROM by reload at 14:27:42 UTC Wed Oct 12 2016
System image file is "flash:cat3k_caa-universalk9.16.03.01a.SPA.bin"
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
[email protected].    


Technology Package License Information:     

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

cisco WS-C3850-12XS (MIPS) processor (revision K0) with 866081K/6147K bytes of memory.
Processor board ID FOC2028U0P2
1 Virtual Ethernet interface
16 Ten Gigabit Ethernet interfaces
2048K bytes of non-volatile configuration memory.
4194304K bytes of physical memory.
253984K bytes of Crash Files at crashinfo:.
3431232K bytes of Flash at flash:.
0K bytes of  at webui:.    

Base Ethernet MAC Address          : 00:a2:89:56:f1:80
Motherboard Assembly Number        : 73-16295-06
Motherboard Serial Number          : FOC20276N1P
Model Revision Number              : K0
Motherboard Revision Number        : A0
Model Number                       : WS-C3850-12XS
System Serial Number               : FOC2029U0K2    


Switch Ports Model              SW Version        SW Image              Mode   
------ ----- -----              ----------        ----------            ----   
*    1 16    WS-C3850-12XS      16.3.1            CAT3K_CAA-UNIVERSALK9 BUNDLE     


Configuration register is 0x102

After the fix:

>>> import napalm
>>> driver = napalm.get_network_driver('ios')
>>> device = driver(hostname='router1', username='ccurtis', password='Password1')
>>> 
>>> device.open()
>>> device.get_facts()
{'os_version': u'[Denali], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.1a, RELEASE SOFTWARE (fc4)', 'uptime': 447060, 'interface_list': [u'Vlan1', u'GigabitEthernet0/0', u'Te1/0/1', u'Te1/0/2', u'Te1/0/3', u'Te1/0/4', u'Te1/0/5', u'Te1/0/6', u'Te1/0/7', u'Te1/0/8', u'Te1/0/9', u'Te1/0/10', u'Te1/0/11', u'Te1/0/12', u'Te1/1/1', u'Te1/1/2', u'Te1/1/3', u'Te1/1/4', u'Loopback0', u'Loopback112', u'Loopback122', u'Loopback132', u'Loopback142', u'Loopback152', u'Loopback162', u'Loopback182', u'Loopback192'], 'vendor': u'Cisco', 'serial_number': u'FOC2029U0K2', 'model': u'WS-C3850-12XS', 'hostname': u'router1', 'fqdn': u'router1.xxx.edu'}
>>> quit()

get_mac_address_table issue processing multicast entries header

Description of Issue/Question

When called, get_mac_address_table throws exception while processing the multicast entries header from "show mac address-table" output

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

  • Yes
  • No

Setup

napalm-ios version

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

(devs) tarik-mbp:dev tarik$ pip freeze | grep napalm-ios
napalm-ios==0.4.0

Since 0.4.0 only issues "show mac-address-table" cli, I install the library directly from github with
pip install git+git://github.com/napalm-automation/napalm-ios.git

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSALK9-M), Version 03.03.02.XO RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2014 by Cisco Systems, Inc.
Compiled Tue 19-Aug-14 02:17 by prod_rel_team



Cisco IOS-XE software, Copyright (c) 2005-2013 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: 15.1(1r)SG2

Steps to Reproduce the Issue

Error Traceback

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

Traceback (most recent call last):
  File "devs/lib/python2.7/site-packages/napalm_ios/ios.py", line 1429, in get_mac_address_table
    raise ValueError("Unexpected output from: {}".format(repr(line)))
ValueError: Unexpected output from: u'Multicast Entries'

Changes before Hackathon

@dbarrosop @mirceaulinic

I have staged some changes to napalm-ios prior to the Hackathon. I am planning on submitting these once I release Netmiko 1.0 which should be before Thursday.

Here are the changes I made:

  • Adding support to import all Netmiko ConnectHandler arguments. This will add support for SSH keys and for an enable secret.
  • Add version to be a part of the package so you can do napalm_ios.version (i.e. so you clearly check which version of the code you are running).
  • Eliminate PEP257 from pylama.ini (basically want ios.py to 100% pass pylama and PEP257 is too pedantic. I also excepted C901 (McCabe too complex rule). I would rather have fewer rules but require compliance, than more rules and ignore warnings/issues.
  • Fixed issues on get_lldp_neighbors_detail, get_snmp_information, get_mac_address_table that was causing them all to fail when I tested against a real IOS router.
  • Rolled Netmiko requirement to 1.0.

Changes are here:
https://github.com/ktbyers/napalm-ios/tree/devel

Some of these might conflict with other plans you have (particularly pylama.ini changes and setup.py changes) so bringing up here.

Multiple Getters Failing on IOS-XE (ASR1001)

Description of Issue/Question

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

  • Yes
  • No

Setup

napalm-ios version

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

napalm-ios==0.4.0
napalm-iosxr==0.4.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS XE Software, Version 03.16.01a.S - Extended Support Release
Cisco IOS Software, ASR1000 Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.5(3)S1a, 
ROM: IOS-XE ROMMON
iosxe-rtr uptime is 5 weeks, 6 days, 17 hours, 17 minutes
Uptime for this control processor is 5 weeks, 6 days, 17 hours, 18 minutes
System returned to ROM by reload at 04:39:13 UTC Wed Oct 19 2016
System image file is "bootflash:asr1001x-universalk9.03.16.01a.S.155-3.S1a-ext.SPA.bi"
Last reload reason: Reload Command
cisco ASR1001-X (1NG) processor (revision 1NG) with 3729813K/6147K bytes of memory.
Configuration register is 0x2102

Steps to Reproduce the Issue

device.get_bgp_neighbors()
device.get_facts()
device.get_arp_table()
device.get_interfaces()
device.get_interfaces_ip()

Error Traceback

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

>>> device.get_bgp_neighbors()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/napalm_ios/ios.py", line 917, in get_bgp_neighbors
    out_queue, up_time, state_prefix = fields
ValueError: need more than 1 value to unpack

>>> device.get_facts()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/napalm_ios/ios.py", line 583, in get_facts
    interface = line.split()[0]
IndexError: list index out of range

>>> device.get_arp_table()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/napalm_ios/ios.py", line 1177, in get_arp_table
    raise ValueError("Unexpected output from: {}".format(line.split()))
ValueError: Unexpected output from: [u'Time', u'source', u'is', u'NTP,', u'*22:05:56.858', u'UTC', u'Tue', u'Nov', u'29', u'2016']

>>> device.get_interfaces()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/napalm_ios/ios.py", line 663, in get_interfaces
    raise ValueError(u"Unexpected Response from the device")
ValueError: Unexpected Response from the device

>>> device.get_interfaces_ip()                     
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/napalm_ios/ios.py", line 746, in get_interfaces_ip
    raise ValueError("Unexpected response from the router")
ValueError: Unexpected response from the router

The BGP neighbors error is most likely due to the 'Neighbors' column in IOS not being wide enough to accomadate an IP address with four full octets (*192.168.123.123). For the get facts I'm not sure what's causing the error.

BGP neighbors example:

*192.168.123.97 4        12345   20902   20895    13061    0    0 3d09h           1
*192.168.123.98 4        12345   967     971    13061    0    0 03:45:19        2
*192.168.123.99 4        12345   18277   18271    13061    0    0 2d23h           2
*192.168.123.100
                4        12345    8783    8788    13061    0    0 1d10h           1
*192.168.123.101
                4        12345   16235   16202    13061    0    0 2d15h           2
*192.168.123.102
                4        12345   21769   21796    13061    0    0 3d12h           2
*192.168.123.103
                4        12345    2284    2293    13061    0    0 08:53:20        2

Fix setup.cfg and requirements.cfg files

Relates to napalm-automation/napalm#280

Add setup.cfg and requirements-dev.txt file with the following content:

  • `setup.cfg
[pylama]
linters = mccabe,pep257,pep8,pyflakes,import_order
ignore = D203

[pylama:pep8]
max_line_length = 100
  • requirements-dev.txt
pytest
pytest-cov
pytest-json
pytest-pythonpath
pylama
flake8-import-order
-r requirements.txt

get_mac_address_table not returning expected results

Different IOS platforms format show mac address-table differently (different order and/or different number of fields), which can cause ValueError exceptions or in some cases empty result sets depending on the format.

Some examples:

6500

Error:

In [26]: device.get_mac_address_table()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-26-2c330fa5b90b> in <module>()
----> 1 mac_table = device.get_mac_address_table()

/opt/napalm/env/local/lib/python2.7/site-packages/napalm_ios/ios.pyc in get_mac_address_table(self)
   1274                     'mac': mac,
   1275                     'interface': interface,
-> 1276                     'vlan': int(vlan),
   1277                     'static': static,
   1278                     'active': active,

ValueError: invalid literal for int() with base 10: 'not'

Table format:

Legend: * - primary entry
        age - seconds since last seen
        n/a - not available

  vlan   mac address     type    learn     age              ports
------+----------------+--------+-----+----------+--------------------------
*  999  1111.2222.3333   dynamic  Yes          0   Port-channel1

4948

Error

In [41]: device.get_mac_address_table()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-41-dcfc80b6b664> in <module>()
----> 1 device.get_mac_address_table()

/opt/napalm/env/local/lib/python2.7/site-packages/napalm_ios/ios.pyc in get_mac_address_table(self)
   1282                 mac_address_table.append(entry)
   1283             else:
-> 1284                 raise ValueError("Unexpected output from: {}".format(line.split()))
   1285         return mac_address_table
   1286 

ValueError: Unexpected output from: [u'-------+---------------+--------+---------------------+--------------------']

Table format

Unicast Entries
 vlan   mac address     type        protocols               port
-------+---------------+--------+---------------------+--------------------
 999    1111.2222.3333   dynamic ip                    Port-channel1      

2960

Error

None, but result set is empty

Table format

Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
All    1111.2222.3333    STATIC      CPU

Issue with get_mac_address_table() on some devices

Description of Issue/Question

The function uses show mac-address-table to get mac addresses. For some IOS devices the show mac address-table command is used.

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

  • Yes
  • No

Setup

napalm-ios version

napalm-ios==0.4.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2013 by Cisco Systems, Inc.
Compiled Wed 26-Jun-13 02:49 by prod_rel_team

Steps to Reproduce the Issue

Error Traceback

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

>>> device.open()
>>> a = device.get_mac_address_table()
>>> a
[]
>>>

A solution could be to issue show mac-address-table and look for an error and then execute the other command instead.

NS2903-ASW-01#show mac-address-table
                      ^
% Invalid input detected at '^' marker.

NS2903-ASW-01#show mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
 All    0100.0ccc.cccc    STATIC      CPU
 All    0100.0ccc.cccd    STATIC      CPU
 All    0180.c200.0000    STATIC      CPU
 All    0180.c200.0001    STATIC      CPU
 All    0180.c200.0002    STATIC      CPU
 All    0180.c200.0003    STATIC      CPU
<etc>

Unable to open connection with Cisco ASA

Description of Issue

I'm trying to open the connection with a Cisco ASA device.

napalm-ios version

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

netmiko version

$ pip freeze | grep netmiko
netmiko==1.0.0

IOS version and platform details

vpn-sfo01# sh ver

Cisco Adaptive Security Appliance Software Version 9.6(1)
Device Manager Version 7.6(1)

Compiled on Fri 18-Mar-16 14:08 PDT by builders
System image file is "disk0:/asa961-smp-k8.bin"
Config file at boot was "startup-config"

Error Traceback

>>> e.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/napalm_ios/ios.py", line 67, in open
    self.dest_file_system = self.device._autodetect_fs()
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/cisco_base_connection.py", line 57, in _autodetect_fs
    output = self.send_command_expect(cmd)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 653, in send_command_expect
    return self.send_command(*args, **kwargs)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 645, in send_command
    search_pattern))
IOError: Search pattern never detected in send_command_expect: vpn\-sfo01\#

Looks like it does not like a hostname containing hyphen?

Also, it would probably be good in the close method to check if the connection has been established before trying to close:

>>> e.close()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/napalm_ios/ios.py", line 74, in close
    self.device.disconnect()
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 857, in disconnect
    self.cleanup()
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/cisco_base_connection.py", line 52, in cleanup
    self.exit_config_mode()
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/cisco_base_connection.py", line 48, in exit_config_mode
    pattern=pattern)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 749, in exit_config_mode
    if self.check_config_mode():
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/cisco_base_connection.py", line 30, in check_config_mode
    pattern=pattern)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 730, in check_config_mode
    output = self.read_until_pattern(pattern=pattern)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 191, in read_until_pattern
    return self._read_channel_expect(*args, **kwargs)
  File "/usr/local/salt/virtualenv/lib/python2.7/site-packages/netmiko/base_connection.py", line 144, in _read_channel_expect
    raise NetMikoTimeoutException("Timed-out reading channel, data not available.")
netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.

Support configuration lock for IOS on merge operation

We can't really use this for a complete config replacement, just a merge I think (well technically we could, but the user would have to upload a file using many "no" clauses to negate existing config if they wanted to replace the running config with a completely different configuration, it's basically high risk / high likelihood of failure).

The current NAPALM IOS driver is using "configure replace" on the CLI for a complete replace operation and "copy running-config" for a merge operation. For the merge operation we could have an optional argument that instead enters into "configure terminal" mode and locks the configuration and then streams the new config file in as CLI input.

One can lock the configuration in IOS by using "configure terminal lock [revert timer N]", the optional end part means we can provide an optional automatic rollback if the configuration isn't confirmed within N minutes. The configuration unlocks when the current users leaves "conf t" mode.

So in the case of a merge operation we can wrap the proposed config file in a "configure terminal lock" command, then stream in the file to the CLI, then finish with an "end" to exit "conf t" mode and release the configuration lock (although I think ending the IOS config with an "end" is a pre-req anyway right?).

We could also optionally wrap it in "configure terminal lock revert timer N". If after N minutes the users hasn't left "conf t" mode and entered "configure confirm" back in enable mode, IOS will auto rollback the change. This would make the operation safer.

This whole feature requires the local config archive feature to be enabled on the IOS device, when one enters “configure terminal lock revert timer N” a backup of the running config is made to the archive destination (such as “flash:”) before the configuration is locked and the user placed into “configure terminal” mode, so that is has something to roll back to. This but is also a pre-req of the NAPALM IOS driver too right?

So I think both pre-reqs for this proposed enhancement are implicitly met if one is using NAPALM-IOS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.