Giter VIP home page Giter VIP logo

netconf_client's Introduction

Build Status PyPI version Coverage Status

netconf_client

A NETCONF client for Python 3.8+.

Basic Usage

from netconf_client.connect import connect_ssh
from netconf_client.ncclient import Manager

session = connect_ssh(host="localhost", port=830, username="admin", password="password")
mgr = Manager(session, timeout=120)

mgr.edit_config(config="""<config> ... </config>""")
print(mgr.get(filter="""<filter> ... </filter>""").data_xml)

More complete documentation can be found in the User Guide

Comparison with ncclient

Compared to ncclient, netconf_client has several advantages:

  • It's simpler (at the time of writing: 789 LoC vs 2889 LoC)
  • lxml can be bypassed, which can work around issues where lxml breaks namespaces of e.g. identityrefs
  • Support for TLS sessions

And a few disadvantages:

  • Support for non-RFC-compliant devices isn't really included in netconf_client
  • netconf_client does a lot less error checking and assumes you're sending valid messages to the server (however this can be useful for testing edge-case behavior of a server)

netconf_client's People

Contributors

alangefe avatar apcboston avatar geoffaliro avatar hschulzbln avatar jenntoo avatar kwatsen avatar pramodkavvaru avatar rpocase avatar skolbel avatar synther avatar wburkhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netconf_client's Issues

Connect.py should not set socket timeout to None

Referencing this code in connect.py: by setting sock.settimeout(None), it becomes possible that a send_rpc call to a device hangs indefinitely if the device has gone into an unresponsive state without closing the connection. It also violates the expectation of the calling code that the timeout parameter on connect_ssh will put the socket in timeout mode. (I note as I am writing this that the docstring does say it's a timeout 'when connecting the socket, but it's non-obvious until entering this failure mode that this timeout is changed to None` after the connection is first established.

if not sock:
sock = socket.socket()
sock.settimeout(timeout)
sock.connect((host, port))
sock.settimeout(None)

I'm not submitting a PR to fix only because it's not entirely clear to me what the intention was in setting this to None in the first place.

Add integration tests against a real NETCONF server

It would be useful to gate releases with testing against a real life NETCONF server. We could probably use a netopeer2-based Docker image to act as the server.

  • Test SSH connections
  • Test TLS connections

Tracking issue for 3.0.0 release

I don't know when we'll do this exactly, but this issue will be for tracking things that need to be done whenever we do the next major rev release:

  • Remove the deprecated timeout parameters from the connect_* functions
  • Ratchet python requirement up to 3.8 (or whatever the oldest non-EOL Python release is at the time)

not able to connect netconf server via windows

Hi All,

am facing callhome issue only on windows machine but not on linux machine,

File "C:\Users\SL-BLR-10204\AppData\Local\Programs\Python\Python37-32\lib\site-packages\netconf_client\connect.py", line 171, in exit
self.server_socket.shutdown(socket.SHUT_RDWR)
OSError: [WinError 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

But, if I put line 171 from connect.py, in try & except its working fine on windows
can you please let me know whats the catch?

Callhome to IPv6 addresses

Hello

IPv6 and call-home seems to be very unstable. I can see that when I just do a "accept_one_tls()", Windows "netstat -a" does not display a listening IPv6 socket.

The "funny" thing is that there is a good chance that the connection is eventually accepted, so somehow the IPv6 socket is created.

Is there a way to tell the module to open both IPv4 and IPv6 listening sockets? Or is there a way to force it to do IPv6 only?

TypeError in session.py: can't concat str to bytes

I see the following error message while using send_rpc() using python 3.6 version.

File "c:\python36\lib\site-packages\netconf_client\session.py", line 152, in frame_message_11
return header + msg + footer
TypeError: can't concat str to bytes

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.