napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

Add handling for exec prompt timestamp #53

Closed piter50 closed 7 years ago

piter50 commented 7 years ago

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

ktbyers commented 7 years ago

Can you disable this?

line vty 0 4
  exec prompt timestamp

in other words, your config has made your output non-standard.

The general problem is that we can't write the getters() such that any changes someone makes to the output in the CLI can be accommodated. It is hard-enough just to handle the normal variations in output.

Second option...if NAPALM-ios and possibly salt integration provided a way to dynamically modify that, is that an acceptable solution to you?

In other words, you pass in a CLI command at beginning of session to disable this in your config. At the end of the session, you then restore the config?

piter50 commented 7 years ago

Actually, it looks like it can be turned off on a per session basis and would not need to be done in config mode. The command would be terminal no exec prompt timestamp Subsequent logins would turn it back on.

piter50 commented 7 years ago

I was able to get around it by adding to the netmiko libraries...

to netmiko/base_connection.py, i just added a set_timestamp_off command which i just copied from the set terminal width command and added a line for set_timestamp_off in the session_preparation.

cisco/cisco_ios.py: self.set_timestamp_off(command='terminal no exec prompt timestamp')

ktbyers commented 7 years ago

@piter50 Nice, is that a workable solution for you?

mirceaulinic commented 7 years ago

Sounds like a good workaround for me too!

piter50 commented 7 years ago

It is a workable solution for me. Is it something you would consider adding/merging to the netmiko code?

ktbyers commented 7 years ago

Probably not...as this is the first time I have ever seen this issue. Someone can always just turn it off in Netmiko (pretty easily).

piter50 commented 7 years ago

Fair enough. I had to patch my rancid set up for this prior to release 3.0 where the devs added it in. Thanks

ktbyers commented 7 years ago

I will probably watch and see if other people have this issue. It also becomes more problematic for things that depend on Netmiko (NAPALM/Ansible/Salt) where it might not be so easy to directly turn it off.