napalm-automation / napalm-ios Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
>>>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
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.
Update unittests to test that invalid commands in a replace config operation get rejected.
While working with the pytest framework I noticed a bug. Will just ignore this for now and remove the static entry.
napalm-ios==0.4.0
(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)
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#
(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']
>>>
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)?
Looks like load_merge_candidate
does not accept the config
arg: https://github.com/napalm-automation/napalm-ios/blob/develop/napalm_ios/ios.py#L170-L171
For this reason, the load_template
helper won't work as it tries to send the result after the template is renders in the config
argument: https://github.com/napalm-automation/napalm-base/blob/develop/napalm_base/helpers.py#L86
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`
Need support for inline config merge, config replace (i.e. not from an external file, but from inline in-code).
get_lldp_neighbors failed if device line does not have capabilities. maybe we should implement the case in textfsm and handle it?
(Paste verbatim output from pip freeze | grep napalm-ios
between quotes below)
napalm-ios==0.4.0
(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
Connect a security camera, dell server or any simple device that does not exchange capabilities. Then call get_lldp_neighbors()
(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
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.
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
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
Should support passing in of secret argument.
Automatically attempt to go into enable mode if secret argument is present.
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()
See details in the parent issue napalm-automation/napalm#297
When called, get_mac_address_table throws exception while processing the multicast entries header from "show mac address-table" output
(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
(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
(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'
Should this be changed so that it never shows up in the diff.
See details in the parent issue napalm-automation/napalm-base#71
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:
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.
Also unit tests don't catch this.
pynet-rtr1>dir
Translating "dir"
% Bad IP address or host name
% Unknown command or computer name, or unable to find computer address
You only need this for the file operations and not for the getter operations.
(Paste verbatim output from pip freeze | grep napalm-ios
between quotes below)
napalm-ios==0.4.0
napalm-iosxr==0.4.0
(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
device.get_bgp_neighbors()
device.get_facts()
device.get_arp_table()
device.get_interfaces()
device.get_interfaces_ip()
(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
rollback()
compare()
commit_config()
Relates to napalm-automation/napalm#280
Add setup.cfg
and requirements-dev.txt
file with the following content:
[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
See details in the parent issue napalm-automation/napalm-base#65
Netmiko is looking for trailing prompt, but the trailing prompt changes when hostname is changed.
I have seen reports on this.
Base ref napalm-automation/napalm-base#13
'dir' command in the auto detection of the filesystem will fail if not in enable mode, but there is nothing ensuring that the device is in enable mode.
Might also affect panos, ios-xr, and vyos drivers that use Netmiko
Original issue napalm-automation/napalm#215 created by @ktbyers
See issue #209
See details in the parent issue napalm-automation/napalm-base#137
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:
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'
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
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'-------+---------------+--------+---------------------+--------------------']
Unicast Entries
vlan mac address type protocols port
-------+---------------+--------+---------------------+--------------------
999 1111.2222.3333 dynamic ip Port-channel1
None, but result set is empty
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
All 1111.2222.3333 STATIC CPU
See details in the parent issue napalm-automation/napalm#327
Make it more self-explanatory what the issue is.
See details in the parent issue napalm-automation/napalm-base#107
http://napalm.readthedocs.io/en/latest/support/ios.html
Netmiko version.
Statement regarding write mem (not occurring).
Needs tied to Netmiko version 1.1 (i.e. if Netmiko version >= this, then support that argument).
See details in the parent issue napalm-automation/napalm#199
See details in the parent issue napalm-automation/napalm-base#99
New test was added that is now causing unit tests to break.
I never used NAPALM on IOS, but thankfully to a user curious to exploit some new stuff, the following error was detected when calling get_environment
:
local variable 'match' referenced before assignment
As I do not have much experience here, may I ask you if it is related to this @ktbyers or @dbarrosop?
Thank you!
The function uses show mac-address-table
to get mac addresses. For some IOS devices the show mac address-table
command is used.
napalm-ios==0.4.0
(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
(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>
x
I'm trying to open the connection with a Cisco ASA device.
$ pip freeze | grep napalm-ios
napalm-ios==0.2.0
$ pip freeze | grep netmiko
netmiko==1.0.0
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"
>>> 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.
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.
Test behavior if interfaces are out of order on config replace
What does compare_config() do.
Also any issue with commit of config.
See details in the parent issue napalm-automation/napalm-base#70
Base ref napalm-automation/napalm-base#36
Original issue napalm-automation/napalm#224 created by @ktbyers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.