fix: proxmox client relit la config DB à chaque requête (token update sans redémarrage)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c0dff6d86f
commit
c6028b6951
1 changed files with 3 additions and 7 deletions
|
|
@ -58,16 +58,14 @@ func (h *ProxmoxHandler) initClient() {
|
|||
log.Printf("[proxmox/init] Impossible de déchiffrer le token : %v", err)
|
||||
return
|
||||
}
|
||||
log.Printf("[proxmox/init] Client initialisé — url=%s", url)
|
||||
h.client = proxmox.NewClient(url, token)
|
||||
}
|
||||
|
||||
// GetResources retourne la liste de toutes les ressources Proxmox (LXC + VM + nodes).
|
||||
// GET /api/proxmox/resources
|
||||
func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) {
|
||||
if h.client == nil {
|
||||
// Toujours relire la config (prend en compte les mises à jour du token sans redémarrage)
|
||||
h.initClient()
|
||||
}
|
||||
if h.client == nil {
|
||||
JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable)
|
||||
return
|
||||
|
|
@ -86,9 +84,7 @@ func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) {
|
|||
// GetLXC retourne uniquement les conteneurs LXC.
|
||||
// GET /api/proxmox/lxc
|
||||
func (h *ProxmoxHandler) GetLXC(w http.ResponseWriter, r *http.Request) {
|
||||
if h.client == nil {
|
||||
h.initClient()
|
||||
}
|
||||
if h.client == nil {
|
||||
JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue