Comments (24)
Are you shitting me? Is Cisco that st%&$d? They don't know that an IP represented as a string can have a max_length of 15 counting the dots? Interesting a networking vendor doesn't know about that.
from napalm-ios.
*192.168.123.100
4 12345 8783 8788 13061 0 0 1d10h 1
Whut. the. f!? That's beyond my imagination!
from napalm-ios.
One way to "normalize" the data:
out = '''
*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
'''
output = out.split('\n')
count = 1
regexp = re.compile(r'^(?:\*|\s+)(?:\d{3}\.){3}\d{3}')
tempoutput = []
for line in output:
if len(line.split()) == 9:
pass
elif regexp.search(line) is not None and len(output[count].split()) == 9:
tempoutput.append(line.strip() + output[count])
else:
tempoutput.append(line)
count = count + 1
output = tempoutput
from napalm-ios.
Added this in slack, but thought I would comment here, should probably have: peer_id = peer_id.replace('*','')
as well.
from napalm-ios.
Can we just re.sub based on IP address pattern with a trailing newline and then eliminate the newline?
@itdependsnetworks Sounds good on your peer_id replacement as well?
from napalm-ios.
@ktbyers That would actually work quite well if done before the linesplit. Replace the trailing newline with a space and good to go. Genius!
I still need to figure out why the other getters are failing.
from napalm-ios.
get_facts() fails due to show ip interface brief
on IOS-XE also returns load and time source stats. Fix is show ip interface brief | begin ^Interface
Here's the output:
#show ip interface brief
Load for five secs: 1%/0%; one minute: 1%; five minutes: 1%
Time source is NTP, *09:59:40.324 UTC Wed Nov 30 2016
Interface IP-Address OK? Method Status Protocol
from napalm-ios.
I'm not sure how that will work, in my mind it will still be two different elements in the same list, though I am sure I am missing something. If it works, then all the better. Was just offering up at potential solution being that it only took me 5-10 min, but again, whatever works :)
from napalm-ios.
@itdependsnetworks: What @ktbyers is proposing is eliminating the newlines following the IP before the .split("\n") function is performed. That should make the linesplit piece execute without issue.
from napalm-ios.
@itdependsnetworks It's all good. I will try to do a few tests.
from napalm-ios.
@tyler-8 @ktbyers brilliant :)
output = re.sub(r'((?:\*|\s+)(?:\d{3}\.){3}\d{3}\s*)(?:\n|\r)', r'\1', output)
from napalm-ios.
get_arp_table() has the same issue as get_facts(). show ip arp
output gives load and NTP stats.
Raw output:
#sh ip arp
Load for five secs: 1%/0%; one minute: 1%; five minutes: 0%
Time source is NTP, *11:57:42.689 UTC Wed Nov 30 2016
Protocol Address Age (min) Hardware Addr Type Interface
Internet 207.11.25.233 12 0010.dbff.1001 ARPA GigabitEthernet0/0/0
Here's the fix:
sh ip arp | begin ^Protocol
from napalm-ios.
@tyler-8 Okay, I will try to fix these in the same PR request.
from napalm-ios.
@ktbyers - Okay confirmed for sure. These functions are breaking due to the same lines in the output.
device.get_facts()
device.get_arp_table()
device.get_interfaces()
device.get_interfaces_ip()
Adding the output modifiers to | begin ^Protocol
or | begin ^Interface
will fix it for all IOS devices.
from napalm-ios.
I just saw that the get_arp_table() is already using an output modifier.
command = 'show arp | exclude Incomplete'
So for that command it'll have to be something like sh ip arp | exclude Incomplete|Load for|Time source
but that still leaves a blank line at the beginning of the output. I'm not sure if there's a way to filter out blank lines in the CLI so that may be for NAPALM to do.
router#sh ip arp | exclude Incomplete|Load for|Time source
Protocol Address Age (min) Hardware Addr Type Interface
from napalm-ios.
Thanks to @ogenstad
Try typing
terminal no exec prompt timestamp
, before the command.
You probably have something in your config to set that.
Which turned out to be the case for all the getters with issues except device.get_bgp_neighbors()
- which still breaks due to IOS wrapping the neighbor lines.
Performing >>> device.cli(["terminal no exec prompt timestamp"])
prior to executing the other getters solves the problems.
from napalm-ios.
@tyler-8 Yes, I figured it was probably a CLI setting for the ones excluding BGP.
It is probably worth fixing, however, so NAPALM just filters those lines out.
from napalm-ios.
Found some additional silliness, though netmiko may already be handling this by doing terminal length 0
.
When encountering -- More --
, IOS will insert additional header rows, which can split up the peer-id from its BGP data.
*192.168.123.100
4 12345 1941 1943 13847 0 0 07:32:54 1
*192.168.123.101
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4 12345 3768 3769 13847 0 0 14:39:49 2
*192.168.123.102
4 12345 1098 1101 13847 0 0 04:16:13 1
from napalm-ios.
Here's my regex stab at removing the line breaks/feeds after the peer-id:
line_merge = re.compile(r"((?:\d{1,3}\.){3}\d{1,3}\s*)(?:\n|\r)(.+)")
output = line_merge.sub(r"\1\2", bgp_output.strip())
from napalm-ios.
Will try to fix next week: 12/5 - 12/9
from napalm-ios.
Would be nice to migrate to the new testing framework and include this test cases before fixing. Will double check with @ogenstad as I think he was working on it and help him out to have it ready ASAP.
from napalm-ios.
I submitted a PR on this including tests here:
from napalm-ios.
@tyler-8 Can you test this fix works with your BGP line wrapping issue.
from napalm-ios.
I also put in a fix that should filter these lines:
Load for five secs: 1%/0%; one minute: 1%; five minutes: 1%
Time source is NTP, *09:59:40.324 UTC Wed Nov 30 2016
from napalm-ios.
Related Issues (20)
- ios throw 'SSH session not active' when load_merge_candidate is called HOT 27
- Implement `get_bgp_neighbors_detail` HOT 1
- Latency Issue Cause various errors - increased global_delay_factor HOT 2
- remove 'ip scp server enable' after deployment HOT 1
- load_merge_candidate & commit_config slow (takes 40 seconds) HOT 4
- Regex used fto match the name of the network interface HOT 9
- get_environment fails on Cisco 3850 switch HOT 3
- get_environment fails on Cisco 4500 HOT 1
- get_facts returns the whole string from "show version" not just the software version HOT 4
- get_snmp_information() returns ACL names as "N/A" if none exist for a community HOT 2
- Missing end in "merge_config.txt" causes the error "!Error: cfgdiff returned error 5" HOT 1
- ISSUE WITH BASIC NAPALM CODE HOT 5
- "ValueError: Unable to find prompt" on commit_config() operation HOT 11
- get_facts() errors if "show hosts" command returns nothing HOT 2
- napalm-ios ping is not correctly tracking probes_sent HOT 1
- get_interfaces_ip executes a show command for each interface HOT 1
- CSR1000V HOT 1
- Cannot install config if candidate change username HOT 1
- Is AAA (TACACS) Supported? Not able to login nor test. HOT 4
- get_facts()['version'] Unknown on old 2950 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from napalm-ios.