38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import librouteros
|
|
|
|
api = librouteros.connect('192.168.100.2', 'mi4', 'm14', port=8728)
|
|
|
|
# Test 1: Set comment on Bulanan2
|
|
items = list(api('/system/scheduler/print'))
|
|
for item in items:
|
|
if item['name'] == 'Bulanan2':
|
|
print(f'Bulanan2 .id = {item[".id"]}')
|
|
print(f'Current comment: {item.get("comment")}')
|
|
|
|
# Set comment
|
|
result = list(api('/system/scheduler/set', **{'.id': item['.id'], 'comment': 'TEST_FIX_123'}))
|
|
print(f'Set result: {result}')
|
|
break
|
|
|
|
# Re-read
|
|
items = list(api('/system/scheduler/print'))
|
|
for item in items:
|
|
if item['name'] == 'Bulanan2':
|
|
print(f'Comment after set: {item.get("comment")}')
|
|
|
|
# Test 2: Set on-event with simple value
|
|
simple_script = ':put "hello world"'
|
|
items = list(api('/system/scheduler/print', **{'?name': 'Bulanan2'}))
|
|
if items:
|
|
item = items[0]
|
|
print(f'Setting on-event to simple script...')
|
|
result = list(api('/system/scheduler/set', **{'.id': item['.id'], 'on-event': simple_script, 'comment': 'Monitor Profile Bulanan2'}))
|
|
print(f'Result: {result}')
|
|
|
|
# Re-read
|
|
items = list(api('/system/scheduler/print', **{'?name': 'Bulanan2'}))
|
|
if items:
|
|
print(f'On-event after: {items[0].get("on-event")[:100]}')
|
|
|
|
api.close()
|