On Mar 27, 2015 1:54 AM, "Kevin" kevin@sidx.org.uk wrote:
I¹m now looking at the link you sent in more detail, If I¹m honest, I didn¹t realise that MikroTik had python in its OS - python coding is not something I¹m as familiar with,
Mikrotik does not have Python in their OS. I found no way to process data from a JSON API with Mikrotik scripting language, so this was designed to run on a separate computer with Python.
I run it on my workstation. This is the same workstation I use to configure the router manually, so it already has the required private DSA key to log in to the router. This allows me to run the script via cron without having to enter a password.
If you want a contained solution with no computers other than the router, you could install an OpenWRT MetaRouter on your Mikrotik and run the Python script in that. At this point you could also just use rip44d on OpenWRT to manage the AMPR tunnels. I have not tried this.
I know this may be a pain, but could you explain a little bit on how to add these files into the back end and is there anything I need to edit in the files (I know the settings.py need changing with my api details from the portal) perhaps if its not too much trouble a bit of a walkthough?
First, create an API key at https://portal.ampr.org/profile.php
These steps should work for Ubuntu/Debian: sudo apt-get install git-core python git clone https://github.com/kd7lxl/python-amprapi.git cd python-amprapi vi settings.py # enter your AMPR username and API key :wq ./updateros.py -v -n 192.168.1.1 # substitute your router IP
This will print the list of Mikrotik commands that are needed to add the AMPR tunnels to your router. If you run it again without -n, these commands will be sent to your router via SSH.
It may take a long time to run the first time. The script does not invoke a shell in SSH, so each command (about 1500 of them, for 500 routes) is sent independently. You can cancel and restart without any harm. It'll pick up where it left off last time.
Subsequent runs only execute a diff, so they will be very fast (unless some catastrophe causes hundreds of AMPR gateways to be removed from the portal).
Here's the actual line from my crontab that runs it on my router: 3 * * * * /home/tom/src/python-amprapi/updateros.py 44.24.221.1
Hope that helps.
Tom KD7LXL