i’m currently developing some Scripts and Software which interfaces the API. I’m wondering how consistent are the IDs i get with the “find” function. For example:
I like to update some static routes via a script.
So i fetch all routes i need to update with “find” and then do some “set” on such items using the IDs i got with the “find”.
So far no a problem.
At the same time we have routes from OSPF on the router. I might be that due to some updates via ospf the list oft routes get changed. What will happen if this event occurs exactly between i fetch the IDs with “find” and i use them to change routes? Is it possible that i change the wrong entry? What do you think? Maybe someone from Mikotik can answer this question.
AFAIK, IDs are generated per connection, so regardless of CRUD operations and number of connections, no, you shouldn’t suddenly target the wrong entry.
However, the next time you connect (including, for example, if you create a new connection without disconnecting the old one), if there were CRUD operations, yes, you may end up targeting the wrong entry.
These ID’s are the same that are returned when you do API print for argument .id values. Static ID numbers will not change ever, dynamic ones can change if routes are updated. However, IDs will not change if there are no updates. If ID of the dynamic route has changes between print and you need massive number of route changes to wrap ID counter for routes as this 40173409 is a hex number. So, in the all you get via API if route is gone - is error message that item does not exist !trap
sounds ok for me as i just modify the static entries.
just FYI
A script updates a static host route to a VPN endpoint(concentrator) with the gateway information the dhcp-client has received. purpose of that hostroute is to send VPN traffic over the uplink. inside the VPN we use ospf with even an advertisement of default routes to have the internet-breakout at an other location.