admin control features and admin dashboard

This commit is contained in:
ayurishchev committed 2026-08-23 20:39:22 +03:00
1 parent c630f13c57
commit 37910e410b
69 files changed
+4959 -400

No files matched your search

+46
View File
@@ -73,3 +73,49 @@ func (s *Server) handleAdminValidators(w http.ResponseWriter, r *http.Request) {
}
writeJSON(w, http.StatusOK, validators)
}
// handleAdminSubmitIPs is the single entry point for both adding new
// addresses to the queue and forcing a re-check of already-finished ones —
// see db.SubmitIPs for the exact per-address rules. It's a direct DB call
// (no OpenStack interaction is needed to merely queue work), matching the
// existing admin handlers above which also bypass the orchestrator for
// reads.
func (s *Server) handleAdminSubmitIPs(w http.ResponseWriter, r *http.Request) {
var req submitIPsRequest
if err := readJSON(r, &req); err != nil {
writeError(w, http.StatusBadRequest, "invalid body: "+err.Error())
return
}
result, err := s.DB.SubmitIPs(r.Context(), req.Addresses)
if err != nil {
writeDBError(w, err)
return
}
writeJSON(w, http.StatusOK, submitIPsResponse{
Added: emptyIfNil(result.Added),
Requeued: emptyIfNil(result.Requeued),
Reordered: emptyIfNil(result.Reordered),
SkippedInProgress: emptyIfNil(result.SkippedInProgress),
})
}
// handleAdminCancelIP force-stops a check in progress (or still-queued) for
// the given address. Requires the orchestrator, since a floating IP may
// need to be disassociated in OpenStack.
func (s *Server) handleAdminCancelIP(w http.ResponseWriter, r *http.Request) {
address := r.PathValue("ip")
if err := s.Orch.ForceCancel(r.Context(), address); err != nil {
writeDBError(w, err)
return
}
writeJSON(w, http.StatusOK, okResponse{OK: true})
}
// emptyIfNil turns a nil slice into an empty one so these fields always
// marshal as `[]` rather than `null`.
func emptyIfNil(s []string) []string {
if s == nil {
return []string{}
}
return s
}