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

Update Mikrotik to last version #36

Open
abrpr opened this issue Aug 24, 2018 · 1 comment
Open

Update Mikrotik to last version #36

abrpr opened this issue Aug 24, 2018 · 1 comment

Comments

@abrpr
Copy link

abrpr commented Aug 24, 2018

how can i update my mikrotik to last version with this API?
it should first download new update with this command
system/package/update download
and then reboot the router

@UtgardaLokki
Copy link

I did it like that :

import routeros_api
import datetime
from scanNmapy import ScanNmapy


ip_list =[]

no_access = []
comunication_error = []

update_time = datetime.datetime(2017, 9, 15, 14, 20)
delta = datetime.timedelta(days=0.0005)

length = len(ip_list)

while length != 1:
    length = len(ip_list)
    ip = ip_list.pop(0)

    time = str(update_time)[11:19]

    connection = routeros_api.RouterOsApiPool(ip, username=login, password=password)
    try:
        api = connection.get_api()
        try:
            task = api.get_resource('/system/scheduler')
            task.add(name='', start_time=time, on_event='system package update check-for-updates' + '\n' + 'system package update download')
            task.add(name='reset', start_time='03:00:00', start_date='Sep/18/2017', on_event='system reboot')
        except routeros_api.exceptions.RouterOsApiCommunicationError:
            comunication_error.append(ip)

        connection.disconnect()
        print(ip + '  Done')
    except routeros_api.exceptions.RouterOsApiConnectionError:
        print(ip + '  NOT done')
        no_access.append(ip)

    update_time = update_time + delta


print('No access :')

print(no_access)

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

No branches or pull requests

2 participants