Skip to content

Nokia SR Linux Multiline Prompt Issues #3522

Closed
@jeffkala

Description

@jeffkala

Description of Issue/Question

Note: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

Using netmiko, for the case of nokia_srl i'm using the | as json to get back structured data via screenscraping; however, the outputs are capturing the first line of the prompt --{ running }--[ ]-- as part of the command output, hence is no longer jsonable.

The default prompt for srlinux is a multiline prompt as below shows:

--{ running }--[  ]--
A:srl1#

--{ running }--[  ]--
A:srl1#

Can get around it by changing the user level rc file via environment prompt {host}#

--{ running }--[  ]--
A:srl1# environment prompt {hw_slot}:{host}#
A:srl1#
A:srl1#
A:srl1#

Setup

Netmiko version

(Paste verbatim output from pip freeze | grep netmiko between quotes below)

▶ pip freeze | grep netmiko
netmiko==4.4.0

Netmiko device_type (if relevant to the issue)

(Paste device_type between quotes below)

srl = {
        'device_type': 'nokia_srl',
        'host': '172.20.20.2',
        'username': 'admin',
        'password': 'NokiaSrl1!'
    }

Steps to Reproduce the Issue

  1. Using containerlab quickly spin up a free nokia_srl via a clab file below.
name: learn-srlinux
prefix: ""

topology:
  kinds:
    nokia_srlinux:
      image: ghcr.io/nokia/srlinux:24.7.2

  nodes:
    srl1:
      kind: nokia_srlinux
      type: ixrd2l
  1. Start clab
▶ sudo containerlab deploy -t lab.clab.yml
[sudo] password for allprojeff66: 
INFO[0000] Containerlab v0.59.0 started                 
INFO[0000] Parsing & checking topology file: lab.clab.yml 
... omitted ..
INFO[0012] Adding containerlab host entries to /etc/hosts file 
INFO[0012] Adding ssh config for containerlab nodes     
+---+------+--------------+------------------------------+---------------+---------+----------------+----------------------+
| # | Name | Container ID |            Image             |     Kind      |  State  |  IPv4 Address  |     IPv6 Address     |
+---+------+--------------+------------------------------+---------------+---------+----------------+----------------------+
| 1 | srl1 | 2325534a2ea5 | ghcr.io/nokia/srlinux:24.7.2 | nokia_srlinux | running | 172.20.20.2/24 | 3fff:172:20:20::2/64 |
+---+------+--------------+------------------------------+---------------+---------+----------------+----------------------+

Error Traceback

No traceback, the output simply is keeping the first line of the prompt which results in the | as json command not being jsonable anymore.

▶ poetry run ipython srl_netmiko.py
{
  "basic system info": {
    "Hostname": "srl1",
    "Chassis Type": "7220 IXR-D2L",
    "Part Number": "Sim Part No.",
    "Serial Number": "Sim Serial No.",
    "System HW MAC Address": "1A:03:00:FF:00:00",
    "OS": "SR Linux",
    "Software Version": "v24.7.2",
    "Build Number": "319-g64b71941f7",
    "Architecture": "<Unknown>",
    "Last Booted": "2024-11-01T17:21:00.164Z",
    "Total Memory": "<Unknown>",
    "Free Memory": "<Unknown>"
  }
}

--{ running }--[  ]--

Relevant Python code

(Please try to essentialize your Python code to the minimum code needed to reproduce the issue)
(Paste the code between the quotes below)

from netmiko import ConnectHandler

def srl_netmiko():
    srl = {
        'device_type': 'nokia_srl',
        'host': '172.20.20.2',
        'username': 'admin',
        'password': 'NokiaSrl1!'
    }
    net_connect = ConnectHandler(**srl)
    output = net_connect.send_command('show version | as json')
    print(output)

if __name__ == '__main__':
    srl_netmiko()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions