Uninett / nav

Network Administration Visualized
GNU General Public License v3.0
175 stars 38 forks source link

API endpoints for maintenance #2927

Open indy-independence opened 1 month ago

indy-independence commented 1 month ago

Is your feature request related to a problem? Please describe.

We want to be able to schedule maintenance / downtime of devices via API, for example when triggering an OS/firmware upgrade from NMS we want to suppress alerts for a short while

Describe the solution you'd like

Addition of new API endpoints to add maintenance tasks , probably also list and delete maintenance tasks but not sure we will use those to start Our intended solution is just before the reboot switch command is sent, we make an API call to NAV to start a ~15 min maintenance task. If the API can handle adding up to ~50 tiny maintenance windows with one device each in rapid succession that would be good, or maybe we can also try to schedule a bit longer window for up to 50 devices at a time with one API call

Describe alternatives you've considered

Additional context

We have discussed this in meetings a while back but I think I never actually created the issue on github before (or if I did I can't find it anymore)

lunkwill42 commented 1 month ago

Making this available through API sounds worthwhile to me, at least.

Our intended solution is just before the reboot switch command is sent, we make an API call to NAV to start a ~15 min maintenance task.

Just be aware that in the current implementation, maintenance schedules are processed only every 5 minutes by a cron job. I.e. you can create a new maintenance task that has a start time of "now", but up to 5 minutes could potentially pass until the components are actually marked as being on maintenance.

If the API can handle adding up to ~50 tiny maintenance windows with one device each in rapid succession that would be good, or maybe we can also try to schedule a bit longer window for up to 50 devices at a time with one API call

Are you asking that a single API request can be used to create 50 separate maintenance tasks in one go?

This sounds counterintuitive to me, given how maintenance tasks work in NAV: You'd seriously crowd your maintenance calendar if you added single tasks for each device in this manner. If your intention is to reboot 50 devices in bulk over the course of the next 15 minutes, I'd try to post that as a single maintenance task that contains all those 50 devices.