Community discussions

MikroTik App
 
User avatar
DavidCN
just joined
Topic Author
Posts: 12
Joined: Wed Feb 27, 2019 1:37 am
Location: Spain
Contact:

Python SSH API for MikroTik devices

Thu Jun 03, 2021 7:58 pm

Hi guys!

I want to share with you an SSH API that I have made in Python and that I have freely published on GitHub.

For now there are a few basic functions available but I will be incorporating new features

Any suggestion is welcome ;-)

You can get the code by accessing the GitHub repository, downloading it from PyPI or by installing it directly on your machines using PIP with:
pip3 install routeros-ssh-connector

I hope you enjoy it!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Python SSH API for MikroTik devices

Thu Jun 03, 2021 8:49 pm

Thanks for sharing, I hope someone can find it helpful
 
User avatar
DavidCN
just joined
Topic Author
Posts: 12
Joined: Wed Feb 27, 2019 1:37 am
Location: Spain
Contact:

Re: Python SSH API for MikroTik devices

Tue Jun 08, 2021 6:54 pm

Hi guys,

There are new version of this API:

v1.6 Changelog
  • Added new method download_file
  • Updated download_backup, download_export and make_backup methods to optimize code:
  • Fixed make_backup method to set password parameter to None by default
  • Optimized get_routes method to allow to get more than 1000 routes.
  • Optimized connect method to handle connection exceptions

You can download it at GitHub or PyPI

To install directly on your host using PIP:
pip3 install routeros-ssh-connector
 
User avatar
DavidCN
just joined
Topic Author
Posts: 12
Joined: Wed Feb 27, 2019 1:37 am
Location: Spain
Contact:

Re: Python SSH API for MikroTik devices

Wed Jun 09, 2021 7:50 pm

Hi guys,

There are new version of this API:

v1.7.1 Changelog
Added new "tool" methods:

- configure_wlan that allows to configure 2.4GHz and 5GHz wlan interfaces
- reboot_device to reboot your device
- update_system to upgrade your RouterOS to latest version
- upload_file to upload local files to your RouterOS device

You can download it at GitHub or PyPI

To install directly on your host using PIP:
pip3 install routeros-ssh-connector

I hope you enjoy it!
 
MrYan
Member Candidate
Member Candidate
Posts: 160
Joined: Sat Feb 27, 2010 6:13 pm

Re: Python SSH API for MikroTik devices

Thu Jun 10, 2021 12:02 am

Your getters and setters are quite similar to Napalm (https://napalm.readthedocs.io/en/latest/base.html). You might want to see if there is some synergy between your work and theirs.
 
User avatar
DavidCN
just joined
Topic Author
Posts: 12
Joined: Wed Feb 27, 2019 1:37 am
Location: Spain
Contact:

Re: Python SSH API for MikroTik devices

Thu Jun 10, 2021 12:24 pm

Hi MrYan,

Thanks for your comment! I know Napalm and i'm using it for automation tasks in our core network with Cisco and Huawei devices. Napalm is more oriented to network devices that supports "configuration states" like candidate, active, etc... Mikrotik doesn't support it.

Another thing is that the Napalm module for Mikrotik only have implemented (at the moment) getters as they say in their GitHub module homepage but doesn't allow configurations on device.

The main intention of my project is to serve an easy and friendly SSH API for MikroTik devices. It can be used from get some basic info from device or even in an automation scenario.

As i said at start, thanks for your comment! ;-)

Regards

Who is online

Users browsing this forum: No registered users and 14 guests