Giter VIP home page Giter VIP logo

napalm-srlinux's Introduction

Nokia napalm-srlinux

Community NAPALM driver for the Nokia SR Linux OS. https://www.nokia.com/networks/products/service-router-linux-NOS/

Getting started - quick connection code snippet

driver = get_network_driver("srl")
optional_args = {
  "gnmi_port": 57400, # default
  "jsonrpc_port": 443, # default

  # "tls_ca": tls_ca, # Root CA to verify SSL connections
  # "tls_cert": cwd + "srl/client.pem",
  # "tls_key": cwd + "srl/client.key",
  # "skip_verify": True,
  "insecure": True, # FOR TESTING PURPOSES ONLY - this uses the server certificate as root of trust
  "encoding": "JSON_IETF"
}
device = driver("host-or-ip", "admin", "NokiaSrl1!", 10, optional_args)
device.open()
facts = device.get_facts()
print( facts )
device.close()

NAPALM

NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is a Python library that implements a set of functions to interact with different router vendor devices using a unified API.

NAPALM supports several methods to connect to the devices, to manipulate configurations or to retrieve data.

SR Linux OS

The driver leverages Nokia SRL YANG models for configuration and state trees for the SRL platform. NAPALM integration is validated with a minimum of Nokia Service Router Linux Operating System (SRL OS) version 21.3.1.

Releases beyond this have not been validated and should be by users before using the driver in labs and production on devices using different SRL OS versions. Please contact the Nokia owners of this repository for additional information with respect to additional release validation.

Documentation

  1. Please read the installation instruction in Install Document
  2. Mapping of various parameters of NAPALM output to Nokia SRL can be found in this Mapping Document
  3. For testing, please refer to Test Document

**Components **

  1. Python (3.7 or later)
  2. grpcio
  3. protobuf
Important Notes
  1. Ports: The napalm-srlinux driver uses gNMI and JSON-RPC for various functions, Make sure to enable the ports at SR Linux Node (57400 and 443 respectively by default)

  2. Certificates: The napalm-srlinux driver establishes secure connection only with the node, Hence make sure the appropriate CA/Certificates and Keys are in place. For testing purposes, 'insecure=True' can be used to accept any certificate presented by the device

  3. Compare_Config: The compare_commit based on the previously called function performs the operation as below, Default is on-box difference

    Function compare_config
    LOAD_MERGE on-box difference
    LOAD_REPLACE out-box difference
  4. Proxy Setting: The driver establishes RPC connections with the nodes, Check proxy settings at local machine(where driver is running), Disable proxy if not needed when running locally.

License

This project is licensed under the Apache-2.0 license - see the LICENSE file.

napalm-srlinux's People

Contributors

jbemmel avatar jonlundstrom avatar mfzhsn avatar nunomcruz avatar ohai89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

napalm-srlinux's Issues

JSON compare_config format

Based on napalm documentation the compare_config() should be returning a string - https://napalm.readthedocs.io/en/latest/base.html#napalm.base.base.NetworkDriver.compare_config
image
Current compare_config implementation for JSON returns list of dictionaries. Also that's missing any formatting so it's not easy for human to review.
Also the current format/data type is not consistent with the return values from compare_config() for on-box set-style diff - which is nicely formatted human readable string.

The simplest fix might be to return pprint.pprint(<diff>) from the JSON diff. With exception of "no diff' for which I think napalm should be returning empty string.
Best fix I guess might be some form of unified-diff style output - lines with '+' prefix for added parts, '-' line prefix for removed parts.

get_lldp_neighbors[detail] returns empty dict

Hi,
I have a 7220 D3 box with v21.6.4 SW and the latest napalm-srlinux module.
I'm trying to fetch lldp neighbors, but it returns empty dict, although there are a few neighbors visible from the CLI and even via gnmic.

get_facts works fine, so it doesn't seem like a coding issue.

Code:
`

driver = get_network_driver("srl")

srl_args = {
    "gnmi_port": 57400,
    "jsonrpc_port": 443,
    "target_name": "<addr>",
    "tls_cert":f"{certs_path}/client.pem",
    "tls_ca": f"{certs_path}/ca.pem",
    "tls_key": f"{certs_path}/client-key.pem",
    "skip_verify": True,
    "insecure": True,
    "encoding": "JSON_IETF"
} 

device = driver("<addr>", user, pass, 60, srl_args)
device.open()
print("LLDP:", device.get_lldp_neighbors())
device.close()

`

JSON diff not working

I'm using this driver to get running config (get_config() function) and then later I'm using the obtained config file to check that nothing changed on the device (load_replace_candidate() and compare_config() functions).

Despite the diff should be empty, the compare_config returns quite long diff.

Rewrite gnmi code to use pyGnmi library

The generated protobuf files are getting old, which may lead to issues: #17

It would be better to rewrite the plugin to use pyGnmi for gNMI protocol interactions, such that we can lift along with updated versions as they come out

Logging and error handling

Current behaviour of the driver is that it catches the exceptions and uses "stdout" print for saying what went wrong, but it's not re-raising the exceptions.
One example of how this handling provides "weird" output is when doing following operations with incorrect credentials

with driver(<args>) as device:
  result = device.get_config(retrieve='running')
  config = result['running']

This code doesn't fail on the open() nor the get_config() calls.

>>> result['running']
...
TypeError: 'NoneType' object is not subscriptable

So this makes the debugging harder also I would say it's quite non-standard.

The other thing is the logging. The prints statements are hard to integrate into other applications, and the driver can also be used with other than CLI programs. So it's not possible to make the prints integrated with logging files for long-running processes/service or with centralised logging systems.

My suggestion is to replace the prints statements with logging module and to reraise the exceptions (either the same or based on napalm library exceptions). Happy to hear other opinions on the logging and exceptions handling problem described above.

Too old ansible requirements

Ansible 2.9.12 is quite old, is there any reason why requiring this version ? - https://github.com/napalm-automation-community/napalm-srlinux/blob/main/requirements.txt#L2

Also what's the reason for raising AnsibleConnectionFailure when failed to read certificate files? - https://github.com/napalm-automation-community/napalm-srlinux/blob/main/napalm_srl/srl.py#L2552
This is a napalm driver so I don't think it needs to be used together with ansible, so I don't understand why ansible exception. Napalm has its own set of exceptions so why not to use that? or a python standard exception?

@jbemmel I'm happy to raise a PR for this, just wants to know if it's fine to remove the ansible requirement.

clarity on behaviour of load_replace_candidate

From the mapping documentation https://github.com/napalm-automation-community/napalm-srlinux/blob/main/Summary_of_Methods.pdf in section 2.6 about load_replace_config it says the follwoing:

Limitation
This method has implicit commit, when using this command user needs to be careful since the candidate config will be merged with running config along without an explicit commit. Numeric value for the position in the list of the change, and not the ID of the object. The ID of the object is stored as a separate leaf object in the SRL OS Yang models.

When going through the code https://github.com/napalm-automation-community/napalm-srlinux/blob/main/napalm_srl/srl.py#L2346 it doesn't suggest that there is any commit happening.

Can you please clarify what is the default behaviour here.

No way to update startup config

Is there a way to update startup config using this napalm driver? So in case the device reboots, the config stays the same
If this is not possible with current implementation, could this please be added?

I believe for example with Juniper napalm driver, the startup config gets updated when commit_config() operation is done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.