Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telnetlib is deprecated #3177

Closed
sleinen opened this issue Apr 24, 2023 · 10 comments · Fixed by #3444
Closed

telnetlib is deprecated #3177

sleinen opened this issue Apr 24, 2023 · 10 comments · Fixed by #3444

Comments

@sleinen
Copy link

sleinen commented Apr 24, 2023

When adding pytest coverage to my own script that uses Netmiko, I noticed the following warning:

=================================================================================== warnings summary ====================================================================================
.venv/lib/python3.11/site-packages/netmiko/base_connection.py:30
  /Users/leinen/network/bgp-observer/.venv/lib/python3.11/site-packages/netmiko/base_connection.py:30: DeprecationWarning: 'telnetlib' is deprecated and slated for removal in Python 3.13
    import telnetlib

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
[...]

telnetlib is indeed one of several network-related modules that are scheduled for removal in Python 3.13, according to PEP 594. The table mentions telnetlib3 and Exscript as possible replacements.

I haven't looked at the two in detail, but according to this StackOverflow response, Exscript could actually be closer to the original telnetlib than telnetlib3 is to telnetlib. But I can't tell what option would make the most sense for Netmiko going forward.

@ktbyers
Copy link
Owner

ktbyers commented Apr 24, 2023

Well that is unfortunate...I will probably just wait and see if someone writes a backport for it. telnetlib3 won't work (it's async).

@GoreNetwork
Copy link

sadly gear that doesn't support current SSH is still widly deployed.

@JohnVillalovos
Copy link
Contributor

One suggestion in https://discuss.python.org/t/pep-594-take-2-removing-dead-batteries-from-the-standard-library/13508/59

Is to just copy telnetlib.py and use it.

Would have to comply with their license: https://docs.python.org/3/license.html

@ktbyers
Copy link
Owner

ktbyers commented Sep 19, 2023

@JohnVillalovos Yeah, I guess we could just "vendor" it inside of Netmiko and copy their license inside that folder (and make a note on our main license).

@AlaBouali
Copy link

hello guys, please try my alternative to telnetlib:

https://github.com/AlaBouali/xtelnet

This is an easy to use telnet module to interact with a remote system smoothly over this protocol! It is a very minimalistic alterative to "telnetlib". xtelnet is a powerful and user-friendly Python library designed for managing Telnet sessions with ease and efficiency. With its intuitive interface and robust functionality, xtelnet simplifies the process of interacting with Telnet servers, offering a range of features for seamless communication. xtelnet offers a comprehensive solution for Telnet communication, providing developers with the tools they need to effectively manage Telnet sessions and interact with remote systems. Whether you're a seasoned developer or new to Telnet protocols, xtelnet empowers you to achieve your goals efficiently and reliably.

Why should I use xtelnet?
Easy to use and stable
Simple Authentication mechanism
Compatible with almost all servers when it comes to authentication and executing the commands
Available Command line tool
Thread-safe: if the session is shared among threads to execute commands, the commands will be executed one by one
Supports running multiple sessions concurrently
Can connect simultaneously and run in parallel the same command on: single or some or all connected hosts
Allow reconnect after closing the connection
Allow escape ANSI characters
Grab banners
Available "ping" function to use if you want to keep the connection open
Supports SOCKS 4 / 5 proxies
Supports SSL
Supports sending JSON data

@AdamWill
Copy link

This is now rather more than an RFE, as telnetlib is removed in Python 3.13, which will be released in October (and is already in Fedora Rawhide and probably pending for other development distros).

@dtantsur
Copy link

@ktbyers sorry for bothering you, any progress here? I'm stuck with Fedora packaging because of this issue. I can vendor telnetlib myself, but I'd rather at least coordinate with you (especially because of the licensing question).

@ktbyers
Copy link
Owner

ktbyers commented Jun 20, 2024

@dtantsur @AdamWill I will see if I can vendor it inside of Netmiko either this week or next week (hopefully, next week).

I will read through the associated telnet license and incorporate the PSF3 license into that subdirectory / part of Netmiko.

Don't hesitate to ping me if I forget to do this.

@dtantsur
Copy link

dtantsur commented Jul 3, 2024

@ktbyers hi, sorry for nagging you, but could you make a release with this fix? The last one was in November 2023 afaik, so it's more or less due anyway. A release would help me a lot with packaging since I won't need to pull a git version.

@ktbyers
Copy link
Owner

ktbyers commented Jul 7, 2024

@dtantsur I am working on the release for this, but running into some issues with the 'cffi' conditional dependency in pyproject.toml. I need to look at this some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants