question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nokia_SROS adding backspace characters to output

See original GitHub issue

I’m using the textfsm processing to pull command output tables, and I noticed that on some devices it wasn’t returning the expected output but on others it was. Further examination from the Netmiko debug logs I found that the return seemed to be including backspace control characters that were messing up the output spacing and throwing off the textfsm parse.

The code doesn’t seem to matter, as I get the same result from an interactive python env as I do in a built script, so here’s what I’m doing and the output I’m seeing.

Not working:

>>> net_connect = Netmiko(host='10.187.165.188', username='ipmetro-script', password='*******', device_type='nokia_sros')
>>> output = net_connect.send_command('show router ospf neighbor')
>>> print(output)
===============================================================================
Rtr Base OSPFv2 Instance 0 Neighbors
===============================================================================
Interface-Name                   Rtr Id          State      Pri  RetxQ   TTL
   Area-Id
-------------------------------------------------------------------------------
  x-ge1/1/25                       10.187.165.155  Full       1    0       39
   0.0.0.0
    ge1/1/20                         10.186.16.2     Full       1    2       38
   0.0.0.0
  -------------------------------------------------------------------------------
No. of Neighbors: 2
===============================================================================
>>> net_connect.disconnect()

Each of the interface names should be right against the left margin, but they are spaced away. Here’s one that works properly, with the exact same command, though the device is a different type of hardware:

Working

>>> net_connect = Netmiko(host='10.187.166.141', username='ipmetro-script', password='*******', device_type='nokia_sros')
>>> output = net_connect.send_command('show router ospf neighbor')
>>> print(output)                                                                                                   
===============================================================================
Rtr Base OSPFv2 Instance 0 Neighbors
===============================================================================
Interface-Name                   Rtr Id          State      Pri  RetxQ   TTL
   Area-Id
-------------------------------------------------------------------------------
x-ge1/1/1                        10.187.166.134  Full       1    0       37
   0.0.0.0
x-ge2/1/1                        10.187.166.135  Full       1    0       31
   0.0.0.0
x-ge1/2/1                        10.187.166.191  Full       1    0       35
   0.0.0.0
-------------------------------------------------------------------------------
No. of Neighbors: 3
===============================================================================
>>> net_connect.disconnect()

Attached the relevant Netmiko logs as well. I’ve tried post-processing with the strip_backspace() method, but it doesn’t seem to work, and defeats the purpose of doing textfsm inline with the send_command(unless of course I’m using it incorrectly, which I’ll admit is as likely as anything else since I’m a network engineer first and reasonably new to this automation journey). backspace control logs.txt

Thanks in advance for any insight you can provide.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
helltcommented, Jun 2, 2020

@ktbyers yes, I am reading it the same. The software version OP is running is way too old (10yrs back) to even ask “wtf is happening” internally.

the only thing that comes to my mind is to make an additional function for such old releases that will count the number of backspace chars per line and will remove the same number of spaces from the left for such lines.

I would name that func the_old_software_strikes_back()

0reactions
ktbyerscommented, Jun 2, 2020

Yeah, I think it should just be in the TextFSM template. It is just whitespace so really shouldn’t be a problem in the template (in general).

Okay, I am going to close this as I don’t think there is anything to do on the Netmiko side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2. CLI Usage
Use the CLI to access, configure, and manage Nokia's routers. CLI commands are entered at the command line prompt. Access to specific CLI...
Read more >
IES Service Configuration Commands - Nokia Documentation
This command configures an optional service name, up to 64 characters in length, ... VRRP policy associations may be added and removed at...
Read more >
VPRN Service Configuration Commands - Nokia Documentation
This command facilitates a simplified method to configure the route target to be added to advertised routes or compared against received routes from...
Read more >
Layer 3 Services Guide: IES and VPRN - Nokia Documentation
Command outputs shown in this guide are examples only; ... subnets cannot be added without a corresponding SRRP gateway IP address.
Read more >
MD-CLI USER GUIDE RELEASE 22.10.R1
"urn:nokia.com:sros:ns:yang:sr:attributes">. <ipv4>. <receive>true</receive>. </ipv4>. </add-paths>. The configuration output can display ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found